[Change] Improved the keybind loading system somewhat.

This commit is contained in:
Allanis 2014-03-18 15:23:42 +00:00
parent 770bad9ecc
commit cdd5549ad3
2 changed files with 9 additions and 3 deletions

View File

@ -276,7 +276,7 @@ int conf_loadConfig(const char* file) {
mod = NULL; mod = NULL;
lua_remove(L, -1); lua_remove(L, -1);
if((key != SDLK_UNKNOWN) && (str != NULL)) { if(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;
else if(strcmp(str, "keyboard") ==0) type = KEYBIND_KEYBOARD; else if(strcmp(str, "keyboard") ==0) type = KEYBIND_KEYBOARD;
@ -308,7 +308,7 @@ int conf_loadConfig(const char* file) {
/* Set the keybind. */ /* Set the keybind. */
input_setKeybind((char*)keybindNames[i], type, key, m, reverse); input_setKeybind((char*)keybindNames[i], type, key, m, reverse);
} else { } else {
WARN("Malformed keybind in %s", file); WARN("Malformed keybind for %s in '%s'", keybindNames[i], file);
} }
/* Clean up after table crap. */ /* Clean up after table crap. */

View File

@ -220,9 +220,15 @@ static void input_keyConvDestroy(void) {
*/ */
SDLKey input_keyConv(char* name) { SDLKey input_keyConv(char* name) {
SDLKey k; 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++) 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; return k;
WARN("Keyname '%s' doesn't match any key.", name); WARN("Keyname '%s' doesn't match any key.", name);