[Add] Support for mod keys in configuration.
This commit is contained in:
parent
0914172c53
commit
c9eea49c53
29
src/conf.c
29
src/conf.c
@ -98,6 +98,9 @@ void conf_setDefaults(void) {
|
|||||||
int conf_loadConfig(const char* file) {
|
int conf_loadConfig(const char* file) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
double d = 0.;
|
double d = 0.;
|
||||||
|
char* str, *mod;
|
||||||
|
int type, key, reverse;
|
||||||
|
SDLMod m;
|
||||||
|
|
||||||
lua_State* L = llua_newState();
|
lua_State* L = llua_newState();
|
||||||
if(luaL_dofile(L, file) == 0) {
|
if(luaL_dofile(L, file) == 0) {
|
||||||
@ -150,8 +153,6 @@ int conf_loadConfig(const char* file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If there are any keybindings. Grab them. */
|
/* If there are any keybindings. Grab them. */
|
||||||
char* str;
|
|
||||||
int type, key, reverse;
|
|
||||||
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;
|
str = NULL;
|
||||||
@ -176,6 +177,11 @@ int conf_loadConfig(const char* file) {
|
|||||||
if(lua_isnumber(L, -1))
|
if(lua_isnumber(L, -1))
|
||||||
reverse = 1;
|
reverse = 1;
|
||||||
|
|
||||||
|
lua_pushstring(L, "mod");
|
||||||
|
lua_gettable(L, -4);
|
||||||
|
if(lua_isstring(L, -1))
|
||||||
|
mod = (char*)lua_tostring(L, -1);
|
||||||
|
|
||||||
if(key != -1 && str != NULL) {
|
if(key != -1 && str != NULL) {
|
||||||
/* Then the keybind is valid. Get the type. */
|
/* Then the keybind is valid. Get the type. */
|
||||||
if(strcmp(str, "null")==0) type = KEYBIND_NULL;
|
if(strcmp(str, "null")==0) type = KEYBIND_NULL;
|
||||||
@ -186,8 +192,25 @@ int conf_loadConfig(const char* file) {
|
|||||||
WARN("Unknown keybinding of type %s", str);
|
WARN("Unknown keybinding of type %s", str);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(mod != NULL) {
|
||||||
|
if(strcmp(mod, "lctrl") ==0) m = KMOD_LCTRL;
|
||||||
|
else if(strcmp(mod, "rctrl") ==0) m = KMOD_RCTRL;
|
||||||
|
else if(strcmp(mod, "lshift") ==0) m = KMOD_LSHIFT;
|
||||||
|
else if(strcmp(mod, "rshift") ==0) m = KMOD_RSHIFT;
|
||||||
|
else if(strcmp(mod, "lalt") ==0) m = KMOD_LALT;
|
||||||
|
else if(strcmp(mod, "ralt") ==0) m = KMOD_RALT;
|
||||||
|
else if(strcmp(mod, "lmeta") ==0) m = KMOD_LMETA;
|
||||||
|
else if(strcmp(mod, "rmeta") ==0) m = KMOD_RMETA;
|
||||||
|
else {
|
||||||
|
WARN("Unkown keybinding mod of type %s", mod);
|
||||||
|
m = KMOD_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else m = KMOD_NONE;
|
||||||
|
|
||||||
/* Set the keybind. */
|
/* Set the keybind. */
|
||||||
input_setKeybind((char*)keybindNames[i], type, key, KMOD_ALL, reverse);
|
input_setKeybind((char*)keybindNames[i], type, key, m, reverse);
|
||||||
} else
|
} else
|
||||||
WARN("Malformed keybind in %s", file);
|
WARN("Malformed keybind in %s", file);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user