Issue №2445 opened by joereynolds at 2021-01-11 12:49:50
Before I submit a PR I just thought I'd check with you all on this.
When I connect a wireless PS4 controller to my Linux (Ubuntu 18.04) machine, it's name comes through as Sony Interactive Entertainment Wireless Controller (notPS4 Controller) and the control scheme is pretty much identical to the Xbox360 controller.
On windows it comes through as documented - PS4 Controller and the control scheme is as documented.
I'm happy to document the controller for Linux, has anyone else experienced this?
Could this be an issue on say MacOS as well? or even different versions of an OS?
Pygame 2
Playstation 4 Controller (name: "PS4 Controller")
But this isn't true on Linux as it comes through as "Sony Interactive Entertainment Wireless Controller". It's not a huge issue but thought it could do with being documented. If there's a more reliable way to get the kind of controller that is plugged in, then I would happily use that :+1:
I only have Xbox and Nintendo controllers (and an 8bitDo one that can be configured to act like either), but I know your problem well. There used to be a kernel driver (xpad) for the 360 controller, and a userspace driver (xboxdrv), and now there are also bluetooth gamepads with still another userspace driver.
SDL2 has code to re-map controllers to known configurations. If your OS/driver does not do the right thing, SDL2 can compensate. In addition to this, there are tools for players to re-map their controllers, and SDL2 will work with that.
You can even use this to get games built with SDL2 to work with gamepads that were released after the game was compiled!
Can you run gamepadtool with your gamepad in both configurations, and copy and paste both mapping strings here?
If SDL_GAMECONTROLLERCONFIG="YOUR_MAPPING_HERE" python3 your_game.py does the trick, we just need to file a PR upstream, or maybe your controller is already in the DB.
Here's the mapping string. I'm not sure what you mean by "both" configurations, I plugged in the controller and got this mapping string
Found 1 gamepad(s):
"PS4 Controller", 030000004c050000cc09000011810000 (mapping available)
Environment variable "SDL_GAMECONTROLLERCONFIG" is not defined
Checking if new mappings available from github: https://github.com/gabomdq/SDL_GameControllerDB
Mapping string for "PS4 Controller" is "030000004c050000cc09000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,"
Interestingly gamepadtool picks it up correctly as "PS4 Controller", it's only in the call to joystick.get_name() where it differs.
By "both" I meant wired and via bluetooth.
Is the GUID/mapping different when it is connected wirelessly? I would suspect it to be, as it uses different chips. An USB-ID is not the same as a bluetooth UUID or MAC address.
Okay my mistake. I have not connected it wirelessly but even wired the name is different on Linux (Sony Interactive Entertainment Wireless Controller) vs Windows(PS4 Controller). Is that not a problem in itself?
I haven't attempted to use it via bluetooth yet, I'll have to look into that when I get a chance.
Issue №2445 opened by joereynolds at 2021-01-11 12:49:50
Before I submit a PR I just thought I'd check with you all on this.
When I connect a wireless PS4 controller to my Linux (Ubuntu 18.04) machine, it's name comes through as
Sony Interactive Entertainment Wireless Controller
(notPS4 Controller
) and the control scheme is pretty much identical to the Xbox360 controller.On windows it comes through as documented -
PS4 Controller
and the control scheme is as documented.I'm happy to document the controller for Linux, has anyone else experienced this? Could this be an issue on say MacOS as well? or even different versions of an OS?
Here's the controller code I've made for working with PS4 controllers on Linux if you're wondering: https://github.com/joereynolds/Mr-Figs/blob/master/src/input_handlers/ps4_controller.py
Comments
*robertpfeiffer commented at 2021-01-11 16:00:31*
This is partly due to your OS and drivers.
What documentation are you referring to?
*joereynolds commented at 2021-01-11 16:38:36*
In the joystick docs it states:
But this isn't true on Linux as it comes through as "Sony Interactive Entertainment Wireless Controller". It's not a huge issue but thought it could do with being documented. If there's a more reliable way to get the kind of controller that is plugged in, then I would happily use that :+1:
*robertpfeiffer commented at 2021-01-11 17:56:11*
I only have Xbox and Nintendo controllers (and an 8bitDo one that can be configured to act like either), but I know your problem well. There used to be a kernel driver (xpad) for the 360 controller, and a userspace driver (xboxdrv), and now there are also bluetooth gamepads with still another userspace driver.
SDL2 has code to re-map controllers to known configurations. If your OS/driver does not do the right thing, SDL2 can compensate. In addition to this, there are tools for players to re-map their controllers, and SDL2 will work with that.
https://github.com/gabomdq/SDL_GameControllerDB https://www.generalarcade.com/gamepadtool/
You can even use this to get games built with SDL2 to work with gamepads that were released after the game was compiled!
Can you run gamepadtool with your gamepad in both configurations, and copy and paste both mapping strings here?
If
SDL_GAMECONTROLLERCONFIG="YOUR_MAPPING_HERE" python3 your_game.py
does the trick, we just need to file a PR upstream, or maybe your controller is already in the DB.*joereynolds commented at 2021-01-12 14:23:15*
Here's the mapping string. I'm not sure what you mean by "both" configurations, I plugged in the controller and got this mapping string
Interestingly gamepadtool picks it up correctly as "PS4 Controller", it's only in the call to
joystick.get_name()
where it differs.*robertpfeiffer commented at 2021-01-12 14:55:07*
By "both" I meant wired and via bluetooth. Is the GUID/mapping different when it is connected wirelessly? I would suspect it to be, as it uses different chips. An USB-ID is not the same as a bluetooth UUID or MAC address.
*joereynolds commented at 2021-01-18 09:49:04*
Okay my mistake. I have not connected it wirelessly but even wired the name is different on Linux (
Sony Interactive Entertainment Wireless Controller
) vs Windows(PS4 Controller
). Is that not a problem in itself?I haven't attempted to use it via bluetooth yet, I'll have to look into that when I get a chance.