diff --git a/src/conf.c b/src/conf.c index 9c15f4d..6b78609 100644 --- a/src/conf.c +++ b/src/conf.c @@ -210,17 +210,19 @@ int conf_loadConfig(const char* file) { lua_remove(L, -1); } + /* Keybindings. */ for(i = 0; strcmp(keybindNames[i], "end"); i++) { lua_getglobal(L, keybindNames[i]); - str = NULL; - key = -1; - reverse = 0; if(lua_istable(L, -1)) { /* It's a gawd damn table!! */ lua_pushstring(L, "type"); lua_gettable(L, -2); if(lua_isstring(L, -1)) str = (char*)lua_tostring(L, -1); + else { + WARN("Found keybind with no type field!"); + str = "null"; + } lua_remove(L, -1); /* Get the key. */ @@ -228,19 +230,30 @@ int conf_loadConfig(const char* file) { lua_gettable(L, -2); if(lua_isnumber(L, -1)) key = (int)lua_tonumber(L, -1); + else { + WARN("Found keybind with no key field!"); + key = -1; + } lua_remove(L, -1); /* Is it reversed? Only used for axis. */ lua_pushstring(L, "reverse"); lua_gettable(L, -2); if(lua_isnumber(L, -1)) - reverse = 1; + reverse = !!(int)lua_tonumber(L, -1); + else if(lua_isboolean(L, -1)) + reverse = lua_toboolean(L, -1); + else + reverse = 0; lua_remove(L, -1); + /* Get the modifier. */ lua_pushstring(L, "mod"); lua_gettable(L, -2); if(lua_isstring(L, -1)) mod = (char*)lua_tostring(L, -1); + else + mod = NULL; lua_remove(L, -1); @@ -255,6 +268,7 @@ int conf_loadConfig(const char* file) { continue; } + /* Set modifier, probably should be able to handle two at a time. */ if(mod != NULL) { if(strcmp(mod, "lctrl") ==0) m = KMOD_LCTRL; else if(strcmp(mod, "rctrl") ==0) m = KMOD_RCTRL;