diff --git a/README b/README index 9a11d29..7597524 100644 --- a/README +++ b/README @@ -257,6 +257,15 @@ multiple keycodes might break the mapping from keysym to evdev code. When you try to let a gamepad key send a keyboard event you might run into trouble with Xorg, for possible fixes see the section further down. +For joystick buttons there is in addition to the BTN_JOYSTICK, BTN_X, +etc. macros the special name JS_$NUM, which sets the given button to +the $NUMS joystick button, i.e.: + + % xboxdrv --ui-clear --ui-buttonmap A=JS_0,B=JS_1 + +Note that this will only work if no other joystick button ids are in +the way + In addition to just the event you can also pass additional configuration parameter seperated by colons, the exact parameter differ on the type of event, everything but the first parameter is diff --git a/src/evdev_helper.cpp b/src/evdev_helper.cpp index 6240f7f..b569a55 100644 --- a/src/evdev_helper.cpp +++ b/src/evdev_helper.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -683,6 +684,12 @@ bool str2event(const std::string& name, int& type, int& code) code = xkeysym2keycode(name); return true; } + else if (name.compare(0, 2, "JS") == 0) + { + type = EV_KEY; + code = BTN_JOYSTICK + boost::lexical_cast(name.substr(3)); + return true; + } else if (name.compare(0, 3, "KEY") == 0 || name.compare(0, 3, "BTN") == 0) {