Fixed windows compilation

This commit is contained in:
Łukasz Magiera 2016-02-28 14:39:57 +01:00
parent 3b89f0b59c
commit 23512a8ae6

View File

@ -5,6 +5,7 @@
#include <lua.h> #include <lua.h>
#include <lualib.h> #include <lualib.h>
#include <lauxlib.h> #include <lauxlib.h>
#ifndef _WIN32
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/mman.h> #include <sys/mman.h>
@ -391,11 +392,6 @@ static int l_get_height (lua_State *L) {
return 1; return 1;
} }
static int l_fb_ready (lua_State *L) {
lua_pushboolean(L, fb_ready);
return 1;
}
static int l_fb_getbg (lua_State *L) { static int l_fb_getbg (lua_State *L) {
int x = lua_tonumber(L, 1); int x = lua_tonumber(L, 1);
int y = lua_tonumber(L, 2); int y = lua_tonumber(L, 2);
@ -429,7 +425,19 @@ static int l_fb_get (lua_State *L) {
return 1; return 1;
} }
#endif
static int l_fb_ready (lua_State *L) {
#ifndef _WIN32
lua_pushboolean(L, fb_ready);
#else
lua_pushboolean(L, 0);
#endif
return 1;
}
void fb_start(lua_State *L) { void fb_start(lua_State *L) {
#ifndef _WIN32
fb_file = open("/dev/fb0", O_RDWR); fb_file = open("/dev/fb0", O_RDWR);
if (fb_file == -1) { if (fb_file == -1) {
printf("Error: cannot open framebuffer device"); printf("Error: cannot open framebuffer device");
@ -484,18 +492,22 @@ void fb_start(lua_State *L) {
fb_ready = 1; fb_ready = 1;
#endif
struct luaL_Reg fblib[] = { struct luaL_Reg fblib[] = {
#ifndef _WIN32
{"setPalette", l_set_palette}, {"setPalette", l_set_palette},
{"getWidth", l_get_width}, {"getWidth", l_get_width},
{"getHeight", l_get_height}, {"getHeight", l_get_height},
{"put", l_fbput}, {"put", l_fbput},
{"copy", l_fbcopy}, {"copy", l_fbcopy},
{"fill", l_fbfill}, {"fill", l_fbfill},
{"isReady", l_fb_ready},
{"getBackground", l_fb_getbg}, {"getBackground", l_fb_getbg},
{"getForeground", l_fb_getfg}, {"getForeground", l_fb_getfg},
{"get", l_fb_get}, {"get", l_fb_get},
{"getNearest", l_get_nearest}, {"getNearest", l_get_nearest},
#endif
{"isReady", l_fb_ready},
{NULL, NULL} {NULL, NULL}
}; };