Setting up a Bluetooth Controller for Linux Gaming (Part 2: Wine & Steam Play)
Recently I solved an issue for setting up my Wireless (via Bluetooth) controller on Steam for Linux (distr. Ubuntu 18.10), and decided to elaborate my experience a little better, and share my results and observations with you all.
In my previous article on the same topic, I dealt with the basic setup of the driver and the application for games which run natively on Linux. In the following sections I have considered instead the cases of games running with Wine or Proton (via Steam Play).
The relevant steps mentioned in the previous article are the ones that enabled us to launch the xboxdrv with the following command:
$ xboxdrv --evdev "/dev/input/event-asus-gamepad" --config xboxdrv.config
And that consequently enabled us to launch the Steam environment with a similar script:
#!/bin/sh if [ -h /dev/input/event-asus-gamepad ] then # remove any previous instance: killall -KILL xboxdrv # start the new driver in userspace mode: xboxdrv --evdev "/dev/input/event-asus-gamepad" \ --config xboxdrv.config & fi /usr/bin/steam %U
The configuration steps might vary according to the specific input API used in the game implementation.
Games running on Wine/Proton with DirectInput support
Most of the games issued until 2015 used to have support for the DirectInput API, which used to be the first Microsoft API (available in the DirectX library package) to process data from a joystick, or other game controller. Additional information on the API are available in the official Microsoft API documentation.
Few games such as Dark Souls (the original release and the Prepare to Die edition, but not the Remastered), Dark Souls II (both the original and Scholar of the First Sin releases), One Piece Pirate Warriors 3 and several else I tried are actually still using this API.
Before setting up the DirectInput controller configuration, make sure to turn the controller on and launch the xboxdriver as shown in the section above, with the following statement:
$ xboxdrv --evdev "/dev/input/event-asus-gamepad" --config xboxdrv.config
Then, in order to access to the driver setup, you have to run the following command:
Please keep in mind that in case of use of Steam Play (Proton) the WINEPREFIX is usually the following:
$ export WINEPREFIX=~/.steam/steam/steamapps/compatdata/$/pfx
and the wine executable to use is under the following path:
~/.steam/steam/steamapps/common/Proton\ $/dist/bin/
- $ is the Unique App ID of the specific game in the Steam Store (i.e. 211420 for Dark Souls: Prepare to Die, 335300 for Dark Souls II: Scholar of the First Sin, etc.);
- $ is the version of Proton that Steam Play uses specifically for that game, available with the following statement:
$ cat .steam/steam/steamapps/compatdata/$/version
I.e., for «Dark Souls II: Scholar of the First Sin», the wine control statement above would look like this:
$ WINEPREFIX=~/.steam/steam/steamapps/compatdata/335300/pfx/ ~/.steam/steam/steamapps/common/Proton\ 3.16/dist/bin/wine control
Once you launch the wine control statement, select the Game Controllers app from the newly opened window:
In the list, select the entry corresponding to the hardware controller (in my case «ASUS Gamepad») and press Disable, as show in the picture here below:
Press then OK and close the wine control application. This will make sure that DirectInput will get the Input just from the virtual controller defined via the xboxdrv driver.
Open them Steam and run the game to try the applied settings.
Alternatively to the guided procedure above, more skilled users might perform the same activity via the Registry Keys defined for that specific Wine Prefix. All the documentation is available at this link.
Games running on Wine/Proton with Xinput support
Most recent games (such as The Witcher 3: Wild Hunt, Dark Souls Remastered, Dark Souls 3 and generally all the games running just for the Windows 64bit architecture) use the Microsoft Xinput API. Additional information for this API are available in the official Microsoft documentation.
If the Xbox Controller Support has been correctly configured in Steam (as shown in the picture here below), there is nothing else you need to do. The in-game Xinput API will recognise the controller automatically as soon as you press any button or move any axis.
Conclusions
The observations I have collected in these two articles have just the purpose to share my favourite procedure and setup for using the same controller (and keeping the same configuration) in several cases.
I find this procedure particularly useful either if I am looking for a casual gaming day (where I swap between several games in my Steam library) or when I decide to focus for just one of them for the whole day.
The two main reasons I decided to migrate (100% successfully) to a Bluetooth controller are of course the following:
But of course feel free to add your own comments and observations about the topic. I’ll be pretty glad to answer and discuss about the topic.
How to Use Xbox 360 Wireless Gaming Controller?
Im Curious about the usage of the controller to play any games, like. does it even work in linux?,if so do i need a driver of some sorts?
4 Answers 4
I’m using the Microsoft Xbox 360 Wireless (Gaming) Receiver for Windows in Ubuntu Linux together with multiple “Microsoft Xbox 360 Wireless Controller” gamepads for single or multiplayer games with up to 4 controllers simulatiously.
This solution took me some time to figure out and it might be not the final solution to issues with gamepads in Linux, but these controllers are some of the most supported gamespads in the Linux world and a standard in PC gaming for game developers since their introduction in 2005 until today. This solution works for Xbox and Xbox One Controllers too.
As drivers, I’ve used xboxdrv and xpad before on my notebook (from Ubuntu LTS-Versions 12.04 until 18.04), but xboxdrv failed to be fully recognised with some games on my new PC with a fresh Kubuntu 18.04 LTS installed, because xboxdrv it is unmaintained now (since about 2 years). The last Ubuntu LTS it was working perfectly for me was 14.04, just with installing the PPA.
Just after installing Kubuntu 18.04 LTS (or Ubuntu 18.04 LTS for that matter), I’ve first tried to use my Xbox360 Wireless Controller gamepads and it worked out of the box with the default kernel driver version of xpad, but only in some games, where the analog bumpers (LB and RB) where not needed. Problems arrived in Steam and Steam Play, for native Linux games as well as Windows games though Steam Play (Valve’s Wine adaption inside steam). Valkyria Chronicles played well, in Grand Theft Auto V only the camera worked (unplayable) and in Project Cars 2 I was able to assign the basic controls to buttons that worked, but it was almost unplayable.
I tried every solution with xboxdrv then, that I could find on the net, but it’s just too old now. Valve contributed a lot to linux gaming since then. All buttons worked with xboxdrv, but the configuration mixed up the axis of the right stick and the right bumper and I couldn’t figure out how to solve it.
So here is the solution using xpad that made all the magic happen just by installing it. All the gamepads worked perfectly as it should have been with all the games I tried.
Install the Linux Kernel Driver for the Xbox/ Xbox 360/ Xbox One Controllers
Follow the installation instructions there. By the time of writing it goes like this:
Open Terminal
- Install git and dkms if you haven’t got it by entering:
sudo apt-get install git dkms
sudo git clone https://github.com/paroj/xpad.git /usr/src/xpad-0.4
sudo dkms install -m xpad -v 0.4
Install this PPA with joystickwake to help with Screensavers
Unless a game takes special steps, you also will need a joystick-aware screen waker until the display servers catch up. Joystickwake helps linux gamers who are tired of their screen saver interrupting their fun. The source code and documentation are on github: https://github.com/foresto/joystickwake
sudo add-apt-repository ppa:foresto/toys