From 7589cb5cae8a0cebbf08e0499e6cc6035b2c93fa Mon Sep 17 00:00:00 2001 From: Philip Paeps Date: Sun, 8 Aug 2004 00:57:07 +0000 Subject: Update support for Synaptics Touchpads (Volume II) o Handle the 'up/down' buttons some touchpads have as a z-axis (scrollwheel) as recommended by the specs o Report the buttons as button4 and button5 instead of button2 and button4, button2 can be emulated by pressing button1 and button3 simultaneously. This allows one to use the two extra buttons for other purposes if one so desires. Tested by: many subscribers to -current Approved by: njl --- sys/isa/psm.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'sys/isa') diff --git a/sys/isa/psm.c b/sys/isa/psm.c index d81177748c8d..37faa1bfca18 100644 --- a/sys/isa/psm.c +++ b/sys/isa/psm.c @@ -2502,16 +2502,19 @@ psmsoftintr(void *arg) ((pb->ipacket[0] & 0x04) >> 1) | ((pb->ipacket[3] & 0x04) >> 2); + /* Button presses */ ms.button = 0; if (pb->ipacket[0] & 0x01) ms.button |= MOUSE_BUTTON1DOWN; if (pb->ipacket[0] & 0x02) ms.button |= MOUSE_BUTTON3DOWN; - if ((pb->ipacket[3] & 0x01) && (pb->ipacket[0] & 0x01) == 0) - ms.button |= MOUSE_BUTTON2DOWN; - if ((pb->ipacket[3] & 0x02) && (pb->ipacket[0] & 0x02) == 0) - ms.button |= MOUSE_BUTTON4DOWN; + if (sc->synhw.capExtended && sc->synhw.capFourButtons) { + if ((pb->ipacket[3] & 0x01) && (pb->ipacket[0] & 0x01) == 0) + ms.button |= MOUSE_BUTTON4DOWN; + if ((pb->ipacket[3] & 0x02) && (pb->ipacket[0] & 0x02) == 0) + ms.button |= MOUSE_BUTTON5DOWN; + } /* There is a finger on the pad. */ if ((w >= 4 && w <= 7) && (z >= 16 && z < 200)) { @@ -2537,7 +2540,15 @@ psmsoftintr(void *arg) } else { sc->flags &= ~PSM_FLAGS_FINGERDOWN; } - z = 0; + + /* Use the extra buttons as a scrollwheel */ + if (ms.button & MOUSE_BUTTON4DOWN) + z = -1; + else if (ms.button & MOUSE_BUTTON5DOWN) + z = 1; + else + z = 0; + break; case MOUSE_MODEL_GENERIC: @@ -3140,6 +3151,16 @@ enable_synaptics(struct psm_softc *sc) /* Reset the sampling rate */ set_mouse_sampling_rate(kbdc, 20); + /* + * Report the correct number of buttons + * + * XXX: I'm not sure this is used anywhere. + */ + if (sc->synhw.capExtended && sc->synhw.capFourButtons) + sc->hw.buttons = 4; + else + sc->hw.buttons = 3; + return (TRUE); } -- cgit v1.3