[Add] Some better keybind loading.
This commit is contained in:
parent
5b8a9bcbc0
commit
e02f379050
22
src/conf.c
22
src/conf.c
@ -210,17 +210,19 @@ int conf_loadConfig(const char* file) {
|
|||||||
lua_remove(L, -1);
|
lua_remove(L, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Keybindings. */
|
||||||
for(i = 0; strcmp(keybindNames[i], "end"); i++) {
|
for(i = 0; strcmp(keybindNames[i], "end"); i++) {
|
||||||
lua_getglobal(L, keybindNames[i]);
|
lua_getglobal(L, keybindNames[i]);
|
||||||
str = NULL;
|
|
||||||
key = -1;
|
|
||||||
reverse = 0;
|
|
||||||
if(lua_istable(L, -1)) {
|
if(lua_istable(L, -1)) {
|
||||||
/* It's a gawd damn table!! */
|
/* It's a gawd damn table!! */
|
||||||
lua_pushstring(L, "type");
|
lua_pushstring(L, "type");
|
||||||
lua_gettable(L, -2);
|
lua_gettable(L, -2);
|
||||||
if(lua_isstring(L, -1))
|
if(lua_isstring(L, -1))
|
||||||
str = (char*)lua_tostring(L, -1);
|
str = (char*)lua_tostring(L, -1);
|
||||||
|
else {
|
||||||
|
WARN("Found keybind with no type field!");
|
||||||
|
str = "null";
|
||||||
|
}
|
||||||
lua_remove(L, -1);
|
lua_remove(L, -1);
|
||||||
|
|
||||||
/* Get the key. */
|
/* Get the key. */
|
||||||
@ -228,19 +230,30 @@ int conf_loadConfig(const char* file) {
|
|||||||
lua_gettable(L, -2);
|
lua_gettable(L, -2);
|
||||||
if(lua_isnumber(L, -1))
|
if(lua_isnumber(L, -1))
|
||||||
key = (int)lua_tonumber(L, -1);
|
key = (int)lua_tonumber(L, -1);
|
||||||
|
else {
|
||||||
|
WARN("Found keybind with no key field!");
|
||||||
|
key = -1;
|
||||||
|
}
|
||||||
lua_remove(L, -1);
|
lua_remove(L, -1);
|
||||||
|
|
||||||
/* Is it reversed? Only used for axis. */
|
/* Is it reversed? Only used for axis. */
|
||||||
lua_pushstring(L, "reverse");
|
lua_pushstring(L, "reverse");
|
||||||
lua_gettable(L, -2);
|
lua_gettable(L, -2);
|
||||||
if(lua_isnumber(L, -1))
|
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);
|
lua_remove(L, -1);
|
||||||
|
|
||||||
|
/* Get the modifier. */
|
||||||
lua_pushstring(L, "mod");
|
lua_pushstring(L, "mod");
|
||||||
lua_gettable(L, -2);
|
lua_gettable(L, -2);
|
||||||
if(lua_isstring(L, -1))
|
if(lua_isstring(L, -1))
|
||||||
mod = (char*)lua_tostring(L, -1);
|
mod = (char*)lua_tostring(L, -1);
|
||||||
|
else
|
||||||
|
mod = NULL;
|
||||||
lua_remove(L, -1);
|
lua_remove(L, -1);
|
||||||
|
|
||||||
|
|
||||||
@ -255,6 +268,7 @@ int conf_loadConfig(const char* file) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set modifier, probably should be able to handle two at a time. */
|
||||||
if(mod != NULL) {
|
if(mod != NULL) {
|
||||||
if(strcmp(mod, "lctrl") ==0) m = KMOD_LCTRL;
|
if(strcmp(mod, "lctrl") ==0) m = KMOD_LCTRL;
|
||||||
else if(strcmp(mod, "rctrl") ==0) m = KMOD_RCTRL;
|
else if(strcmp(mod, "rctrl") ==0) m = KMOD_RCTRL;
|
||||||
|
Loading…
Reference in New Issue
Block a user