OpenTK Identify PS4v2 Controller (via USB)

524 Views Asked by At

When I query the name of a PS4 v2 connected controller within my OpenTK application using OpenTK.Input.GamePad.GetName(i), I get "Unmapped Controller" and the axis and button values are all over the place. I want to make my application work with both Xbox 360/One as well as PS3/4 controllers, so I need a way to differentiate the two and apply a mapping whenever needed.

First of all I think that OpenTK lacks support for such controllers and this is why it reports it as an unmapped controller (I actually just checked the OpenTK source code and it seems that there is a specific mapping defined for PS4 controller and I am surprised why it doesn't work. Could it be because of the v2 version?). So I need a way of telling if the controller that I have connected is a PS4 controller in order to apply a custom mapping on it.

Is there any way to fetch the real device name of an OpenTK Gamepad instead of that generic "Unmapped Controller" title?

I'm using OpenTK 3.0.1.

1

There are 1 best solutions below

3
On

OpenTK is cross-platform, can you share which OS you're using it on? Much of the gamepad driver logic is platform-specific. If you're on a Linux-based OS, the kernel version is also relevant when it comes to gamepad compatibility issues.

It looks like OpenTK may be using SDL2 for gamepad input. If that's the case, you'll want to check which version of SDL2 it's using and possibly update the gamecontrollerdb.txt configuration file with new gamepad info:

https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt

Dualshock 4 gamepads are complicated and you will need several entries to correctly support all its versions and modes, particularly on Linux. Besides the V1/V2 differences, there was also an update to the hid-sony Linux driver that changed how the device is exposed to applications. SDL2 needs to be updated to work correctly with the new mapping.