Comment 2 for bug 284951

Revision history for this message
In , Albert Damen (albrt) wrote :

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.