Bug 18150 - evdev detects non-existing button as mouse button
Summary: evdev detects non-existing button as mouse button
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Input/evdev (show other bugs)
Version: 7.4 (2008.09)
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Peter Hutterer
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
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

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>


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.