Event que on keyboard

my programm contains a timer because it’s kinda of realtime app and i
want to get the keyboard input but if i put there the fuction
UpdateInput(); of my on fuctions it waits for an event instead
of reading out of the event_que which i don;t know where to read out
and this stops my programm until there is a key-board event.

what is there to do ?

Thank you===============================

void UpdateInput(void)
{
extern Uint8 *keys;
extern double cur_accel;
extern double cur_angle;

while ( SDL_WaitEvent(&event) >= 0 ) {
switch (event.type) {
case SDL_KEYDOWN: {
keys = SDL_GetKeyState(NULL);
if ( keys[SDLK_ESCAPE] == SDL_PRESSED ) {
SDL_FreeSurface(planet_image);
SDL_FreeSurface(ufo1_image);
exit(0);
}
if ( keys[SDLK_UP] == SDL_PRESSED ) {
while (1) {
cur_accel = 10;
break;
}
}
if ( keys[SDLK_LEFT] == SDL_PRESSED ) {
while (1) {
if (cur_angle >= 360) {
cur_angle=0;
} else {
cur_angle++;
}
break;
}
}
if ( keys[SDLK_RIGHT] == SDL_PRESSED ) {
while (1) {
if (cur_angle <= 0) {
cur_angle=360;
} else {
cur_angle–;
}
break;
}
}
break;
}

  	case SDL_QUIT: { 			
  		SDL_FreeSurface(planet_image);
  		SDL_FreeSurface(ufo1_image);
  		exit(0);
  	}
  }	
break;

}
}


From:
Joachim Schiele
[ http://www.dune2.de || Linux - my way! ]

Try SDL_PollEvents instead of SDL_WaitEvent.

  • Chris

At 03:09 PM 6/18/00 +0200, you wrote:>my programm contains a timer because it’s kinda of realtime app and i

want to get the keyboard input but if i put there the fuction
UpdateInput(); of my on fuctions it waits for an event instead
of reading out of the event_que which i don;t know where to read out
and this stops my programm until there is a key-board event.

what is there to do ?

Thank you

my programm contains a timer because it’s kinda of realtime app and i
want to get the keyboard input but if i put there the fuction
UpdateInput(); of my on fuctions it waits for an event instead
of reading out of the event_que which i don;t know where to read out
and this stops my programm until there is a key-board event.

Use SDL_PolLEvent() instead of WaitEvent… :slight_smile:

-bill!