I’m having trouble with getting the motion controls from the Dualsense controller I have plugged into my computer.
To try isolating whatever is going wrong, I made a simple test program:
// Starting up the program
SDL_Init(SDL_INIT_GAMECONTROLLER|SDL_INIT_SENSOR);
SDL_JoystickEventState(SDL_ENABLE);
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1");
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5, "1");
// Initializing the controller
SDL_GameController* gc = SDL_GameControllerOpen(0);
SDL_GameControllerSetSensorEnabled(gc, SDL_SENSOR_ACCEL, SDL_TRUE);
SDL_GameControllerSetSensorEnabled(gc, SDL_SENSOR_GYRO, SDL_TRUE);
// Polling the controller
if(SDL_GameControllerHasSensor(gc, SDL_SENSOR_GYRO))
{
cout << SDL_GameControllerName(gc) << " has a gyroscope." << endl;
}
else
{
cout << SDL_GameControllerName(gc) << " does not have a gyroscope." << endl;
}
Now I know this PlayStation 5 controller has a gyroscope in it, but I don’t know SDL all that well. What am I not doing to properly set up the HID and its sensors? The output, Sony Interactive Entertainment Wireless Controller does not have a gyroscope., tells me I’m at least accessing the device in a coherent manner.
At least, SDL2 finds the sensors of my PS4 controller with this code. What OS and what version of SDL2 are you using right now? I had problems finding the sensors on linux using older versions of SDL2 for example.
UPDATE #1: I compiled v2.0.21 and installed it. Now the program says PS5 Controller does not have a gyroscope., which is at least more specific than my last attempt.
Hi, I just got my hands on a PS5 controller and figured out that gyro does not work, because there is (at least in ubuntu 20.04) no udev rule for the controller in the steam-devices package (which usually covers most controllers). You are using kubuntu, so this might be the problem.
Add this file to /etc/udev/rules.d:
# /etc/udev/rules.d/60-ps5.rules
# PS5 DualSense controller over USB hidraw
KERNEL=="hidraw*", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0ce6", MODE="0660", TAG+="uaccess"
# PS5 DualSense controller over bluetooth hidraw
KERNEL=="hidraw*", KERNELS=="*054C:0CE6*", MODE="0660", TAG+="uaccess"
Reload the rules:
sudo udevadm control --reload-rules && sudo udevadm trigger
then reconnect the controller. Gyro and accel should work now.