From cdd5549ad3bf48627fd4fc9362179bbdc5414fe1 Mon Sep 17 00:00:00 2001 From: Allanis Date: Tue, 18 Mar 2014 15:23:42 +0000 Subject: [PATCH] [Change] Improved the keybind loading system somewhat. --- src/conf.c | 4 ++-- src/input.c | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/conf.c b/src/conf.c index fb30d99..b224d46 100644 --- a/src/conf.c +++ b/src/conf.c @@ -276,7 +276,7 @@ int conf_loadConfig(const char* file) { mod = NULL; lua_remove(L, -1); - if((key != SDLK_UNKNOWN) && (str != NULL)) { + if(str != NULL) { /* Then the keybind is valid. Get the type. */ if(strcmp(str, "null") ==0) type = KEYBIND_NULL; else if(strcmp(str, "keyboard") ==0) type = KEYBIND_KEYBOARD; @@ -308,7 +308,7 @@ int conf_loadConfig(const char* file) { /* Set the keybind. */ input_setKeybind((char*)keybindNames[i], type, key, m, reverse); } else { - WARN("Malformed keybind in %s", file); + WARN("Malformed keybind for %s in '%s'", keybindNames[i], file); } /* Clean up after table crap. */ diff --git a/src/input.c b/src/input.c index 2446430..9cad2a2 100644 --- a/src/input.c +++ b/src/input.c @@ -220,9 +220,15 @@ static void input_keyConvDestroy(void) { */ SDLKey input_keyConv(char* name) { SDLKey k; + size_t l; + char buf[2]; + + l = strlen(name); + buf[0] = tolower(name[0]); + buf[1] = '\0'; for(k = SDLK_FIRST; k < SDLK_LAST; k++) - if(strcmp(name, keyconv[k])==0) + if(strcmp((l==1) ? buf : name, keyconv[k])==0) return k; WARN("Keyname '%s' doesn't match any key.", name);