From owner-svn-src-head@FreeBSD.ORG Sun Nov 2 19:08:10 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7A7571065687; Sun, 2 Nov 2008 19:08:10 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 68CC18FC1A; Sun, 2 Nov 2008 19:08:10 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mA2J8A5g045952; Sun, 2 Nov 2008 19:08:10 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mA2J8Axn045951; Sun, 2 Nov 2008 19:08:10 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200811021908.mA2J8Axn045951@svn.freebsd.org> From: Ed Schouten Date: Sun, 2 Nov 2008 19:08:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r184565 - head/sys/dev/adb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Nov 2008 19:08:10 -0000 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);