From 3eeae957f6dbfb036663c976feb83067fa8df630 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 9 Sep 2017 00:12:40 +0200 Subject: [PATCH] Cleanups --- configuration.c | 16 +++--- menu/menu_displaylist.h | 24 ++++---- menu/menu_setting.c | 3 +- menu/widgets/menu_entry.h | 2 +- menu/widgets/menu_filebrowser.c | 2 +- menu/widgets/menu_input_bind_dialog.c | 82 ++++++++++++++------------- menu/widgets/menu_list.c | 19 ++++--- 7 files changed, 79 insertions(+), 69 deletions(-) diff --git a/configuration.c b/configuration.c index fbd64f79ff..dcc2702e67 100644 --- a/configuration.c +++ b/configuration.c @@ -63,36 +63,36 @@ struct config_bool_setting struct config_int_setting { const char *ident; - int *ptr; bool def_enable; - int def; bool handle; + int *ptr; + int def; }; struct config_uint_setting { const char *ident; - unsigned *ptr; bool def_enable; - unsigned def; bool handle; + unsigned *ptr; + unsigned def; }; struct config_float_setting { const char *ident; - float *ptr; bool def_enable; - float def; bool handle; + float *ptr; + float def; }; struct config_array_setting { const char *ident; char *ptr; - bool def_enable; const char *def; + bool def_enable; bool handle; }; @@ -100,8 +100,8 @@ struct config_path_setting { const char *ident; char *ptr; - bool def_enable; char *def; + bool def_enable; bool handle; }; diff --git a/menu/menu_displaylist.h b/menu/menu_displaylist.h index 3a6d4d0664..71db8dd760 100644 --- a/menu/menu_displaylist.h +++ b/menu/menu_displaylist.h @@ -172,44 +172,42 @@ typedef struct menu_displaylist_info bool need_refresh; bool need_entries_refresh; bool need_push; - /* should we clear the displaylist before we push * entries onto it? */ bool need_clear; - bool push_builtin_cores; - /* Should a 'download core' entry be pushed onto the list? * This will be set to true in case there are no currently * installed cores. */ bool download_core; - /* does the navigation index need to be cleared to 0 (first entry) ? */ bool need_navigation_clear; - file_list_t *list; - file_list_t *menu_list; + enum msg_hash_enums enum_idx; + char path[PATH_MAX_LENGTH]; char path_b[PATH_MAX_LENGTH]; char path_c[PATH_MAX_LENGTH]; - char label[255]; - uint32_t label_hash; char exts[PATH_MAX_LENGTH]; + char label[255]; + + size_t directory_ptr; + uint32_t label_hash; unsigned type; unsigned type_default; - size_t directory_ptr; unsigned flags; - enum msg_hash_enums enum_idx; rarch_setting_t *setting; + file_list_t *list; + file_list_t *menu_list; } menu_displaylist_info_t; typedef struct menu_displaylist_ctx_parse_entry { - void *data; - menu_displaylist_info_t *info; - const char *info_label; enum msg_hash_enums enum_idx; enum menu_displaylist_parse_type parse_type; bool add_empty_entry; + menu_displaylist_info_t *info; + const char *info_label; + void *data; } menu_displaylist_ctx_parse_entry_t; typedef struct menu_displaylist_ctx_entry diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 4d3b034d60..4ff9c04a18 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -992,7 +992,8 @@ static int setting_action_start_bind_device(void *data) return -1; configuration_set_uint(settings, - settings->uints.input_joypad_map[index_offset], setting->index_offset); + settings->uints.input_joypad_map[setting->index_offset], + setting->index_offset); return 0; } diff --git a/menu/widgets/menu_entry.h b/menu/widgets/menu_entry.h index 01e6180a1f..f46a4d0dfe 100644 --- a/menu/widgets/menu_entry.h +++ b/menu/widgets/menu_entry.h @@ -45,13 +45,13 @@ enum menu_entry_type typedef struct menu_entry { + enum msg_hash_enums enum_idx; char path[255]; char label[255]; char sublabel[255]; char rich_label[255]; char value[255]; size_t entry_idx; - enum msg_hash_enums enum_idx; unsigned idx; unsigned type; unsigned spacing; diff --git a/menu/widgets/menu_filebrowser.c b/menu/widgets/menu_filebrowser.c index b1b024ef76..dd6efd79be 100644 --- a/menu/widgets/menu_filebrowser.c +++ b/menu/widgets/menu_filebrowser.c @@ -119,7 +119,7 @@ void filebrowser_parse(void *data, unsigned type_data) { for (i = 0; i < list_size; i++) { - char label[PATH_MAX_LENGTH]; + char label[32]; bool is_dir = false; enum msg_hash_enums enum_idx = MSG_UNKNOWN; enum msg_file_type file_type = FILE_TYPE_NONE; diff --git a/menu/widgets/menu_input_bind_dialog.c b/menu/widgets/menu_input_bind_dialog.c index 9da3367292..3ba11b5ec1 100644 --- a/menu/widgets/menu_input_bind_dialog.c +++ b/menu/widgets/menu_input_bind_dialog.c @@ -49,16 +49,14 @@ struct menu_bind_axis_state struct menu_bind_state { - struct retro_keybind *target; - /* For keyboard binding. */ - - rarch_timer_t timer; + bool skip; unsigned begin; unsigned last; unsigned user; + rarch_timer_t timer; + struct retro_keybind *target; struct menu_bind_state_port state[MAX_USERS]; struct menu_bind_axis_state axis_state[MAX_USERS]; - bool skip; }; static unsigned menu_bind_port = 0; @@ -73,7 +71,8 @@ static bool menu_input_key_bind_custom_bind_keyboard_cb( menu_input_binds.begin++; menu_input_binds.target++; - rarch_timer_begin_new_time(&menu_input_binds.timer, settings->uints.input_bind_timeout); + rarch_timer_begin_new_time(&menu_input_binds.timer, + settings->uints.input_bind_timeout); return (menu_input_binds.begin <= menu_input_binds.last); } @@ -170,33 +169,33 @@ static void menu_input_key_bind_poll_bind_state_internal( unsigned port, bool timed_out) { - unsigned b, a, h; - if (!joypad) - return; + uint8_t b, a, h; + if (!joypad) + return; - if (joypad->poll) - joypad->poll(); + if (joypad->poll) + joypad->poll(); - /* poll only the relevant port */ - for (b = 0; b < MENU_MAX_BUTTONS; b++) - state->state[port].buttons[b] = - input_joypad_button_raw(joypad, port, b); + /* poll only the relevant port */ + for (b = 0; b < MENU_MAX_BUTTONS; b++) + state->state[port].buttons[b] = + input_joypad_button_raw(joypad, port, b); - for (a = 0; a < MENU_MAX_AXES; a++) - state->state[port].axes[a] = - input_joypad_axis_raw(joypad, port, a); + for (a = 0; a < MENU_MAX_AXES; a++) + state->state[port].axes[a] = + input_joypad_axis_raw(joypad, port, a); - for (h = 0; h < MENU_MAX_HATS; h++) - { - if (input_joypad_hat_raw(joypad, port, HAT_UP_MASK, h)) - state->state[port].hats[h] |= HAT_UP_MASK; - if (input_joypad_hat_raw(joypad, port, HAT_DOWN_MASK, h)) - state->state[port].hats[h] |= HAT_DOWN_MASK; - if (input_joypad_hat_raw(joypad, port, HAT_LEFT_MASK, h)) - state->state[port].hats[h] |= HAT_LEFT_MASK; - if (input_joypad_hat_raw(joypad, port, HAT_RIGHT_MASK, h)) - state->state[port].hats[h] |= HAT_RIGHT_MASK; - } + for (h = 0; h < MENU_MAX_HATS; h++) + { + if (input_joypad_hat_raw(joypad, port, HAT_UP_MASK, h)) + state->state[port].hats[h] |= HAT_UP_MASK; + if (input_joypad_hat_raw(joypad, port, HAT_DOWN_MASK, h)) + state->state[port].hats[h] |= HAT_DOWN_MASK; + if (input_joypad_hat_raw(joypad, port, HAT_LEFT_MASK, h)) + state->state[port].hats[h] |= HAT_LEFT_MASK; + if (input_joypad_hat_raw(joypad, port, HAT_RIGHT_MASK, h)) + state->state[port].hats[h] |= HAT_RIGHT_MASK; + } } static void menu_input_key_bind_poll_bind_state( @@ -269,10 +268,12 @@ static bool menu_input_key_bind_poll_find_trigger_pad( struct menu_bind_state *new_state, unsigned p) { - unsigned a, b, h; - const struct menu_bind_state_port *n = (const struct menu_bind_state_port*) + uint8_t a, b, h; + const struct menu_bind_state_port *n = + (const struct menu_bind_state_port*) &new_state->state[p]; - const struct menu_bind_state_port *o = (const struct menu_bind_state_port*) + const struct menu_bind_state_port *o = + (const struct menu_bind_state_port*) &state->state[p]; for (b = 0; b < MENU_MAX_BUTTONS; b++) @@ -345,8 +346,9 @@ static bool menu_input_key_bind_poll_find_trigger( struct menu_bind_state *state, struct menu_bind_state *new_state) { - unsigned i; - unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS)); + uint8_t i; + unsigned max_users = *(input_driver_get_uint( + INPUT_ACTION_MAX_USERS)); if (!state || !new_state) return false; @@ -391,7 +393,8 @@ bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind) menu_input_binds.begin++; menu_input_binds.target++; - rarch_timer_begin_new_time(&menu_input_binds.timer, settings->uints.input_bind_timeout); + rarch_timer_begin_new_time(&menu_input_binds.timer, + settings->uints.input_bind_timeout); timed_out = true; } @@ -410,7 +413,8 @@ bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind) /* We won't be getting any key events, so just cancel early. */ if (timed_out) - input_keyboard_ctl(RARCH_INPUT_KEYBOARD_CTL_CANCEL_WAIT_KEYS, NULL); + input_keyboard_ctl( + RARCH_INPUT_KEYBOARD_CTL_CANCEL_WAIT_KEYS, NULL); return true; } @@ -432,12 +436,14 @@ bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind) if (binds.begin > binds.last) { - input_keyboard_ctl(RARCH_INPUT_KEYBOARD_CTL_CANCEL_WAIT_KEYS, NULL); + input_keyboard_ctl( + RARCH_INPUT_KEYBOARD_CTL_CANCEL_WAIT_KEYS, NULL); return true; } binds.target++; - rarch_timer_begin_new_time(&binds.timer, settings->uints.input_bind_timeout); + rarch_timer_begin_new_time(&binds.timer, + settings->uints.input_bind_timeout); } menu_input_binds = binds; diff --git a/menu/widgets/menu_list.c b/menu/widgets/menu_list.c index 5cd4d14292..de643ad296 100644 --- a/menu/widgets/menu_list.c +++ b/menu/widgets/menu_list.c @@ -23,10 +23,10 @@ struct menu_list { - file_list_t **menu_stack; size_t menu_stack_size; - file_list_t **selection_buf; size_t selection_buf_size; + file_list_t **menu_stack; + file_list_t **selection_buf; }; void menu_list_free_list(file_list_t *list) @@ -79,17 +79,20 @@ void menu_list_free(menu_list_t *menu_list) menu_list_t *menu_list_new(void) { unsigned i; - menu_list_t *list = (menu_list_t*)calloc(1, sizeof(*list)); + menu_list_t *list = (menu_list_t*)calloc(1, + sizeof(*list)); if (!list) return NULL; - list->menu_stack = (file_list_t**)calloc(1, sizeof(*list->menu_stack)); + list->menu_stack = (file_list_t**)calloc(1, + sizeof(*list->menu_stack)); if (!list->menu_stack) goto error; - list->selection_buf = (file_list_t**)calloc(1, sizeof(*list->selection_buf)); + list->selection_buf = (file_list_t**)calloc(1, + sizeof(*list->selection_buf)); if (!list->selection_buf) goto error; @@ -98,10 +101,12 @@ menu_list_t *menu_list_new(void) list->selection_buf_size = 1; for (i = 0; i < list->menu_stack_size; i++) - list->menu_stack[i] = (file_list_t*)calloc(1, sizeof(*list->menu_stack[i])); + list->menu_stack[i] = (file_list_t*)calloc(1, + sizeof(*list->menu_stack[i])); for (i = 0; i < list->selection_buf_size; i++) - list->selection_buf[i] = (file_list_t*)calloc(1, sizeof(*list->selection_buf[i])); + list->selection_buf[i] = (file_list_t*)calloc(1, + sizeof(*list->selection_buf[i])); return list;