Bug 4382

Summary: first joystick button mapped to extra number
Product: Alternate Trees Reporter: Matthew Mueller (pygvkxh02)
Component: mmAssignee: Vojtech Pavlik (vojtech)
Status: CLOSED CODE_FIX    
Severity: normal CC: bunk, guichaz
Priority: P2    
Hardware: i386   
OS: Linux   
Kernel Version: 2.6.12-rc1-mm1 Subsystem:
Regression: --- Bisected commit-id:
Attachments: evtest log for rumblepad2 on 2.6.11.1
evtest log for sw3dpro on 2.6.11.1
evtest log for rumblepad2 on 2.6.12-rc1-mm1
evtest log for sw3dpro on 2.6.12-rc1-mm1
Patch to fix the extra button

Description Matthew Mueller 2005-03-21 23:50:58 UTC
Distribution: Debian unstable
Hardware Environment: Athlon64 3000+, Chaintech vnf3-250 mobo, 1GB ram, SB
Audigy (w/game port slot thing attached), Logitech Rumblepad 2 gamepad (usb), MS
Sidewinder 3D Pro joystick (gameport)
Software Environment: jstest
Problem Description: The first button of each of my joysticks did not register
as button 0, but instead as an extra button at the end of the list.

On kernel 2.6.11.1:
Joystick (Microsoft SideWinder 3D Pro) has 6 axes and 9 buttons. Driver version
is 2.1.0.
When I press the trigger, button 0 is indicated as on.
Joystick (Logitech Logitech RumblePad 2 USB) has 6 axes and 12 buttons. Driver
version is 2.1.0.
When I press the button labelled "1" on the control, jstest indicates button 0
as on.

On 2.6.12-rc1-mm1 jstest says:
Joystick (Microsoft SideWinder 3D Pro) has 6 axes and 10 buttons. Driver version
is 2.1.0.
When I press the trigger, button 9 is indicated as on.
Joystick (Logitech Logitech RumblePad 2 USB) has 6 axes and 13 buttons. Driver
version is 2.1.0.
When I press the button labelled "1" on the control, jstest indicates button 12
as on.

Steps to reproduce:
1. run jstest <joy device>
2. jstest will say there is one more button than there actually is.
3. press each button on joystick.
4. button 0 never registers, but the extra button number does instead.
Comment 1 Matthew Mueller 2005-03-21 23:55:23 UTC
Oh, I should note: this was with 64 bit kernel, and the problem occured both
with 64bit jstest and 32bit jstest running in a chroot.
Comment 2 Vojtech Pavlik 2005-03-22 00:55:11 UTC
Can you test the joysticks with evtest in addition to jstest, to see where
the extra button comes from?
Comment 3 Matthew Mueller 2005-03-22 01:53:07 UTC
Ok, I tested it with evtest under both kernels, though there doesn't seem to be
a whole lot of differences..  I'll attach the logs.  In each log I also pressed
and released (what should be) button 0 once.  (The sw3dpro logs have extra
events since it's hard to hit the trigger without moving the stick.)
Comment 4 Matthew Mueller 2005-03-22 01:55:01 UTC
Created attachment 4769 [details]
evtest log for rumblepad2 on 2.6.11.1
Comment 5 Matthew Mueller 2005-03-22 01:55:41 UTC
Created attachment 4770 [details]
evtest log for sw3dpro on 2.6.11.1
Comment 6 Matthew Mueller 2005-03-22 01:56:52 UTC
Created attachment 4771 [details]
evtest log for rumblepad2 on 2.6.12-rc1-mm1
Comment 7 Matthew Mueller 2005-03-22 01:57:18 UTC
Created attachment 4772 [details]
evtest log for sw3dpro on 2.6.12-rc1-mm1
Comment 8 Vojtech Pavlik 2005-03-22 05:06:23 UTC
Created attachment 4773 [details]
Patch to fix the extra button

This patch should fix your problems.
Comment 9 Matthew Mueller 2005-03-22 21:54:17 UTC
Yep, that fixed it.  Thanks.
Comment 10 Guillaume Chazarain 2005-04-26 00:58:20 UTC
Of course, this patch fixes also my problem (http://lkml.org/lkml/2005/4/12/145).
Sorry for posting to LKML without having checked bugzilla first.
BTW, I am wondering why this patch is not in -mm or in linus' tree.
Comment 11 Andrew Morton 2005-05-25 16:57:58 UTC
Guys, can you please confirm that 2.6.12-rc5 has all the needed fixes and is
functioning OK?

Thanks.
Comment 12 Guillaume Chazarain 2005-05-27 05:13:25 UTC
I will try to test tonight, but IIRC, the fix
(http://bugzilla.kernel.org/attachment.cgi?id=4773) is included in
ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.12-rc5/2.6.12-rc5-mm1/broken-out/bk-input.patch
so not in 2.6.12-rc5.

This hunk to joydev.c is enough to fix the problem for me:

-	for (i = 0; i < BTN_JOYSTICK - BTN_MISC + 1; i++)
+	for (i = 0; i < BTN_JOYSTICK - BTN_MISC; i++)
Comment 13 Matthew Mueller 2005-05-27 11:53:03 UTC
I just tested 2.6.12-rc5, the extra button problem is indeed still present.
Comment 14 Guillaume Chazarain 2005-05-27 12:26:04 UTC
After actually testing, I confirm the bug is still present.
Comment 15 Adrian Bunk 2005-06-07 13:44:36 UTC
The fix went into 2.6.12-rc6.

Can you confirm it's fixed there?
Comment 16 Guillaume Chazarain 2005-06-09 08:58:04 UTC
I confirm it's fixed, the bug should be marked as CLOSED.
Comment 17 Matthew Mueller 2005-06-24 05:15:02 UTC
I tested 2.6.12, it is fixed there also.
Comment 18 Adrian Bunk 2005-06-24 05:21:02 UTC
Thanks, I'm therefore closing this bug.