/* KindlePDFViewer: input abstraction for Lua Copyright (C) 2011 Hans-Werner Hilse This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include #include #include "input.h" #define NUM_FDS 3 int inputfds[3] = { -1, -1, -1 }; static int openInputDevice(lua_State *L) { #ifndef EMULATE_READER int i; const char* inputdevice = luaL_checkstring(L, 1); for(i=0; i: %d", inputdevice, errno); } } } return luaL_error(L, "no free slot for new input device <%s>", inputdevice); #else if(SDL_Init(SDL_INIT_VIDEO) < 0) { return luaL_error(L, "cannot initialize SDL."); } return 0; #endif } static int closeInputDevices(lua_State *L) { int i; for(i=0; i nfds) nfds = inputfds[i] + 1; } num = select(nfds, &fds, NULL, NULL, &timeout); if(num < 0) { return luaL_error(L, "Waiting for input failed: %d\n", errno); } for(i=0; i