The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
[Workaround] RPI2 keystrokes leaking into X11 terminal
josephpaul0


Joined: 10 Apr 2016
Posts: 3
Applies to : Raspberry Pi 2 and SDL 2.0.4
OS : Raspbian Jessie and Ubuntu MATE for RPI

Problem : when started from a terminal under X-Window, SDL2 programs leak keyboard input into the X11 terminal.
Consequence : Undesired shell commands may be executed and have a potentially dangerous outcome.
Workarounds:
- start SDL2 programs from a pure tty (not under X11).
- or capture stdin into your SDL2 application (under X11).

[HOWTO] Capturing stdin into your SDL2 program:
You can read this code from Rock Dodger CE as an example.
Then use it into you main() function like this:

Code:
struct termios saved;
init_RPI_termios(&saved);
gameloop(); // calls capture_RPI_stdin();
restore_RPI_termios(&saved);