This week marks the launch the twin-stick bullet hell shooter Assault Android Cactus, one of the highest profile Australian games right now. It's been a star ever since it debuted at AVCon and PAX Australia two years ago, and has continued to make waves at shows internationally.
One of the game's cooler features is it's native support for DualShock 4 controllers, something of a rarity (still) on PC. I spoke to Witch Beam's programmer and animator Tim Dawson about the challenge of implementing native DS4 support, and why more studios haven't done it.
"When the PlayStation 4 was released and the Dual Shock 4 came with native Windows support, it seemed like a natural fit to get [Assault Android] Cactus playable with it," Dawson told me. "There's always been ways to get other controllers to connect with Windows but because they often use third party drives and workarounds, I figured the onerous was on the user to set them up so they would work like an Xbox 360 pad, since that is the de facto PC controller but since you could plug a Dual Shock 4 into a PC and it would show up as a controller, I wanted that to 'just work'."
Problem is, it doesn't just work. While you can plug the DS4 into a PC with any USB to micro-USB cable and have it appear as a controller, it only shows up as a Direct Input device. Those don't map the same way as Xbox 360 controllers and given that most games only support XInput, the API for 360 and "next generation" controllers, DS4 pads are left out in the cold.
Assault Android Cactus and Witch Beam had another issue with native support too: the Unity engine itself. "For a Unity developer, the problem is the [DS4] will be readable just fine, but it's buttons and axis are all mismatched compared to a 360 controller."
"It ended up as a lot of tangled code that would try its best to detect when a Dual Shock 4 was being used, and read it differently, and hope for the best. At one point you could plug 4 DS4's in and play Cactus that way, or use 4 Xbox controllers, but not mix and match, and if you added an older Logitech controller into the mix, it was anyone's guess what would happen."
When the studio upgraded to Unity 5, Dawson's will to find a solution on his own eventually broke and he began searching out for middleware solutions. "The main thing is Unity doesn't give enough access to hardware to really sort out what's happening in meat space," he explained, adding that the upgrade to Unity 5 allowed developers to access the names of devices albeit with one significant caveat.
"You can access the names of devices but they won't necessarily correspond to the controller your accessing. They mostly will, but when it goes wrong, it goes really wrong -- users will suddenly have backwards controls and trigger will make them move forwards."
After much frustration, Dawson ended up settling on an input system called Rewired available on the Unity store. It's a framework that builds on Unity's basic out-of-the-box controller support and adds compatibility for hot swappable joysticks, over 20 buttons per controller and, importantly, the removal of having to track joystick IDs (resolving the issue Dawson mentioned earlier about accessing the names of devices).
I asked why more studios, whether they were using Unity or not, didn't implement native support for DS4 controllers. You'd think it would make sense, considering the PS4's popularity over the Xbox One. The Queenslander suggested it was probably out of pragmatism, and that the proliferation -- and support for the 360 controller -- fostered an expectation among developers that made it easier to shift the problem onto users.
"I think the main problem is that unless you have these devices sitting on your desk and are testing them regularly it's easy to forget they exist or know what they'll even do when plugged in," he told me.
"I suppose the issue is all on the PC side; identifying inputs accurately is a deceptively hard problem in modern engines like Unity, workarounds are imperfect, so you can be blamed by users for even trying, and it can feel like it's of dubious benefit, which makes it feel like a luxury. On Sony's side, they tried to keep things simple by making the Dual Shock 4 connect as a basic PC gamepad when connected to a computer, which is great, but the downside is that's all the computer sees it as, which rules out using the speaker, light, touch pad, tilt sensors or even the rumble, unless you're using your own drivers."
For those who want to use the other features of the DS4 on their PC, third-party drivers like DS4Windows are a godsend. They don't always work with newer versions of Windows, however; I had immense problems getting anything beyond basic support for Windows 8.1, although I've had no issues with DS4Windows (and other wrappers) on Windows 7 and Windows 10.
If you're interested in testing the efforts of Dawson's labour, you can try a demo of Assault Android Cactus on Steam now. The game is on sale for US$12 as part of a launch discount, which isn't a bad asking price for something with a 98% user rating from nearly 300 reviews.