Bug 18150 - evdev detects non-existing button as mouse button
evdev detects non-existing button as mouse button
Status: RESOLVED FIXED
Product: xorg
Classification: Unclassified
Component: Input/evdev
7.4 (2008.09)
x86-64 (AMD64) Linux (All)
: medium normal
Assigned To: Peter Hutterer
Xorg Project Team
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-10-21 05:13 UTC by Albert Damen
Modified: 2008-10-21 12:55 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Albert Damen 2008-10-21 05:13:20 UTC
In Ubuntu Intrepid on amd64, my gamepad and joystick are detected by evdev as mouse. Therefore they act as mouse pointer and cannot be used as joystick.

I changed evdev to log the buttons it found. This reported a non-existing button 287. As 287 < BTN_JOYSTICK, evdev considers it a mouse button and configures the device as mouse. However, there is no physical button that actually generates code 287.

Searching further I found TestBit(287, key_bitmask) reported strange values. I expected either 0 if bit 287 is not set, or 2^31 if the bit is set. However, TestBit returned for example 140636556623872.
That suggests the bitmask used by TestBit is not correct.

Changing:
#define TestBit(bit, array) (array[(bit) / LONG_BITS]) & (1 << ((bit) % LONG_BITS))

Into:
#define TestBit(bit, array) (array[(bit) / LONG_BITS]) & (1l << ((bit) % LONG_BITS))
(note the 1l instead of 1)

in src/evdev.c solved the problem for me. Evdev no longer sees button 287. When I connect the gamepad, evdev now logs:
(II) config/hal: Adding input device Logitech Logitech RumblePad 2 USB
(**) Logitech Logitech RumblePad 2 USB: always reports core events
(**) Logitech Logitech RumblePad 2 USB: Device: "/dev/input/event2"
(II) Logitech Logitech RumblePad 2 USB: Found x and y absolute axes
(WW) Logitech Logitech RumblePad 2 USB: Don't know how to use device
(II) UnloadModule: "evdev"
(EE) PreInit returned NULL for "Logitech Logitech RumblePad 2 USB"
(EE) config/hal: NewInputDeviceRequest failed

and the gamepad and joystick can be used in jscalibrator and flightgear.
Comment 1 Julien Cristau 2008-10-21 11:12:13 UTC
On Tue, Oct 21, 2008 at 05:13:22 -0700, bugzilla-daemon@freedesktop.org wrote:

> Searching further I found TestBit(287, key_bitmask) reported strange values. I
> expected either 0 if bit 287 is not set, or 2^31 if the bit is set. However,
> TestBit returned for example 140636556623872.
> That suggests the bitmask used by TestBit is not correct.
> 
Fixed, thanks!

commit f57e8face94c9e6986b35ca2ec231e284b9f58cf
Author: Julien Cristau <jcristau@debian.org>
Date:   Tue Oct 21 19:21:21 2008 +0200

    Fix TestBit() on 64bit
    
    Reported by Albert Damen <albrt@gmx.net>
    X.Org Bug#18150 <http://bugs.freedesktop.org/show_bug.cgi?id=18150>