A much-requested feature has finally been added to Android Pie: controller mapping for the Sony PlayStation 4’s DualShock 4. The PlayStation 4 is the most popular current-generation game console on the market, so it’s no surprise there’s a lot of people out there with DualShock 4 controllers who want to use them to play mobile games on Android. The problem with using your PlayStation 4 controller on Android is that the key mapping may not be available on your device. Thus, while you can connect to your PlayStation 4 controller via Bluetooth, you might not be able to actually use the controller to navigate the UI or play any games. Sony Xperia devices can use DualShock 4 controllers out of the box, but support on other devices depends on the device maker. Fortunately, Google has finally added the proper key mapping in AOSP so all Android 9 Pie devices should be able to use PlayStation 4 controllers.
PlayStation 4 controller support in Android Pie
Although your Android smartphone can wirelessly connect to your DualShock 4 controller via Bluetooth, your smartphone needs a key layout file that lets Android know how to translate button presses on the controller into standard key events in Android. Developers can then listen for these key events in their apps to determine what action to take in their app. For instance, if a user presses the “X” key, then a shooting game can interpret that to perform a fire action or a mobile platformer could respond with a jump action. Without the key layout file telling Android how to translate button presses, apps won’t know what button the user is pressing.
If you have root access, you can manually add the key layout file that Sony includes on their Xperia devices. You can even setup Remote Play if you really want. If you don’t have root, however, you have to hope that the device maker cared enough to add support for the DualShock 4 controller. With Android Pie, you no longer have to worry about that as the key mapping file will be included by default on all Android Pie devices. Sony engineers have been working to get DualShock 4 key layout support into AOSP as early as April of 2017, but those commits are no longer necessary since Google included support in their internal master branch before pushing the code to AOSP. Thanks to this change, Android now supports both the wireless DualShock 4 controller as well as the wireless Xbox One S controller.