SDL
SDL copied to clipboard
USB controller is connected but has no inputs
Following my discussion at https://discourse.libsdl.org/t/sdl-joysticknumbuttons-always-returns-0/40357/10 I have wired NES USB controller which upon receiving a SDL_JOYDEVICEADDED
event is returning:
SDL_JoystickName: USB Gamepad
SDL_JoystickGetAttached: TRUE
SDL_JoystickNumButtons: 0
SDL_JoystickNumHats: 0
SDL_JoystickNumAxes: 0
SDL_IsGameController: FALSE
I'm running macOS 13 on an M1 Pro and SDL 2.24.1. The controller works using emulators and gamepad-tool
shows it correct and gets button presses.
Are you able to debug SDL and see what's going on? If not, are you willing to send me your controller so I can debug it? :)
I have the same problem with 8BitDo Bluetooth game controllers in D-Input mode since macOS Ventura update. I just found out that Mac mode is also broken. Only X-Input mode and Switch mode are working on macOS Ventura.
Online gamepad testers are able to detect proper functions of both Mac mode and D-Input mode. Perhaps SDL2 is indeed broken. D-Input mode works fine for Linux and both D-Input and X-Input modes work fine for Windows. Both D-Input and Mac modes used to work on macOS Monterey.
The exact models are M30 and SN30 Pro. The OP wired NES USB controller is likely to be in D-Input mode.
I can test the 8BitDo controllers here. Thanks for the additional info!
I wasn't able to reproduce this with an 8BitDo Pro 2. I'll see if I can get the M30 and SN30 Pro to try them out.
Did you try Mac mode or D-Input mode on the Pro 2?
Yes, I tried DirectInput mode.
I'm experiencing the same issue with both an 8BitDo Pro 2 and a PS4 Controller connected to my M1 Mac macOS 13. The gamepad pointer is constructed fine and throws no errors. SDL will log the specific controller connected when queried ("PS4 Controller"). But no gamepad inputs are registered, either in the event loop or by querying the gamepad state manually.
Hmm, I just connected the 8BitDo over Bluetooth in DInput mode and didn't have any issues. Are there input monitoring permissions problems or something?
And I just tried a Bluetooth PS4 controller and it worked fine... ?
Are you able to debug SDL and see what's going on? If not, are you willing to send me your controller so I can debug it? :)
Debug in the SDL Xcode project? I have some experience using IOKit on Mac so maybe I could help. What's the best way to get started?
Yeah I would but I'm in Thailand until next July. Here's where I bought them: https://www.amazon.com/Controller-suily-Joystick-RetroPie-Emulators/dp/B07M7SYX11/ref=sr_1_1?crid=NGH1AOGF4CW9&keywords=suily+usb+nes+controller&qid=1669681823&sprefix=sui+usb+nes+controller%2Caps%2C390&sr=8-1 $13/USD for a pair if you're in the US.
A similar wired SNES controller failed also but strangely the wireless SNES controllers work.
Given a bunch of people are having trouble with controllers that are working for me, I think it makes sense for you guys to see if you can debug it on your end.
Given a bunch of people are having trouble with controllers that are working for me, I think it makes sense for you guys to see if you can debug it on your end.
are you testing wired controllers because my wireless ones worked. Also macOS 13 is probably the other important part if you haven't upgraded yet.
@slouken What's the best way to debug SDL? Can I make a debug build framework so I can at least set breakpoints? I use SDL with Pascal and VSCode/LLDB as my debugger but maybe there's a test app or something I could use from within Xcode?
are you testing wired controllers because my wireless ones worked. Also macOS 13 is probably the other important part if you haven't upgraded yet.
Yep, I just upgraded to macOS Ventura, and have tried those controllers wired and wireless.
@slouken What's the best way to debug SDL? Can I make a debug build framework so I can at least set breakpoints? I use SDL with Pascal and VSCode/LLDB as my debugger but maybe there's a test app or something I could use from within Xcode?
Try opening Xcode/SDLTest/SDLTest.xcodeproj and running the testgamecontroller target?
@slouken Just a dumb question, is your Mac also an M1 and not Intel? I am sorry that I don't have an Intel Mac to check and I can't go back to macOS Monterey.
D-Input mode - testjoystick.c
Same problem as OP.
2022-11-28 20:21:59.272 joytest[58640:806780] INFO: Joystick device 0 added.
2022-11-28 20:21:59.272 joytest[58640:806780] INFO: Joystick
2022-11-28 20:21:59.272 joytest[58640:806780] INFO: name: 8BitDo M30 gamepad
2022-11-28 20:21:59.272 joytest[58640:806780] INFO: type: Game Controller
2022-11-28 20:21:59.272 joytest[58640:806780] INFO: LED: no
2022-11-28 20:21:59.272 joytest[58640:806780] INFO: rumble: no
2022-11-28 20:21:59.272 joytest[58640:806780] INFO: trigger rumble: no
2022-11-28 20:21:59.272 joytest[58640:806780] INFO: axes: 0
2022-11-28 20:21:59.272 joytest[58640:806780] INFO: balls: 0
2022-11-28 20:21:59.272 joytest[58640:806780] INFO: hats: 0
2022-11-28 20:21:59.272 joytest[58640:806780] INFO: buttons: 0
2022-11-28 20:21:59.272 joytest[58640:806780] INFO: instance id: 0
2022-11-28 20:21:59.272 joytest[58640:806780] INFO: guid: <removed>
2022-11-28 20:21:59.273 joytest[58640:806780] INFO: VID/PID: 0x0000/0x0000
Mac mode - testjoystick.c
Joystick found, but no input events coming in.
2022-11-28 20:34:50.431 joytest[58742:810649] INFO: Joystick device 0 added.
2022-11-28 20:34:50.431 joytest[58742:810649] INFO: Joystick
2022-11-28 20:34:50.431 joytest[58742:810649] INFO: name: PS4 Controller
2022-11-28 20:34:50.431 joytest[58742:810649] INFO: type: Game Controller
2022-11-28 20:34:50.431 joytest[58742:810649] INFO: LED: no
2022-11-28 20:34:50.431 joytest[58742:810649] INFO: rumble: no
2022-11-28 20:34:50.431 joytest[58742:810649] INFO: trigger rumble: no
2022-11-28 20:34:50.431 joytest[58742:810649] INFO: axes: 6
2022-11-28 20:34:50.431 joytest[58742:810649] INFO: balls: 0
2022-11-28 20:34:50.431 joytest[58742:810649] INFO: hats: 0
2022-11-28 20:34:50.431 joytest[58742:810649] INFO: buttons: 16
2022-11-28 20:34:50.431 joytest[58742:810649] INFO: instance id: 0
2022-11-28 20:34:50.431 joytest[58742:810649] INFO: guid: <removed>
2022-11-28 20:34:50.431 joytest[58742:810649] INFO: VID/PID: 0x054c/0x05c4
testgamecontroller.c
failed with 0 attached gamecontroller(s) in D-Input mode. In Mac mode, it found the same PS4 Controller
but no input events ever showed up.
Yes, I'm testing on an M1 mac. Can you provide the GUID? There is no system identifiable information in there, but it will tell us what SDL driver is being used.
D-input mode guid: 05009b4238426974446f204d00002000
Mac mode guid: 03008fe54c050000c405000000016800
The 2 following modes all from the same 8BitDo M30 work fine on macOS Ventura.
Switch mode
2022-11-28 21:35:11.955 joytest[59241:830291] INFO: Joystick device 0 added.
2022-11-28 21:35:12.138 joytest[59241:830291] INFO: Joystick
2022-11-28 21:35:12.138 joytest[59241:830291] INFO: name: Nintendo Switch Pro Controller
2022-11-28 21:35:12.138 joytest[59241:830291] INFO: type: Game Controller
2022-11-28 21:35:12.138 joytest[59241:830291] INFO: LED: no
2022-11-28 21:35:12.138 joytest[59241:830291] INFO: rumble: yes
2022-11-28 21:35:12.138 joytest[59241:830291] INFO: trigger rumble: no
2022-11-28 21:35:12.138 joytest[59241:830291] INFO: axes: 6
2022-11-28 21:35:12.138 joytest[59241:830291] INFO: balls: 0
2022-11-28 21:35:12.138 joytest[59241:830291] INFO: hats: 0
2022-11-28 21:35:12.138 joytest[59241:830291] INFO: buttons: 20
2022-11-28 21:35:12.138 joytest[59241:830291] INFO: instance id: 0
2022-11-28 21:35:12.138 joytest[59241:830291] INFO: guid: 030056fb7e0500000920000001006803
2022-11-28 21:35:12.138 joytest[59241:830291] INFO: VID/PID: 0x057e/0x2009
X-Input mode
2022-11-28 21:36:55.908 joytest[59273:831315] INFO: Joystick device 0 added.
2022-11-28 21:36:55.908 joytest[59273:831315] INFO: Joystick
2022-11-28 21:36:55.908 joytest[59273:831315] INFO: name: Xbox One S Controller
2022-11-28 21:36:55.908 joytest[59273:831315] INFO: type: Game Controller
2022-11-28 21:36:55.908 joytest[59273:831315] INFO: LED: no
2022-11-28 21:36:55.908 joytest[59273:831315] INFO: rumble: yes
2022-11-28 21:36:55.908 joytest[59273:831315] INFO: trigger rumble: yes
2022-11-28 21:36:55.908 joytest[59273:831315] INFO: axes: 6
2022-11-28 21:36:55.908 joytest[59273:831315] INFO: balls: 0
2022-11-28 21:36:55.908 joytest[59273:831315] INFO: hats: 0
2022-11-28 21:36:55.908 joytest[59273:831315] INFO: buttons: 15
2022-11-28 21:36:55.908 joytest[59273:831315] INFO: instance id: 0
2022-11-28 21:36:55.908 joytest[59273:831315] INFO: guid: 030082795e040000e002000003096800
2022-11-28 21:36:55.908 joytest[59273:831315] INFO: VID/PID: 0x045e/0x02e0
@slouken What's the best way to debug SDL? Can I make a debug build framework so I can at least set breakpoints? I use SDL with Pascal and VSCode/LLDB as my debugger but maybe there's a test app or something I could use from within Xcode?
Try opening Xcode/SDLTest/SDLTest.xcodeproj and running the testgamecontroller target?
Ok I built the SDL 3 framework from the main project and it built to ~/Library/Developer/Xcode/DerivedData/SDL-goctvbcoxkiommfamjlgzlztoqef/Build/Products/Debug
. Now when I run the SDLTest project it says it can't find the SDL3 framework. I suspect it built to the wrong location. Any ideas?
@slouken I got the test project running now (I needed to build the framework from the test project) and I get the same results (see below).
So it's going to take some actual debugging to see what's wrong.
2022-12-01 08:17:30.465589+0700 testjoystick[31691:132128408] Metal GPU Frame Capture Enabled
2022-12-01 08:17:30.466034+0700 testjoystick[31691:132128408] Metal API Validation Enabled
2022-12-01 08:17:30.481642+0700 testjoystick[31691:132128408] fopen failed for data file: errno = 2 (No such file or directory)
2022-12-01 08:17:30.481680+0700 testjoystick[31691:132128408] Errors found! Invalidating cache...
2022-12-01 08:17:36.616086+0700 testjoystick[31691:132128408] INFO: Joystick device 0 added.
2022-12-01 08:19:15.201351+0700 testjoystick[31691:132128408] INFO: Joystick
2022-12-01 08:19:15.201542+0700 testjoystick[31691:132128408] INFO: name: USB Gamepad
2022-12-01 08:19:15.201583+0700 testjoystick[31691:132128408] INFO: type: Game Controller
2022-12-01 08:19:15.201632+0700 testjoystick[31691:132128408] INFO: LED: no
2022-12-01 08:19:15.201664+0700 testjoystick[31691:132128408] INFO: rumble: no
2022-12-01 08:19:15.201696+0700 testjoystick[31691:132128408] INFO: trigger rumble: no
2022-12-01 08:19:15.201744+0700 testjoystick[31691:132128408] INFO: axes: 0
2022-12-01 08:19:15.202223+0700 testjoystick[31691:132128408] INFO: balls: 0
2022-12-01 08:19:15.202256+0700 testjoystick[31691:132128408] INFO: hats: 0
2022-12-01 08:19:15.202285+0700 testjoystick[31691:132128408] INFO: buttons: 0
2022-12-01 08:19:15.202314+0700 testjoystick[31691:132128408] INFO: instance id: 0
2022-12-01 08:19:15.202342+0700 testjoystick[31691:132128408] INFO: guid: 0500e9f55553422047616d6500006400
2022-12-01 08:19:15.202374+0700 testjoystick[31691:132128408] INFO: VID/PID: 0x0000/0x0000
I believe this is fixed by https://github.com/libsdl-org/SDL/commit/5925cd4ef377a2211fd057ef6fa9f41141999cb7, can you confirm?
I've never used SDL 3 but I built the framework (I'm on macOS) and now I'm getting some linker errors. Are these functions removed or did I need to configure something differently so these functions are included. I built from the Xcode project included in the package.
Undefined symbols for architecture arm64:
"_SDL_GetWindowDisplayIndex", referenced from:
_GLCANVAS_$$_GETDISPLAYSIZE$$TGVEC2$1$CRC713F463B_CRC217401AD in GLCanvas.o
"_SDL_IsGameController", referenced from:
_GLCANVAS_$$_POLLSYSTEMINPUT$PSDL_EVENT in GLCanvas.o
"_SDL_JoystickClose", referenced from:
_GLCANVAS_$$_POLLSYSTEMINPUT$PSDL_EVENT in GLCanvas.o
"_SDL_JoystickGetAttached", referenced from:
_GLCANVAS$_$TGAMECONTROLLER_$__$$_ISCONNECTED$$BOOLEAN in GLCanvas.o
_GLCANVAS_$$_POLLSYSTEMINPUT$PSDL_EVENT in GLCanvas.o
"_SDL_JoystickGetGUID", referenced from:
_GLCANVAS$_$TGAMECONTROLLER_$__$$_GUIDSTRING$$SHORTSTRING in GLCanvas.o
_GLCANVAS_$$_POLLSYSTEMINPUT$PSDL_EVENT in GLCanvas.o
"_SDL_JoystickGetGUIDString", referenced from:
_GLCANVAS$_$TGAMECONTROLLER_$__$$_GUIDSTRING$$SHORTSTRING in GLCanvas.o
"_SDL_JoystickInstanceID", referenced from:
_GLCANVAS_$$_POLLSYSTEMINPUT$PSDL_EVENT in GLCanvas.o
"_SDL_JoystickName", referenced from:
_GLCANVAS$_$TGAMECONTROLLER_$__$$_NAME$$SHORTSTRING in GLCanvas.o
_GLCANVAS_$$_POLLSYSTEMINPUT$PSDL_EVENT in GLCanvas.o
"_SDL_JoystickNumAxes", referenced from:
_GLCANVAS_$$_POLLSYSTEMINPUT$PSDL_EVENT in GLCanvas.o
"_SDL_JoystickNumButtons", referenced from:
_GLCANVAS_$$_POLLSYSTEMINPUT$PSDL_EVENT in GLCanvas.o
"_SDL_JoystickNumHats", referenced from:
_GLCANVAS_$$_POLLSYSTEMINPUT$PSDL_EVENT in GLCanvas.o
"_SDL_JoystickOpen", referenced from:
_GLCANVAS_$$_POLLSYSTEMINPUT$PSDL_EVENT in GLCanvas.o
Yes, those functions are renamed/removed - see https://github.com/libsdl-org/SDL/blob/main/docs/README-migration.md
The commit was backported to SDL2 as well though: https://github.com/libsdl-org/SDL/commit/2c6995778e941524a4857b55d4e35745313c924a
The commit was backported to SDL2 as well though: 2c69957
Somehow, it was missed out in the just release SDL2 2.26.4.
I merged it to the release-2.26.x branch in https://github.com/libsdl-org/SDL/commit/1723e93a0cce6f6248844391bff1e7cb42cf3ea0, thanks!
Cherry-picked https://github.com/libsdl-org/SDL/commit/1723e93a0cce6f6248844391bff1e7cb42cf3ea0 into 2.26.4. 8BitDo M30 D-Input and Mac mode (PS4 Controller) now work fine on macOS Venture 13.2.1. But D-Input mode seemed to enumerate twice, as Gamecontroller and Joystick. Mac mode has no such issue.
gamepad: #0 PS4 Controller
gamepad: #0 Removed
gamepad: #0 8BitDo M30 Gamepad
gamepad: #1 8BitDo M30 gamepad [ 0 buttons 0 axes 0 hats ]
I fixed the duplicate controller issue as well, so I think we can close this. Thanks!
Sorry I used SDL from Pascal so I'm gonna have to update my headers and that will take some time. I'll test this later though and reopen if it's not fixed.
I fixed the duplicate controller issue as well, so I think we can close this. Thanks!
With this change cherry-picked into 2.26.4, D-Input mode only showed up as Joystick and no input events ever come in.
gamepad: #0 8BitDo M30 gamepad [ 0 buttons 0 axes 0 hats ]
gamepad: #0 Removed
gamepad: #0 8BitDo M30 gamepad [ 0 buttons 0 axes 0 hats ]
gamepad: #0 Removed
Whereas before that, while it showed up twice as GameController and Joystick, it actually worked as GameController and input events came in as well since the other Joystick instance registered 0 buttons 0 axes and 0 hats. Is this the expected behavior?