From owner-freebsd-ppc@FreeBSD.ORG Sun Nov 2 17:17:56 2008 Return-Path: Delivered-To: freebsd-ppc@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2E75106568E; Sun, 2 Nov 2008 17:17:56 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from palm.hoeg.nl (mx0.hoeg.nl [IPv6:2001:7b8:613:100::211]) by mx1.freebsd.org (Postfix) with ESMTP id 5F3698FC27; Sun, 2 Nov 2008 17:17:56 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: by palm.hoeg.nl (Postfix, from userid 1000) id CF6A71CCB2; Sun, 2 Nov 2008 18:17:54 +0100 (CET) Date: Sun, 2 Nov 2008 18:17:54 +0100 From: Ed Schouten To: freebsd-ppc@FreeBSD.org Message-ID: <20081102171754.GS1165@hoeg.nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="DOQx4ubtbYINM/to" Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Cc: nwhitehorn@FreeBSD.org Subject: ADB mouse fixup X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Nov 2008 17:17:57 -0000 --DOQx4ubtbYINM/to Content-Type: multipart/mixed; boundary="T/yvDUeUQRtJzDrt" Content-Disposition: inline --T/yvDUeUQRtJzDrt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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! --=20 Ed Schouten WWW: http://80386.nl/ --T/yvDUeUQRtJzDrt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="adb_mouse.diff" Content-Transfer-Encoding: quoted-printable Index: adb_mouse.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- adb_mouse.c (revision 184521) +++ adb_mouse.c (working copy) @@ -67,7 +67,9 @@ struct mtx sc_mtx; struct cv sc_cv; =20 - int extended; + int flags; +#define AMS_EXTENDED 0x1 +#define AMS_TOUCHPAD 0x2 uint16_t dpi; =20 mousehw_t hw; @@ -150,7 +152,7 @@ mtx_init(&sc->sc_mtx,"ams",MTX_DEF,0); cv_init(&sc->sc_cv,"ams"); =20 - sc->extended =3D 0; + sc->flags =3D 0; =20 sc->hw.buttons =3D 2; sc->hw.iftype =3D MOUSE_IF_UNKNOWN; @@ -183,7 +185,7 @@ if (r1_len < 8) break; =20 - sc->extended =3D 1; + sc->flags |=3D AMS_EXTENDED; memcpy(&sc->hw.hwid,r1,4); sc->mode.resolution =3D (r1[4] << 8) | r1[5]; =20 @@ -200,6 +202,10 @@ sc->hw.type =3D MOUSE_TRACKBALL; description =3D "Trackball"; break; + case 3: + sc->flags |=3D AMS_TOUCHPAD; + description =3D "Touchpad"; + break; } =20 sc->hw.buttons =3D r1[7]; @@ -219,7 +225,7 @@ =20 if (adb_get_device_handler(dev) =3D=3D 0x42) { device_printf(dev, "MacAlly 2-Button Mouse\n"); - sc->extended =3D 0; + sc->flags &=3D ~AMS_EXTENDED; } } =09 @@ -272,7 +278,7 @@ buttons |=3D !(data[0] & 0x80); buttons |=3D !(data[1] & 0x80) << 1; =20 - if (sc->extended) { + if (sc->flags & AMS_EXTENDED) { for (i =3D 2; i < len && i < 5; i++) { xdelta |=3D (data[i] & 0x07) << (3*i + 1); ydelta |=3D (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. */ =20 - if (buttons & ~((1 << sc->hw.buttons) - 1)) { + if (buttons & ~((1 << sc->hw.buttons) - 1) + && !(sc->flags & AMS_TOUCHPAD)) { buttons |=3D 1 << (sc->hw.buttons - 1); - buttons &=3D (1 << sc->hw.buttons) - 1; } + buttons &=3D (1 << sc->hw.buttons) - 1; =20 mtx_lock(&sc->sc_mtx); =20 --T/yvDUeUQRtJzDrt-- --DOQx4ubtbYINM/to Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkkN4MIACgkQ52SDGA2eCwVNYwCfakcUuTc0FocxKVbrsgM7orjM UpkAn13FtoVYhovUoLNGCREQQCLmKfog =zAOH -----END PGP SIGNATURE----- --DOQx4ubtbYINM/to--