SDL_PollEvent
Name
SDL_PollEvent -- Polls for currently pending events.
Synopsis
#include "SDL.h" int SDL_PollEvent(SDL_Event *event);
Description
Polls for currently pending events.
If event is not NULL, the next event is removed from the queue and stored in the SDL_Event structure pointed to by event.
As this function implicitly calls SDL_PumpEvents, you can only call this function in the thread that set the video mode.
Return Value
Returns 1 if there are any pending events, or 0 if there are none available.
Examples
SDL_Event event; /* Event structure */
.
.
.
/* Check for events */
while(SDL_PollEvent(&event)) { /* Loop until there are no events left on the queue */
switch(event.type) { /* Process the appropriate event type */
case SDL_KEYDOWN: /* Handle a KEYDOWN event */
printf("Oh! Key press\n");
break;
case SDL_MOUSEMOTION:
.
.
.
default: /* Report an unhandled event */
printf("I don't know what this event is!\n");
}
}
