summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@redhat.com>2008-10-29 13:50:07 +1030
committerPeter Hutterer <peter.hutterer@redhat.com>2008-11-03 13:46:35 +1030
commit6bcbbc0411cf3466edeb1fcbb393290cadfd3082 (patch)
tree6d5618be8028223e14193cf94dbda707d9adc01b
parent534a3734d088ff0155ebc7fca7ab246635cd725a (diff)
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)
-rw-r--r--src/evdev.c27
-rw-r--r--src/evdev.h2
2 files changed, 24 insertions, 5 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);
+ }
}
}
diff --git a/src/evdev.h b/src/evdev.h
index 7e1da15..5a97185 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -119,7 +119,7 @@ typedef struct {
struct input_absinfo absinfo[ABS_MAX];
} EvdevRec, *EvdevPtr;
-unsigned int EvdevUtilButtonEventToButtonNumber(int code);
+unsigned int EvdevUtilButtonEventToButtonNumber(EvdevPtr pEvdev, int code);
/* Middle Button emulation */
int EvdevMBEmuTimer(InputInfoPtr);