Merge branch 'new_ui_code' into ges-detect

This commit is contained in:
Qingping Hou
2012-11-16 18:57:29 -05:00

14
input.c
View File

@@ -250,8 +250,8 @@ static inline void set_event_table(lua_State *L, struct input_event input) {
static int waitForInput(lua_State *L) {
struct input_event input;
int n;
#ifndef EMULATE_READER
int usecs = luaL_optint(L, 1, -1); // we check for <0 later
#ifndef EMULATE_READER
fd_set fds;
struct timeval timeout;
int i, num, nfds;
@@ -298,7 +298,17 @@ static int waitForInput(lua_State *L) {
return 1;
}
SDL_WaitEvent(&event);
int ticks = SDL_GetTicks();
if (usecs < 0)
SDL_WaitEvent(&event);
else {
while (SDL_GetTicks()-ticks <= usecs/1000) {
if (SDL_PollEvent(&event)) break;
SDL_Delay(10);
}
if (SDL_GetTicks()-ticks > usecs/1000)
return luaL_error(L, "Waiting for input failed: timeout\n");
}
switch(event.type) {
case SDL_KEYDOWN:
genEmuEvent(L, inputfds[0], EV_KEY, event.key.keysym.scancode, 1);