summaryrefslogtreecommitdiff
path: root/src/evdev.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-05-20 11:57:01 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-05-21 15:51:08 +1000
commitb358f1eb3a4ef8fdee099114d6c70d6ea06eba95 (patch)
treec15be5bb3f4dcdaee756601c385d30cf6529908c /src/evdev.c
parent33cc112ca1af377a85cfeb05dfb72f07d3850a95 (diff)
Ensure enough buttons are advertised to pass the button mapping.
Some buttons are mapped to higher button numbers. For example, BTN_0 is posted as button 8 if BTN_LEFT is present. On top of that, the driver-specific button mapping may map the button to something else again. We need to take these mappings into account when counting the number of buttons on the device. Example: A device with BTN_LEFT and BTN_0 and a mapping from 1 -> 7 and 8 -> 2. BTN_LEFT is mapped to 1. 1 is mapped to 7. num_buttons is 7. BTN_0 is mapped to 8. 8 is mapped to 2. num_buttons remains 7. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src/evdev.c')
-rw-r--r--src/evdev.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/evdev.c b/src/evdev.c
index 4a9a331..63e70a3 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1488,8 +1488,14 @@ EvdevProbe(InputInfoPtr pInfo)
/* count all buttons */
for (i = BTN_MISC; i < BTN_JOYSTICK; i++)
{
+ int mapping = 0;
if (TestBit(i, pEvdev->key_bitmask))
- num_buttons++;
+ {
+ mapping =
+ pEvdev->btnmap[EvdevUtilButtonEventToButtonNumber(pEvdev, i)];
+ if (mapping > num_buttons)
+ num_buttons = mapping;
+ }
}
if (num_buttons)