diff --git a/man/evdev.man b/man/evdev.man index 8c6ed00..a309a30 100644 --- a/man/evdev.man +++ b/man/evdev.man @@ -276,10 +276,20 @@ Valid values are \*qabsolute\*q and \*qr This can be set at run time per actual device with the xinput utility. .PP .SS BUTTON CONFIGURATION -At the moment, the button portion of this driver only handles buttons -reported as mouse buttons, that is from BTN_MOUSE to BTN_JOYSTICK - 1. +Currently, this driver only supports buttons from BTN_MOUSE to BTN_GEAR_UP. +.fi +The following driver +.B Options +control the button portion of the driver: +.TP 7 +.BI "Option \*qBtnMap\*q \*q" map \*q +remaps buttons according to simple ramapping rules. The basic syntax is +.BR "\*qphysical=virtual[, ...]\*q". +This allows any physical button to be remapped to a logical button, per +device, instead of globally like with xmodmap. For instance, to reverse +the left and right buttons, you would use +.BR "\*q1=2,2=1\*q". .fi -At this time there are no configuration options for buttens. .SS KEYBOARD CONFIGURATION The keyboard portion of this driver handles all keys reported and requires XKB support. @@ -318,5 +328,7 @@ enhance the keyboard behaviour. Default Zephaniah E. Hull. .fi Kristian Høgsberg. +.fi +Brian Murray. .SH "SEE ALSO" __xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), xorgconfig(__appmansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__). diff --git a/src/evdev.h b/src/evdev.h diff --git a/src/evdev_btn.c b/src/evdev_btn.c index dc9ed67..1d3ba0d 100644 --- a/src/evdev_btn.c +++ b/src/evdev_btn.c @@ -240,7 +240,38 @@ EvdevBtnCalcRemap (InputInfoPtr pInfo) state->btn->map[1] = state->btn->map[2]; state->btn->map[2] = base; } +} + +static void +EvdevBtnUserRemap(InputInfoPtr pInfo, char * opts) +{ + evdevDevicePtr pEvdev = pInfo->private; + evdevStatePtr state = &pEvdev->state; + int b1, b2, max, i; + char * s = opts; + max = state->btn->real_buttons; + xf86Msg(X_INFO, "%s: Attempting Remap\n", pInfo->name); + for (i = 0; i < state->btn->real_buttons; i++) + state->btn->buttons = state->btn->map[i] = i + 1; + do { + if (s[0] == ',') s++; + if (sscanf(s, "%d=%d", &b1, &b2) == 2 && + b1 > 0 && b1 < EVDEV_MAXBUTTONS && + b2 > 0 && b2 < EVDEV_MAXBUTTONS ) + { + xf86Msg(X_INFO, "%s: Remapped %d to %d\n", pInfo->name, b1, b2); + state->btn->map[b1 - 1] = b2; + if (b2 > max) max = b2; + } + } while ((s = strstr(s, ",")) != NULL); + state->btn->buttons = max; +} +static void +EvdevBtnUpdateButtons(InputInfoPtr pInfo) { + evdevDevicePtr pEvdev = pInfo->private; + evdevStatePtr state = &pEvdev->state; + int i; if (state->rel) { for (i = 0; i < REL_MAX; i++) { if (state->rel->btnMap[i][0] > state->btn->buttons) @@ -264,7 +295,7 @@ EvdevBtnNew0(InputInfoPtr pInfo) for (i = BTN_MISC; i < (KEY_OK - 1); i++) if (test_bit (i, pEvdev->bits.key)) { bit = i; - if ((bit >= BTN_MOUSE) && (bit < BTN_JOYSTICK)) { + if ((bit >= BTN_MOUSE) && (bit <= BTN_GEAR_UP)) { bit -= BTN_MOUSE - BTN_MISC; } else if ((bit >= BTN_MISC) && (bit < BTN_MOUSE)) { bit += BTN_MOUSE - BTN_MISC; @@ -284,11 +315,18 @@ EvdevBtnNew1(InputInfoPtr pInfo) { evdevDevicePtr pEvdev = pInfo->private; evdevStatePtr state = &pEvdev->state; + char * opts; if (!state->btn) return !Success; - EvdevBtnCalcRemap (pInfo); + opts = xf86SetStrOption(pInfo->options, "BtnMap", NULL); + if (!opts) + EvdevBtnCalcRemap (pInfo); + else + EvdevBtnUserRemap(pInfo, opts); + + EvdevBtnUpdateButtons(pInfo); if (state->btn->buttons) xf86Msg(X_INFO, "%s: Configured %d mouse buttons\n", pInfo->name, state->btn->buttons); @@ -320,7 +358,7 @@ EvdevBtnProcess (InputInfoPtr pInfo, str button = ev->code; - if ((ev->code >= BTN_MOUSE) && (ev->code < BTN_JOYSTICK)) { + if ((ev->code >= BTN_MOUSE) && (ev->code <= BTN_GEAR_UP)) { button -= BTN_MOUSE - BTN_MISC; } else if ((ev->code >= BTN_MISC) && (ev->code < BTN_MOUSE)) { button += BTN_MOUSE - BTN_MISC; @@ -356,7 +394,7 @@ EvdevBtnExists (InputInfoPtr pInfo, int xf86Msg(X_INFO, "%s: Checking button %s (%d)\n", pInfo->name, button_names[button - BTN_MISC], button); - if ((button >= BTN_MOUSE) && (button < BTN_JOYSTICK)) { + if ((button >= BTN_MOUSE) && (button <= BTN_GEAR_UP)) { button -= BTN_MOUSE - BTN_MISC; } else if ((button >= BTN_MISC) && (button < BTN_MOUSE)) { button += BTN_MOUSE - BTN_MISC;