From 22f6d1ce1d595e2339009ef019a548e07ff8d1b2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 25 Feb 2016 17:32:12 +0100 Subject: [PATCH] Cleanups --- menu/menu_input.c | 19 +++++++++---------- menu/menu_input.h | 11 +++++++++-- menu/menu_setting.c | 4 ++-- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index d1ba0b6261..f4f198f612 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -701,8 +701,7 @@ static int menu_input_key_bind_set_mode_common( return 0; } -int menu_input_key_bind_set_mode(void *data, - enum menu_input_bind_mode type) +bool menu_input_key_bind_set_mode(enum menu_input_bind_mode type, void *data) { unsigned index_offset; menu_handle_t *menu = NULL; @@ -711,11 +710,11 @@ int menu_input_key_bind_set_mode(void *data, settings_t *settings = config_get_ptr(); if (!setting) - return -1; + return false; if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) - return -1; + return false; if (menu_input_key_bind_set_mode_common(setting, type) == -1) - return -1; + return false; index_offset = menu_setting_get_index_offset(setting); bind_port = settings->input.joypad_map[index_offset]; @@ -730,7 +729,7 @@ int menu_input_key_bind_set_mode(void *data, input_keyboard_wait_keys(menu, menu_input_key_bind_custom_bind_keyboard_cb); - return 0; + return true; } void menu_input_key_bind_set_min_max(unsigned min, unsigned max) @@ -744,7 +743,7 @@ void menu_input_key_bind_set_min_max(unsigned min, unsigned max) menu_input->binds.last = max; } -int menu_input_key_bind_iterate(char *s, size_t len) +bool menu_input_key_bind_iterate(char *s, size_t len) { struct menu_bind_state binds; bool timed_out = false; @@ -780,7 +779,7 @@ int menu_input_key_bind_iterate(char *s, size_t len) if (timed_out) input_keyboard_wait_keys_cancel(); - return 1; + return true; } binds = menu_input->binds; @@ -799,7 +798,7 @@ int menu_input_key_bind_iterate(char *s, size_t len) binds.begin++; if (binds.begin > binds.last) - return 1; + return true; binds.target++; binds.timeout_end = retro_get_time_usec() + @@ -807,7 +806,7 @@ int menu_input_key_bind_iterate(char *s, size_t len) } menu_input->binds = binds; - return 0; + return false; } static int menu_input_mouse(unsigned *action) diff --git a/menu/menu_input.h b/menu/menu_input.h index d59b68fa3f..f95b5ef0af 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -107,6 +107,12 @@ typedef struct menu_input_ctx_hitbox int32_t y2; } menu_input_ctx_hitbox_t; +typedef struct menu_input_ctx_bind +{ + char *s; + size_t len; +} menu_input_ctx_bind_t; + /* Keyboard input callbacks */ void menu_input_st_uint_cb (void *userdata, const char *str); void menu_input_st_hex_cb (void *userdata, const char *str); @@ -117,9 +123,10 @@ void menu_input_key_start_line(const char *label, const char *label_setting, unsigned type, unsigned idx, input_keyboard_line_complete_t cb); -int menu_input_key_bind_iterate(char *s, size_t len); +bool menu_input_key_bind_iterate(char *s, size_t len); -int menu_input_key_bind_set_mode(void *data, enum menu_input_bind_mode type); +bool menu_input_key_bind_set_mode(enum menu_input_bind_mode type, + void *data); void menu_input_key_bind_set_min_max(unsigned min, unsigned max); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 914d03bf12..73d4bc12b1 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -2548,7 +2548,7 @@ static int setting_action_ok_bind_all(void *data, bool wraparound) if (!global) return -1; - menu_input_key_bind_set_mode(data, MENU_INPUT_BIND_ALL); + menu_input_key_bind_set_mode(MENU_INPUT_BIND_ALL, data); return 0; } @@ -2687,7 +2687,7 @@ static int setting_bind_action_ok(void *data, bool wraparound) { (void)wraparound; - menu_input_key_bind_set_mode(data, MENU_INPUT_BIND_SINGLE); + menu_input_key_bind_set_mode(MENU_INPUT_BIND_SINGLE, data); return 0; }