| From | Sent On | Attachments |
|---|---|---|
| Ed Schouten | Nov 2, 2008 9:17 am | .diff |
| Nathan Whitehorn | Nov 2, 2008 9:22 am | |
| Ed Schouten | Nov 2, 2008 10:43 am | |
| Nathan Whitehorn | Jan 19, 2009 4:22 pm |
| Subject: | ADB mouse fixup | |
|---|---|---|
| From: | Ed Schouten (ed...@80386.nl) | |
| Date: | Nov 2, 2008 9:17:17 am | |
| List: | org.freebsd.freebsd-ppc | |
| Attachments: | ||
Hello all,
After getting Xorg working on my Powerbook 12", I noticed the mouse driver did something strange w.r.t. mouse buttons. After adding printf's to the source code, I noticed it generated button 2 clicks each time I just touched the pad.
It turns out there is this a piece of code in the ADB mouse driver that converts events of buttons that exceed the amount of buttons of the device to button events of the last available button. Disabling this code makes the mouse driver work properly.
Any comments on the attached patch before I commit it to SVN? Thanks!
-- Ed Schouten <ed...@80386.nl> WWW: http://80386.nl/
Index: adb_mouse.c =================================================================== --- adb_mouse.c (revision 184521) +++ adb_mouse.c (working copy) @@ -67,7 +67,9 @@ struct mtx sc_mtx; struct cv sc_cv;
- int extended; + int flags; +#define AMS_EXTENDED 0x1 +#define AMS_TOUCHPAD 0x2 uint16_t dpi;
mousehw_t hw; @@ -150,7 +152,7 @@ mtx_init(&sc->sc_mtx,"ams",MTX_DEF,0); cv_init(&sc->sc_cv,"ams");
- sc->extended = 0; + sc->flags = 0;
sc->hw.buttons = 2; sc->hw.iftype = MOUSE_IF_UNKNOWN; @@ -183,7 +185,7 @@ if (r1_len < 8) break;
- sc->extended = 1; + sc->flags |= AMS_EXTENDED; memcpy(&sc->hw.hwid,r1,4); sc->mode.resolution = (r1[4] << 8) | r1[5];
@@ -200,6 +202,10 @@ sc->hw.type = MOUSE_TRACKBALL; description = "Trackball"; break; + case 3: + sc->flags |= AMS_TOUCHPAD; + description = "Touchpad"; + break; }
sc->hw.buttons = r1[7]; @@ -219,7 +225,7 @@
if (adb_get_device_handler(dev) == 0x42) { device_printf(dev, "MacAlly 2-Button Mouse\n"); - sc->extended = 0; + sc->flags &= ~AMS_EXTENDED; } }
@@ -272,7 +278,7 @@ buttons |= !(data[0] & 0x80); buttons |= !(data[1] & 0x80) << 1;
- if (sc->extended) { + if (sc->flags & AMS_EXTENDED) { for (i = 2; i < len && i < 5; i++) { xdelta |= (data[i] & 0x07) << (3*i + 1); ydelta |= (data[i] & 0x70) << (3*i - 3); @@ -294,12 +300,16 @@ * Some mice report high-numbered buttons on the wrong button number, * so set the highest-numbered real button as pressed if there are * mysterious high-numbered ones set. + * + * Don't do this for touchpads, because touchpads also trigger + * high button events when they are touched. */
- if (buttons & ~((1 << sc->hw.buttons) - 1)) { + if (buttons & ~((1 << sc->hw.buttons) - 1) + && !(sc->flags & AMS_TOUCHPAD)) { buttons |= 1 << (sc->hw.buttons - 1); - buttons &= (1 << sc->hw.buttons) - 1; } + buttons &= (1 << sc->hw.buttons) - 1;
mtx_lock(&sc->sc_mtx);






.diff