Hi everyone,
I am encountering problems with the new input system. I am trying to set the color of the light bar of my Dualshock controller with the following code:
foreach (Gamepad pad in Gamepad.all) {
if (pad is DualShockGamepad dualshock) {
dualshock.SetLightBarColor(Color.magenta);
}
}
This throws an InvalidCastException
. Debugging the code, it becomes obvious that pad is always of type Gamepad
. It should rather be a Dualshock4GamepadHID
or a DualSenseGamepadHID
(I tried both). I noticed that I have two gamepads when Steam is open of which one is a Steam virtual controller, hence the loop in the code for testing.
I checked the input debug window and from the description of the gamepads I can tell it’s my Dualshock that’s connected. I noticed that the interface is SDL
. I don’t know what that is but I suspect it’s not “A DualShock 4 controller connected to a desktop computer using the HID interface” as per the Input System documentation. Unfortunately, the documentation doesn’t explain interfaces so I have no idea what to do.
a) Why is my controller connected via SDL, and what is that?
b) How can I use the specific functionality of my gamepad in this case?
This was reproduced on Linux using Unity 2021.3.39f1 plus InputSystem 1.7 and 1.11 and Unity 2022.3.51f1 with InputSystem 1.11.2.