[PATCH] xf86-input-evdev: Fix EVIOCGBIT ioctl usage on big endian platforms.

Michel Dänzer michel at tungstengraphics.com
Tue Jul 29 01:06:07 PDT 2008


With this fix, on my PowerBook HAL hotplugging correctly detects my USB mouse,
and no longer thinks keyboards have random numbers of mouse buttons. :)

The LONG_BITS and NBITS macro definitions are stolen from xf86-video-synaptics.

Signed-off-by: Michel Dänzer <michel at tungstengraphics.com>
---
 src/evdev.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index f831081..58aa3dc 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -346,7 +346,9 @@ EvdevReadInput(InputInfoPtr pInfo)
     }
 }
 
-#define TestBit(bit, array) (array[(bit) / 8] & (1 << ((bit) % 8)))
+#define LONG_BITS (sizeof(long) * 8)
+#define NBITS(x) (((x) + LONG_BITS - 1) / LONG_BITS)
+#define TestBit(bit, array) (array[(bit) / LONG_BITS]) & (1 << ((bit) % LONG_BITS))
 
 static void
 EvdevPtrCtrlProc(DeviceIntPtr device, PtrCtrl *ctrl)
@@ -980,9 +982,9 @@ EvdevProc(DeviceIntPtr device, int what)
 static int
 EvdevProbe(InputInfoPtr pInfo)
 {
-    char key_bitmask[(KEY_MAX + 7) / 8];
-    char rel_bitmask[(REL_MAX + 7) / 8];
-    char abs_bitmask[(ABS_MAX + 7) / 8];
+    long key_bitmask[NBITS(KEY_MAX)];
+    long rel_bitmask[NBITS(REL_MAX)];
+    long abs_bitmask[NBITS(ABS_MAX)];
     int i, has_axes, has_keys, num_buttons;
     EvdevPtr pEvdev = pInfo->private;
 
-- 
1.5.6.3


-- 
Earthling Michel Dänzer           |          http://tungstengraphics.com
Libre software enthusiast         |          Debian, X and DRI developer




More information about the xorg mailing list