Subject: port-macppc/28366: PowerBook trackpad has phantom (and really annoying) mouse button
To: None <port-macppc-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: None <michael@nosflow.com>
List: netbsd-bugs
Date: 11/20/2004 08:53:00
>Number:         28366
>Category:       port-macppc
>Synopsis:       PowerBook trackpad has phantom (and really annoying) mouse button
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    port-macppc-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Nov 20 08:53:00 +0000 2004
>Originator:     Michael Wolfson
>Release:        2.0RC5
>Organization:
>Environment:
NetBSD gizmobook 2.0_RC5 NetBSD 2.0_RC5 (GIZMOBOOK) #4: Tue Nov 16 19:17:22 PST 2004  mw@gizmobook:/usr/src/src-2-0/sys/arch/macppc/compile/GIZMOBOOK macppc
>Description:
When using the built-in trackpad on my PowerBook G3 (FireWire), it randomly acts like there is a mouse button pushed.  Aymeric.Vincent@labri.fr has also seen this problem on his iBook and says:
http://mail-index.netbsd.org/port-macppc/2004/11/17/0008.html

I have a local patch in my kernel to ignore the 5th button generated
by a tap on the trackpad because it makes Xt menus unusable, but then
again it looks like I'm the only one affected.
(I intend to change this into real support for the tap before I get
 rid of my iBook)
>How-To-Repeat:
Boot NetBSD on macppc laptop and try using mouse in X windows.  This problem is apparent in both Xmacppc and XFree86
>Fix:
It should be possible to detect when a trackpad is in use an limit the number of buttons so only real ones are recognized.  From my dmesg:
ams0 at adb0 addr 3: EMP trackpad <tpad> 2-button, 400 dpi
wsmouse0 at ams0 mux 0

A blunt hack provided by Aymeric is (and it works on my PowerBook):
Index: ams.c
===================================================================
RCS file: /cvsroot/src/sys/arch/macppc/dev/ams.c,v
retrieving revision 1.16
diff -c -r1.16 ams.c
*** ams.c       15 Jul 2003 02:43:28 -0000      1.16
--- ams.c       20 Nov 2004 08:43:26 -0000
***************
*** 496,501 ****
--- 496,505 ----
                                buttons |= button_bit;
                        else
                                buttons &= ~button_bit;
+ 
+ #if 1
+               mask = 0;
+ #else
                /* Extended Protocol (up to 6 more buttons) */
                for (mask = 0x80; i < max_byte;
                     i += (mask == 0x80), button_bit <<= 1) {
***************
*** 507,512 ****
--- 511,517 ----
                        mask = ((mask >> 4) & 0xf)
                                | ((mask & 0xf) << 4);
                }
+ #endif
                break;
        }
        new_event.u.m.buttons = sc->sc_mb | buttons;
(