diff options
author | Peter Hutterer <peter.hutterer@redhat.com> | 2008-10-29 13:50:07 +1030 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@redhat.com> | 2008-11-03 13:46:35 +1030 |
commit | 6bcbbc0411cf3466edeb1fcbb393290cadfd3082 (patch) | |
tree | 6d5618be8028223e14193cf94dbda707d9adc01b /src/evdev.c | |
parent | Remove obsolete FIXME (diff) | |
download | xf86-input-evdev-6bcbbc0411cf3466edeb1fcbb393290cadfd3082.tar.gz xf86-input-evdev-6bcbbc0411cf3466edeb1fcbb393290cadfd3082.tar.bz2 xf86-input-evdev-6bcbbc0411cf3466edeb1fcbb393290cadfd3082.zip |
Treat BTN_[0-2] as LMR buttons if necessary.
Treat BTN_[0-2] as LMR buttons on devices that do not advertise BTN_LEFT,
BTN_MIDDLE, BTN_RIGHT (e.g. 3Dconnexion SpaceNavigator).
Otherwise, treat BTN_[0+n] as button 5+n. Note: This causes duplicate
mappings for BTN_0 + n and BTN_SIDE + n.
This also fixes a bug where we could end up with negative button numbers after
trying to map BTN_0.
Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
(cherry picked from commit 64554e4799a697d37dfd8be480f8eee636b9bea1)
Diffstat (limited to 'src/evdev.c')
-rw-r--r-- | src/evdev.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/evdev.c b/src/evdev.c index cc072d8..9ef2829 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -326,7 +326,7 @@ EvdevReadInput(InputInfoPtr pInfo) /* Intentional fallthrough! */ default: - button = EvdevUtilButtonEventToButtonNumber(ev.code); + button = EvdevUtilButtonEventToButtonNumber(pEvdev, ev.code); /* Handle drag lock */ if (EvdevDragLockFilterEvent(pInfo, button, value)) @@ -1448,7 +1448,7 @@ _X_EXPORT XF86ModuleData evdevModuleData = * returns 0 on non-button event. */ unsigned int -EvdevUtilButtonEventToButtonNumber(int code) +EvdevUtilButtonEventToButtonNumber(EvdevPtr pEvdev, int code) { unsigned int button = 0; @@ -1465,6 +1465,21 @@ EvdevUtilButtonEventToButtonNumber(int code) button = 2; break; + /* Treat BTN_[0-2] as LMR buttons on devices that do not advertise + BTN_LEFT, BTN_MIDDLE, BTN_RIGHT. + Otherwise, treat BTN_[0+n] as button 5+n. + XXX: This causes duplicate mappings for BTN_0 + n and BTN_SIDE + n + */ + case BTN_0: + button = (TestBit(BTN_LEFT, pEvdev->key_bitmask)) ? 8 : 1; + break; + case BTN_1: + button = (TestBit(BTN_MIDDLE, pEvdev->key_bitmask)) ? 9 : 2; + break; + case BTN_2: + button = (TestBit(BTN_RIGHT, pEvdev->key_bitmask)) ? 10 : 3; + break; + case BTN_SIDE: case BTN_EXTRA: case BTN_FORWARD: @@ -1475,8 +1490,12 @@ EvdevUtilButtonEventToButtonNumber(int code) default: if ((code > BTN_TASK) && (code < KEY_OK)) { - if (code < BTN_JOYSTICK) - button = (code - BTN_LEFT + 5); + if (code < BTN_JOYSTICK) { + if (code < BTN_MOUSE) + button = (code - BTN_0 + 5); + else + button = (code - BTN_LEFT + 5); + } } } |