I’ve been trying to add some simple SDL input to a GLES program I’m working on. This program has to detect some key is being held down for a while, and add do something while it’s held down. Then, another different key could be held down for a while, and a different thing would be done while it’s held down.
The program has to exit when ESC is pushed or held down (I don’t mind).
The code relevant part in the I’m currently using is this one:
However, it doesn’t work as expectec. I’ve tried counless things today, no matter what I do I get the first “key held down” detected, and then, after releasing that key, no other key presses or holds are detected anymore.
Do you guys know what’s wrong here?
However, it doesn’t work as expectec. I’ve tried counless things today, no
matter what I do I get the first “key held down” detected, and then, after
releasing that key, no other key presses or holds are detected anymore.
Do you guys know what’s wrong here?
You have to add an SDL_PumpEvents() inside your loop, this will allow SDL
to update your key state vector.–
Bye,
Gabry
However, it doesn’t work as expectec. I’ve tried counless things today,
no matter what I do I get the first “key held down” detected, and then,
after releasing that key, no other key presses or holds are detected
anymore.
Do you guys know what’s wrong here?
You have to add an SDL_PumpEvents() inside your loop, this will allow SDL
to update your key state vector.
Sorry I see there is a SDL_PumpEvents() in your code…
Maybe the problem is that you do not have SDL_Init() and you do not have a
window? Many architectures require a window to handle events.–
Bye,
Gabry
I just copied the relevant parts, sorry. I DO have an SDL_Init() call inside main:
Code:
//Initialize all SDL subsystems
if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
{
return 0;
}
//Video is managed by other graphics system (EGL/GLES2), so I just call this for text console keyboard setting
SDL_SetVideoMode( 0, 0, 16, SDL_SWSURFACE );
Which platform is this on? I don’t exactly trust SDL 1.2 to do the right
thing on Android, for example, and would prefer SDL 2.0 there instead.
Jonny DOn Tue, Feb 18, 2014 at 10:14 AM, vanfanel wrote:
I just copied the relevant parts, sorry. I DO have an SDL_Init() call
inside main:
Code:
//Initialize all SDL subsystems
if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
{
return 0;
}
//Video is managed by other graphics system (EGL/GLES2), so I just
call this for text console keyboard setting
SDL_SetVideoMode( 0, 0, 16, SDL_SWSURFACE );
It’s on Linux X64.
I don’t mind using SDL2 instead, as the input handling stuff is very similar.
The problem is that SDL2 seems to need to create a window before starting to process keyboard input on current console, and I don’t have X11 available. It’s console EGL/GLES + SDL for input.