-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emulate Xbox 360 gamepad #21
Comments
This is getting into SC-Controller type stuff, but that project has gotten big and super hairy, and outdated ( not ported to Python 3 yet ). |
Unfortunately there is no tool out there to fill the gap. They are either unmaintained or dependent upon older technologies. |
Yeah, I'd like something 'simple' and then expand it further as needed. The core right now is simple. We could then add a module to support 'gamepads', and another to support mapping tablets. And finally a UI to help with mapping ( though nothing so fancy as showing a controller at first, more like "Press a button, how do you want it mapped?" ) |
Minimalism in computing to me is paramount. Despite the long report, implementing those features should be pretty straightforward. |
Button mapping of most modern video games default to the Xbox 360 gamepad. There are several tools to remap my PlayStation 2 controller to a virtual Xbox 360 gamepad, the most popular being Xboxdrv. Unfortunately it seems these tools are not maintained anymore. Your application would gracely fill the gap if not for some missing feature:
The new "range" parameter would automagically be used to convert an EV_KEY event to a EV_ABS one as well. This is needed because the Xbox 360 gamepad has some pressure-sensitive buttons with 8 bit precision that need to be mapped from the ordinary buttons on the PlayStation 2 gamepad, thus the EV_KEY event with value 1 (button pressed) would be translated to an EV_ABS event with value 255 (button fully pressed). Releasing the button would report an EV_ABS value to 0 again ("range: [255, 0]").
I think that the proposed enhancement should be very easy and elegant to implement. I would have done it myself but since I don't speak Python I find the code very hard to understand. With the proposed implementation the configuration file would look something like this:
devices:
output_name: Microsoft X-Box 360 pad
remappings:
BTN_THUMB2:
code: BTN_SOUTH
BTN_TOP:
code: BTN_NORTH
BTN_TRIGGER:
code: BTN_WEST
BTN_THUMB:
code: BTN_EAST
BTN_BASE4:
code: BTN_START
BTN_BASE3:
code: BTN_SELECT
BTN_BASE2:
code: BTN_TR
BTN_BASE:
code: BTN_TL
BTN_PINKIE:
code: ABS_RZ
type: EV_ABS # non pressure-sensitive button translated to 8 bit pressure sensitive one
range: [255, 0] # 255 for button pressed and 0 for button released, nothing in-between in this case
BTN_TOP2:
code: ABS_Z
type: EV_ABS
range: [255, 0]
BTN_BASE5:
code: BTN_THUMBL
BTN_BASE6:
code: BTN_THUMBR
BTN_DEAD:
code: ABS_HAT0X # ABS_HAT0X and ABS_HAT0Y needed for directional buttons not being delivered (bug?)
type: EV_ABS
range: [-1, 0] # -1 for button pressed and 0 for button released, nothing in-between in this case
+300: # event with no name preceded by + because it is a reserved character in C/C++ (feel free to think of something else to disambiguate from a C variable name)
code: ABS_HAT0Y
type: EV_ABS
range: [-1, 0]
+301:
code: ABS_HAT0X
type: EV_ABS
range: [1, 0]
+302:
code: ABS_HAT0Y
type: EV_ABS
range: [1, 0]
ABS_X: # no "code:" specified because we only need to reassign the range
range: [-32768, 32767] # EV_ABS being converted from 8 bit 0-255 range to 16 bit -32768-+32767 with values in-between
ABS_Y:
range: [-32768, 32767]
ABS_RZ:
code: ABS_RX
range: [-32768, 32767]
ABS_Z:
code: ABS_RY
range: [-32768, 32767]
The text was updated successfully, but these errors were encountered: