diff --git a/src/game.c b/src/game.c index 45b23dc..7856b85 100644 --- a/src/game.c +++ b/src/game.c @@ -43,21 +43,20 @@ void update(void) log_message("MoveUp pressed!"); if(input_map_state_get("MoveDown", GLFW_RELEASE)) - { - input_map_remvove("Test"); log_message("MoveDown pressed!"); - } if(input_map_state_get("Test", GLFW_RELEASE)) log_message("Test released"); if(input_map_state_get("Test2", GLFW_RELEASE)) { - int keys[] = {GLFW_KEY_R}; - input_map_keys_set("Test2", keys, 1); + input_map_name_set("Test2", "NewTest"); log_message("Test2 released!"); } + if(input_map_state_get("NewTest", GLFW_RELEASE)) + log_message("NewTest released"); + input_update(); } diff --git a/src/input.c b/src/input.c index 4d64366..08b1d6c 100644 --- a/src/input.c +++ b/src/input.c @@ -168,11 +168,26 @@ bool input_map_keys_set(const char* name, int* keys, int num_keys) } success = true; } - if(!success) log_error("input:map_set_keys", "Map %s not found", name); + if(!success) log_error("input:map_keys_set", "Map %s not found", name); return success; } +bool input_map_name_set(const char* name, const char* new_name) +{ + assert(name && new_name); + bool success = false; + int index = map_find(name); + if(index > -1) + { + Input_Map* map = array_get(input_map_list, (unsigned int)index); + map->name = new_name; + success = true; + } + if(!success) log_error("input:map_name_set", "Map %s not found", name); + return success; +} + static int map_find(const char* name) { int index = -1; diff --git a/src/input.h b/src/input.h index 9cb0ba7..9becdc8 100644 --- a/src/input.h +++ b/src/input.h @@ -33,5 +33,6 @@ bool input_map_state_get(const char* map_name, int state); void input_map_create(const char* name, int* keys, size_t num_keys); bool input_map_remvove(const char* name); bool input_map_keys_set(const char* name, int* keys, int num_keys); +bool input_map_name_set(const char* name, const char* new_name); #endif