Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Nov 2008 18:17:54 +0100
From:      Ed Schouten <ed@80386.nl>
To:        freebsd-ppc@FreeBSD.org
Cc:        nwhitehorn@FreeBSD.org
Subject:   ADB mouse fixup
Message-ID:  <20081102171754.GS1165@hoeg.nl>

next in thread | raw e-mail | index | archive | help

--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 <ed@80386.nl>
 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081102171754.GS1165>