Dual Shock 4: A Good Choice on Linux ?

By

Very recently I was shopping for a new controller. Probably because I have an odd use case. I travel often for work these days, and while I can game a little bit on my laptop, for some games the keyboard and mouse combo do not cut it. So, I went to look out in Tokyo in the nearest HUGE shop for controllers on the video games floor. Note that in Japan, the PC section is clearly separated from the video games one. Consoles get a floor on their own, usually high in the building among with the hobby category of products, while the PC is usually underground, in the basement, displayed in a boring and almost secret way. Most people never go there. I decided to look among the consoles first, because I knew that it is where i would find the most abundant choice of accessories such as controllers.

For most Linux gamers, the obvious choice is a Xbox 360 wireless pad. It’s a very solid option. But I wanted something a little smaller for travelling, and first a mini controller FC30 PRO from 8bit Do. I had heard good things about it. It’s wired and wireless as well using bluetooth, and it seems to feature some decent controls. But the price… ouch. For some reason it is price more than 7000 JPY here, and at this price point your mind starts to wander and consider other options. Like, you know, why not getting a real gamepad for the same price or even slightly cheaper ?

While I really like the Xbox360 pad, it has two problems for when I am on the go:

  • It’s a little on the bulky side.
  • It needs a separate USB dongle to work.

I have even considered the Xbox One gamepad for a second, but it seems like it is not properly supported yet (or at least, I was not sure it was worth the risk…).

ps4_vs_xbox_one-small

That left me with the Dual Shock 4 from Sony. That shop had some samples for a quick hands-on experience. And as much as I like the Xbox One controller, I have to admit Sony did a really good job with the Dual Shock 4 as well. It feels way better that the Dual Shock 3 in almost every way. The D-pad is really good and while I don’t remember how the XBox One Dpad feels, the DS4’s Dpad is much better than the one from the Xbox 360 pad for sure. The nubs are great, too - more subtle and more sensitive than the ones used in the DS3 - and require some time for adaptation if you are too used to the DS3 feel, by the way. On top of that, the R2/L2 buttons are now properly designed to be used effectively in shooters - and much closer to the Xbox design in that sense, as you can see below. The back of the pad also features a different plastic texture, making it much easier to grip and keep in hands. A really thoughtful addition.

dualShock-side

And more importantly, the DS4 fits two other criteria that were relevant for the use case:

  • Not too bulky and relatively light to carry
  • Does not need a separate adapter/dongle to work. As long as you have a bluetooth receiver integrated. Most laptops have Wifi-Bluetooth combo chips these days, so it should not be an issue as long as your hardware works properly with Linux.

Of course, what matters most in the end is… does the DS4 work properly on Linux ? Well, yes and no. It’s not as straightforward as you might believe.

From a bluetooth standpoint, it was recognized immediately on my Linux Mint 17.2 install. I just had to hold the PS button and the Share button at the same time for 5 seconds and it would go into pairing mode. You know it’s paired when the big LED window lights up at the back of the pad.

ds4-LED

Then, Steam. Steam is great, it recognizes directly that your DS4 is connected, and maps it accordingly. If you hold the PS button for a couple of seconds, it makes the Steam Client jump directly in Big Picture Mode. Nice!

Next, I tried Broforce, and lo and behold, the gamepad was properly recognized and I could play the game just as expected. At this point, I thought the experiment was successful and my test was over. I was wrong. Testing other controller-supported games led to the harsh conclusion that most of the other games do not recognize the DS4 at all. There is a workaround for some of those games. If you decide to get rid of the bluetooth connection, and instead go for a micro-USB to USB connection (hence, wired), more games seem to work, but then you lose the appeal of the wireless itself. Needless to say, I was not super satisfied with this solution - especially when I realized there were still some titles for which this solution was not working either. Some games actually REQUIRE an XBox360 controller. Yup.

The real solution is DS4DRV. This little tool, which source is available on Github, acts as a separate driver for the Dual Shock 4 and enables additional modes, such as Xpad emulation. Xpad is the protocol used by the Xbox360 driver (depreciated by the Xbox One controller, unfortunately), used by most games providing controller support on Linux. With this Xpad emulation, you can now make the OS believe it is dealing with a Xbox 360 gamepad, solving all the compatibility issues we have mentioned above. And this works even in wireless mode.

DS4DRV can do many other things, such as:

  • Changing the back LED color to your liking (using a typical color code such as #FF0000 for Red, for example - blue would be #0000FF, and so on…). This is awesome if you like specific colors and customization.
  • Enabling you to cycle through different emulation modes. You can switch between the Xpad and the regular DS4 mode with a button combination.
  • Emulating a mouse with the DS4 trackpad. Don’t expect it to behave as well as a real trackpad (it does not, and there’s lag), but for very light use in case you don’t have a mouse plugged in, it may be useful once in a while. Let me stress this again: this is nowhere like what the Steam Controller offers. But it’s nice to have.

Here’s my controller in bright red glow, using the Xpad mode:

ds4red-small

Installing and running Ds4dv was a breeze, but there are a couple of things to keep in mind - here’s how you should probably proceed if you go down this way:

  • Install DS4DRV on your distro. This should work probably everywhere since it relies on Python :
 sudo pip install ds4drv
  • Grab this file and save it as it in your Downloads folder as:
50-ds4drv.rules
  • Copy that file to /etc/udev/rules.d/ with the following command, assuming you saved the previous file in ~/Downloads :
suco cp ~/Downloads/50-ds4drv.rules /etc/udev/rules.d/
  • Once this is done you need to reload the permissions:
sudo udevadm control --reload-rules
sudo udevadm trigger
  • You should then save the configuration file (you can grab mine here) in the .config folder in your home folder (~/.config/), using the following file name:
ds4drv.conf
  • Start the driver by typing in a terminal:
ds4drv
  • Pair your controller by keeping the PS button and the Share Button pressed for something like 5 seconds. When pairing starts the LED should flicker in quick white lights until pairing is complete. Once paired, the LED should look blue by default.
  • Switch your controller to Xpad mode to avoid most issues. With my config file settings you can do this by pressing PS + R1 + L1 at the same time - Press once or twice until the LED light at the front of the gamepad turns red.
  • You are good to go !

Note that in Xpad mode, the gamepad should work perfectly in wireless mode with Steam (all the games I tested had no issue with it) as well as Kodi, and probably most of the other software (emulators and so on). In default mode (i.e. non-red LED light), note that Kodi will crash (this is a known bug), so make sure you use Xpad mode if you use Kodi in its latest incarnation.

I hope this was helpful for all of you who were considering a DS4 controller along with your Linux Gaming system. Note that while I was preparing this post, ProfessorKaos64 has released a Ds4drv package for SteamOS, so it should be possible to follow the same guide on SteamOS too after installing the same package.

Have fun!