RSDKModding / RSDKv4-Decompilation

A complete decompilation of Sonic 1 & Sonic 2 (2013) & Retro Engine (v4)
Other
937 stars 175 forks source link

SDL_NumJoysticks() returns 0 even though a controller is connected #334

Closed awe444 closed 2 years ago

awe444 commented 2 years ago

I've compiled on Linux (Raspberry Pi 3B, Bullseye kernel 5.15.32), using SDL 2.0.22, with SDL_VIDEODRIVER=wayland (no X11/xorg anywhere in the environment, I'm launching the game from inside weston).

The game runs well, but only keyboard input was being recognized, while my bluetooth 8bitdo controller was being ignored.

Initially I tried setting hint variables like SDL_GAMECONTROLLERCONFIG and SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT but those had no effect, and other SDL software was recognizing the gamepad without such hints anyways.

Then I added a print statement which revealed that SDL_NumJoysticks() was returning 0. After further exploring I found that by adding SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER); immediately before this line fixed the issue (SDL_NumJoysticks() now returns 1 and the controller now gets recognized).

Why might this be the case, and is there anything else I can try or share to help debug this issue?

Rubberduckycooly commented 2 years ago

that's very strange... SDL should've initialized all it's subsystems by then, so it should be picking up input devices.

I've pushed the SDL_Init "workaround" in commit b59c2d6, since I'm not really sure what's wrong and it shouldn't cause anyone else any issues by having the SDL_Init there.

Please feel free to reopen this issue if the workaround fix doesn't work!

awe444 commented 2 years ago

Thanks for that--

For further context: the SDL build I'm using was custom compiled (since I wanted to strip out all the X11 stuff), so it's possible the compiler flags I used could have caused this. FWIW, I had compiled SDL with:

CFLAGS="-O3 -march=armv8-a+crc -mtune=cortex-a53 -DMESA_EGL_NO_X11_HEADERS" \
CXXFLAGS="-O3 -march=armv8-a+crc -mtune=cortex-a53 -DMESA_EGL_NO_X11_HEADERS" \
./configure \
--prefix=/usr \
--enable-video-kmsdrm \
--enable-video-wayland \
--enable-libudev \
--enable-video-opengles \
--enable-video-opengl \
--disable-video-x11 \
--disable-dbus \
--disable-diskaudio \
--disable-oss \
--disable-pulseaudio \
--disable-dummyaudio \
--disable-video-dummy \
--disable-ime \
--disable-video-vulkan