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_btn.c b/src/evdev_btn.c index b9bfe07..e0348b8 100644 --- a/src/evdev_btn.c +++ b/src/evdev_btn.c @@ -258,7 +258,7 @@ EvdevBtnCalcRemap (InputInfoPtr pInfo) */ bit = i; bit += BTN_MISC; - 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; @@ -276,7 +276,39 @@ EvdevBtnCalcRemap (InputInfoPtr pInfo) btn->map[1] = btn->map[2]; 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; + evdevBtnPtr btn = state->btn; + int i; if (state->rel) { for (i = 0; i < REL_MAX; i++) { if (state->rel->btnMap[i][0] > btn->buttons) @@ -309,7 +341,7 @@ EvdevBtnNew0(InputInfoPtr pInfo) for (i = BTN_MISC; i < (KEY_OK - 1); i++) { btn = i; - if ((btn >= BTN_MOUSE) && (btn < BTN_JOYSTICK)) { + if ((btn >= BTN_MOUSE) && (btn <= BTN_GEAR_UP)) { btn -= BTN_MOUSE - BTN_MISC; } else if ((btn >= BTN_MISC) && (btn < BTN_MOUSE)) { btn += BTN_MOUSE - BTN_MISC; @@ -346,11 +378,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); @@ -382,7 +421,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; @@ -424,7 +463,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;