Date: Sun, 2 Nov 2008 19:08:10 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r184565 - head/sys/dev/adb Message-ID: <200811021908.mA2J8Axn045951@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ed Date: Sun Nov 2 19:08:10 2008 New Revision: 184565 URL: http://svn.freebsd.org/changeset/base/184565 Log: Make the touch pad on my PowerBook G4 12" a little more usable. For an unknown reason the touch pad of my PowerBook generates button 5 events when you operate it. This causes the adb_mouse code to convert them to button 2 events, which is not what we want. Add a new flag, AMS_TOUCHPAD, which is used to distinguish the touch pad. When set, don't convert button events of unknown buttons to the last button. There are still three problems left with respect to user input: - The mouse button events are not properly processed when the touch pad isn't touched. - The arrow keys on the keyboard don't work inside X11. - The power button isn't handled by the kernel, similar to the ACPI power button on i386/amd64. Approved by: nwhitehorn Modified: head/sys/dev/adb/adb_mouse.c Modified: head/sys/dev/adb/adb_mouse.c ============================================================================== --- head/sys/dev/adb/adb_mouse.c Sun Nov 2 18:48:54 2008 (r184564) +++ head/sys/dev/adb/adb_mouse.c Sun Nov 2 19:08:10 2008 (r184565) @@ -67,7 +67,9 @@ struct adb_mouse_softc { 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 @@ adb_mouse_attach(device_t dev) 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 @@ adb_mouse_attach(device_t dev) 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,11 @@ adb_mouse_attach(device_t dev) sc->hw.type = MOUSE_TRACKBALL; description = "Trackball"; break; + case 3: + sc->flags |= AMS_TOUCHPAD; + sc->hw.type = MOUSE_PAD; + description = "Touchpad"; + break; } sc->hw.buttons = r1[7]; @@ -219,7 +226,7 @@ adb_mouse_attach(device_t dev) if (adb_get_device_handler(dev) == 0x42) { device_printf(dev, "MacAlly 2-Button Mouse\n"); - sc->extended = 0; + sc->flags &= ~AMS_EXTENDED; } } @@ -272,7 +279,7 @@ adb_mouse_receive_packet(device_t dev, u 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 +301,16 @@ adb_mouse_receive_packet(device_t dev, u * 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811021908.mA2J8Axn045951>