Ubuntu – How to emulate XInput device with DirectInput gamepad

gamepadgamesinput-devices

I'm trying to get a Logitech Dual Action controller to work with Bastion, on Ubuntu 13.04. From what I've gathered, Bastion is only compatible with XInput devices, and my controller only supports DirectInput. In fact, the game will recognize most of the buttons except for button 7 (left trigger) and button 10 (the 'start' button on a console gamepad).

Is it possible to somehow emulate an XInput device, like the xbox 360 controller?

Best Answer

Answered here by Reddit user theliphantGen:

As I spent quite some time to figure it out I just wanted to note this somewhere.

Long story short - I couldn't make Brutal Legend or Shank to recognize any of my gamepads. Today I found out that xboxdrv can work on top of ANY joystick/gamepad using evdev. So with this simple mapping I have xboxdrv create another gamepad which mimics xbox360 controller using xpad driver and works out-of-the-box in both Shank and Brutal Legend (and should with others too):

xboxdrv --evdev /dev/input/event15 --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_RZ=x2,ABS_Z=y2,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y --axismap -Y1=Y1,-Y2=Y2 --evdev-keymap BTN_TOP=x,BTN_TRIGGER=y,BTN_THUMB2=a,BTN_THUMB=b,BTN_BASE3=back,BTN_BASE4=start,BTN_BASE=lb,BTN_BASE2=rb,BTN_TOP2=lt,BTN_PINKIE=rt,BTN_BASE5=tl,BTN_BASE6=tr --mimic-xpad --silent

/dev/input/event15 should point to correct event device of your gamepad. This is the mapping for PS2 controller adapter. You can adjust it by removing --silent and adding --evdev-debug to output evdev codes for pressed buttons/axes

Related Question