We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5387

Summary: USB Playstation controller adapter partially broken starting 2.0.6 - 2.0.8+
Product: SDL Reporter: Nate F <ncflaggg>
Component: joystickAssignee: Sam Lantinga <slouken>
Status: RESOLVED INVALID QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: ARM   
OS: Linux   

Description Nate F 2020-12-10 00:42:19 UTC
Prettier version here: https://discourse.libsdl.org/t/playstation-controller-adapter-partially-broken-between-sdl-2-0-6-2-0-8/28426


In my Raspberry Pi 3 setup, all (buttons and thumbsticks) work correctly in:
 Retropie 4.3
 recalbox v4.0.0-beta5

X, O and Square buttons do not register button presses in:
 Retropie 4.4+
 recalbox 6.1.1+ (and probably older versions)

This is the adapter I’m using:
-=============================
Mcbazel PlayStation 2 Controller to USB Adapter for PC or Playstation 3 Converter Cable for Sony DualShock PS2 PS3 Controllers (NOT compatible with Dancing Mat Guitar Hero)

When working properly, the USB adapter shows up as:
 Joystick Name: 'Sony PLAYSTATION(R)3 Controller'
 Joystick GUID: 030000004c0500006802000011010000

Where broken, the sdl2-jstest output shows only 13 (0-12) button codes; the GUID also changes slightly (more below).

recalbox 6.1.1 output:
-=============================
sdl2-jstest -l
Found 1 joystick(s)

Joystick Name: ‘Sony PLAYSTATION®3 Controller’
Joystick Path: ‘/dev/input/event1’
Joystick GUID: 030000004c0500006802000011810000
Joystick Number: 0
Number of Axes: 6
Number of Buttons: 13
Number of Hats: 0
Number of Balls: 0
GameController:
Name: ‘PS3 Controller’
Mapping: ‘030000004c0500006802000011810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,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,’
Axis code 0: 0
Axis code 1: 1
Axis code 2: 2
Axis code 3: 3
Axis code 4: 4
Axis code 5: 5
Button code 0: 307
Button code 1: 310
Button code 2: 311
Button code 3: 312
Button code 4: 313
Button code 5: 314
Button code 6: 315
Button code 7: 317
Button code 8: 318
Button code 9: 544
Button code 10: 545
Button code 11: 546
Button code 12: 547

And when I run “sdl2-jstest -t 0”, the three mentioned buttons do not show any input when pressed, but if I press another button like the right trigger, I see this message:

“INFO: The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL forums/mailing list https://discourse.libsdl.org/ EVDEV KeyCode 313”

However, in recalbox 7.1.0, I do not see the “not recognized” message, yet the three buttons still do nothing.

Compare to working recalbox v4 output:
-=============================

sdl2-jstest -l
Found 1 joystick(s)

Joystick Name: ‘Sony PLAYSTATION®3 Controller’
Joystick Path: ‘/dev/input/event0’
Joystick GUID: 030000004c0500006802000011010000
Joystick Number: 0
Number of Axes: 4
Number of Buttons: 19
Number of Hats: 0
Number of Balls: 0
GameController:
Name: ‘PS3 Controller’
Mapping: ‘030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,’
Axis code 0: 0
Axis code 1: 1
Axis code 2: 2
Axis code 3: 5
Button code 0: 288
Button code 1: 289
Button code 2: 290
Button code 3: 291
Button code 4: 292
Button code 5: 293
Button code 6: 294
Button code 7: 295
Button code 8: 296
Button code 9: 297
Button code 10: 298
Button code 11: 299
Button code 12: 300
Button code 13: 301
Button code 14: 302
Button code 15: 303
Button code 16: 704
Button code 17: 705
Button code 18: 706

Both the number of axes and buttons in the above two outputs differ. I also don’t understand why any PS[1,2,3] (even non dual shock) gamepad would ever report less than 14 total buttons.

SDL2 inferred version info (can’t figure out how to list the SDL2 versions explicitly):
-==================================
Broken in Retropie 4.4. From the release notes:
Version 4.4: (April 14, 2018)
 SDL2 - updated to 2.0.8

Version 4.3
 (No SDL changes mentioned but at least 2.0.5, inferred from the 4.2 notes below)

Version 4.2: (March 19, 2017)
 SDL2 updated to 2.0.5.
 -Our patched SDL2 is now used on the PC version of RetroPie, which should resolve an issue with ps3 controller mapping.

Recalbox 4.0.0 beta 5:
(Used SDL2 2.0.3 or lower, inferred from the 4.1.0 notes below)
 [4.1.0] - 2017-10-13 (Closest match I can find in release notes)
 -bumped SDL to 2.0.4

I can see the Mapping GUIDs are different (off by one digit) as well as the button order, but I don’t know how that works:
-==================================
Working GUID (…1181…):
 Mapping: ‘030000004c0500006802000011810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,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,’

Broken GUID (…1101…):
 Mapping: ‘030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,’

I’m willing to do more testing to help figure out how to fix.
Comment 1 Nate F 2020-12-19 05:16:17 UTC
It looks like this is a Sony driver issue. Sometime around the 4.10 Linux kernel, the hid-sony.ko driver was updated and broke some USB Playstation adapters. Kernel v5.6.17 and up appear to fix it.

Relevant links:
 Discussion and workarounds - https://www.linuxquestions.org/questions/linux-games-33/playstation2-controller-with-usb-adapter-need-help-getting-additional-buttons-to-work-4175643583/
 Linux kernel fix - https://elixir.bootlin.com/linux/v5.6.17/source/drivers/hid/hid-sony.c
 batocera workaround - https://web.archive.org/web/20201031192507if_/https://forum.batocera.org/d/3796-tuto-make-your-ps2-controller-works-completely-with-a-cheap-usb-adaptor
 The guy who fixed it - https://lkml.org/lkml/2020/5/13/1323