Problems using SDL2 on raspberry pi without X11 running

I am having problems getting SDL2 to work on my raspberry pi without x11 running. The default SDL2 in the raspbian jessie repositories only supports and shows X11 as a viable video driver. If I run a test application without X11 running, that is booting straight to the terminal, SDL_GetNumVideoDisplays() returns 0 with the default SDL2 lib and I’m unable to create an SDL window.

I can however build SDL2 on my pi with RPI video driver support. When I boot to the terminal with this lib installed I can create a full screen SDL window relying on the RPI video driver, but I cannot receive any keyboard or mouse events,

Finally, I haven’t been able to build single SDL2 lib which can both create a floating window when X11 is running, and create a full screen window when X11 isn’t running. It’s either one or the other with any SDL2 lib I build, but not both.

I’ve tried many ./config options before make’ing SDL2, and I yet to create a lib which works both with the RPI driver (supporting mouse and keyboard input), and the X11 driver (capable of creating a visible floating window).

If anyone has been able to get an SDL2 lib working on raspberry pi that works as described in the prior paragraph, would you be so kind as to provide some information on how to build such an SDL lib for the pi? I think this information might be useful to others.

Thank you

For the rpi driver, keyboard and mouse input comes from evdev. Make sure you have the libevdev-dev package installed so the configure script picks it up. Also make sure your user has access to the appropriate event device files. You may have to put the user in the input group.

Tested on a Raspberry Pi 3 Model B with Raspbian Jessie and the current tip of Configure command: configure --disable-rpath --enable-video-rpi --disable-video-kmsdrm. Moved the new library to the directory of the test application and renamed it to the name of the SDL2 library the application wants to load. Run command: LD_LIBRARY_PATH=. ./testapplication.