mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge branch 'new_ui_code' into ges-detect
This commit is contained in:
14
input.c
14
input.c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user