Sun 24 May 2015
2:27PM
compton

Xbox 360 Controller in Wine

The xpad kernel driver works pretty well for gamepads in Linux these days, with the wired Xbox 360 controller the recommended choice. This controller should work without need for configuration in most native Linux games.

When running Windows games under Wine, you are quite likely to find that the buttons and axes do not do what they're supposed to, or even don't function at all. This is because gamepad button mapping is different in Windows, Linux and even Mac. Don't worry though, it's not hard to fix this, by simply remapping the buttons to the correct inputs and then Wine games will recognise it properly and assign the right actions to the correct buttons.

xboxdrv is one way to do this. It's a pretty powerful program but is also quite a hassle to configure. The big advantage it offers is that it allows you to map gamepad (or joystick or steering wheel) buttons to keyboard presses, enabling you to use a gamepad in games that don't offer built-in support.

x360ce

If all you need to do is to fix the button mapping for Wine games, the simplest solution I've found is x360ce (the "Xbox 360 Controller Emulator"). This Windows program is designed to allow you to remap the buttons and axes on some other gamepad, such as a PlayStation controller, to match those of an Xbox 360 controller. Luckily for us, it works perfectly in Wine as a way to fix the mixed-up mappings of the Xbox controller itself.

You can try running x360ce.exe from the Zip available on the project's GitHub (see link above), but this needs particular .NET versions to run and the preset controller templates it offers probably don't offer much benefit for Wine users. You can instead get hold of just the necessary files here. To make this work for a particular game, you need to put the DLL and the INI file in the directory where your game's executable lives.

Rather than having multiple copies of these files in every game directory, I keep the files in a single directory in my home dir, and then just create symlinks to them for any game that needs them. Note that some games expect xinput1_3.dll to have a different name - Tomb Raider 2013 for instance needs it to be called xinput9_1_0.dll. Read the included Readme.txt for the list of all possible names.

The Wine team have done a lot of work recently on native support for joysticks, but it's not quite there yet (Wine 2.3 is the latest version at time of writing) and xboxdrv is still required for most games. However, you will need to add an override for xinput1_3 in winecfg so that it will use the Windows DLL:

/xkcd/ Pendulum Types