Hi! I’m using a separate thread and into it I do something like:
int quit_thread;
int *keys;
int thread_func(void *unused)
{
while ( quit_thread == 0 )
{
SDL_PumpEvents();
keys = SDL_GetKeyState(NULL);
if( keys[something] ) moresomething=1;
SDL_Delay(20);
}
return(0);
}
Then this thread will be executed about 50 times per second…
I use the keys[] in the main thread (the program itself) to
test if keys[something] == SDL_PRESSED, and somethings I wait
for SDL_KEYDOWN events (like a getch())… Into the thread
I’m using SDL_PumpEvents() and SDL_GetKeyState()… ?Is this
thread usage secure? Can it hang, or this code is safe for
SDL to work?
I just want to have a 50Hz thread to sync other emulator
routines to some variable changes, and to allow the rest of
the emulator to access to keypresses using the *key array.
I’ve tested SDL_SetTimer() but the emulator hangs sometimes!!!
It starts working, but something crashes (and sometimes not :),
and this thread-style works always…
CU and thx a lot.–
Windows 2000 no se cuelg?
AMIBIOS v2.8. 65535Kb OK. Iniciando Windows 2000…
-----------------------------------------------------
NoP / Compiler – nop @ todolinux.org |
---|
POWERED BY - Linux RedHat 6.0 - Reg. User #74.821 |
http://www.ctv.es/USERS/sromero |
~-----------------------------------------------------~