Wayland not found, causing gamepad not detected?

I am on Ubuntu 20.04.1 LTS

When I configure, build and use SDL2.0.12, then my gamepad is not found.

The Ubuntu provided SDL2 does work:

$ /usr/bin/sdl2-config --version
2.0.10
$ /usr/bin/sdl2-config --static-libs
-lSDL2 -Wl,--no-undefined -lm -ldl -lasound -lm -ldl -lpthread -lpulse-simple -lpulse -lX11 -lXext -lXcursor -lXinerama -lXi -lXrandr -lXss -lXxf86vm -lwayland-egl -lwayland-client -lwayland-cursor -lxkbcommon -lpthread -lrt

My own-built SDL2 does not:

Enabled modules : atomic audio video render events joystick haptic sensor power filesystem threads timers file loadso cpuinfo assembly
Assembly Math   : mmx 3dnow sse sse2 sse3
Audio drivers   : disk dummy oss alsa(dynamic) pulse(dynamic) sndio(dynamic)
Video drivers   : dummy x11(dynamic) opengl opengl_es1 opengl_es2 vulkan
X11 libraries   : xcursor xdbe xinerama xinput2 xinput2_multitouch xrandr xscrnsaver xshape xvidmode
Input drivers   : linuxev linuxkd
Using libsamplerate : NO
Using libudev       : YES
Using dbus          : YES
Using ime           : YES
Using ibus          : YES
Using fcitx         : NO

with this result:

$ /opt/SDL2/bin/sdl2-config --version
2.0.12
$ /opt/SDL2/bin/sdl2-config --static-libs
-L/opt/SDL2/lib -Wl,-rpath,/opt/SDL2/lib -Wl,--enable-new-dtags -lSDL2 -Wl,--no-undefined -lm -ldl -lpthread -lrt

I am beginning to suspect that this has to do with configure not finding wayland support.

Despite my system having this:

# pkg-config --list-all | grep wayland
wayland-egl                    wayland-egl - Frontend wayland-egl library
wayland-cursor                 Wayland Cursor - Wayland cursor helper library
wayland-scanner                Wayland Scanner - Wayland scanner
wayland-client                 Wayland Client - Wayland client side library
wayland-server                 Wayland Server - Server side implementation of the Wayland protocol

Two things surprise me:

  1. Why is wayland not detected?
  2. Why would gamepads not work, even though udev, dbus, etc, are all there?

By the way… the config.log has very little info on why Wayland would not be found:

configure:15572: checking for Wayland support
configure:15584: result: no

Do you have libwayland-dev installed? That’s the only Wayland-related dependency I see in the installation instructions.

I have. I was missing wayland-protocols package, and it looks like the wayland not getting found was because of that. Configure now sees wayland, but still sees no gamepads. I even copied the deb pacakage’s configure command line, but still, no go.

Ok, mystery solved!

I was calling:

SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER | SDL_INIT_TIMER | SDL_INIT_AUDIO );

And if the INIT_AUDIO fails, the initialization of the gamepad stuff is skipped.

I had built an SDL2 without audio (to reduce dependencies that other distros may not have.)

Lesson learned: it is better to call SDL_InitSubSystem() instead, with one subsystem at a time, and check the return values!

I think I will take the wayland support out again, as I am trying to end up with a binary that pulls in as few dynamic libs as possible.

1 Like