From d6659cd4d6a4fff4343c2b055bb5ca41feaa9c55 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 14 Sep 2014 21:56:29 +0200 Subject: [PATCH 01/28] (Menu) Use return value from backend_iterate --- frontend/menu/menu_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index c1addf3ee8..ecfc4d1f2d 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -372,14 +372,14 @@ bool menu_iterate(void) if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->iterate) - driver.menu_ctx->backend->iterate(action); + ret = driver.menu_ctx->backend->iterate(action); draw_frame(true); throttle_frame(); draw_frame(false); if (driver.menu_ctx && driver.menu_ctx->input_postprocess) - ret = driver.menu_ctx->input_postprocess(driver.menu->old_input_state); + driver.menu_ctx->input_postprocess(driver.menu->old_input_state); if (ret < 0) menu_flush_stack_type(driver.menu->menu_stack, MENU_SETTINGS); From 3d689bd40f6d774a3026315ed5434d31cd41c389 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 14 Sep 2014 22:39:33 +0200 Subject: [PATCH 02/28] (Menu) Add SD_FLAG_EXIT to signal to the menu that we want to cleanly exit out of the menu --- frontend/menu/backend/menu_common_backend.c | 59 +++++++++++++++------ frontend/menu/menu_action.c | 21 ++++++-- frontend/menu/menu_action.h | 6 +-- settings_data.c | 8 +-- settings_data.h | 1 + 5 files changed, 68 insertions(+), 27 deletions(-) diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index 4b3891969b..1050024c3b 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -215,7 +215,7 @@ static int menu_common_setting_set_perf(unsigned setting, unsigned action, } -static void menu_common_setting_set_current_path_selection( +static int menu_common_setting_set_current_path_selection( rarch_setting_t *setting, const char *start_path, const char *label, unsigned type, unsigned action) @@ -234,18 +234,28 @@ static void menu_common_setting_set_current_path_selection( if (setting->change_handler) setting->change_handler(setting); + + if (setting->flags & SD_FLAG_EXIT) + return -1; + + return 0; } -static void menu_common_setting_set_current_string_path( +static int menu_common_setting_set_current_string_path( rarch_setting_t *setting, const char *dir, const char *path) { fill_pathname_join(setting->value.string, dir, path, setting->size); if (setting->change_handler) setting->change_handler(setting); + + if (setting->flags & SD_FLAG_EXIT) + return -1; + + return 0; } -void menu_common_set_current_string_based_on_label( +int menu_common_set_current_string_based_on_label( const char *label, const char *str) { if (!strcmp(label, "video_shader_preset_save_as")) @@ -256,27 +266,38 @@ void menu_common_set_current_string_based_on_label( driver.menu_ctx->backend->shader_manager_save_preset(str, false); #endif } + + return 0; } -void menu_common_setting_set_current_string( +int menu_common_setting_set_current_string( rarch_setting_t *setting, const char *str) { strlcpy(setting->value.string, str, setting->size); if (setting->change_handler) setting->change_handler(setting); + + if (setting->flags & SD_FLAG_EXIT) + return -1; + + return 0; } -static void handle_setting(rarch_setting_t *setting, +static int handle_setting(rarch_setting_t *setting, unsigned id, const char *label, unsigned action) { if (setting->type == ST_BOOL) - menu_action_setting_boolean(setting, action); - else if (setting->type == ST_UINT) - menu_action_setting_unsigned_integer(setting, id, action); - else if (setting->type == ST_FLOAT) - menu_action_setting_fraction(setting, action); - else if (setting->type == ST_DIR) + return menu_action_setting_boolean(setting, action); + if (setting->type == ST_UINT) + return menu_action_setting_unsigned_integer(setting, id, action); + if (setting->type == ST_FLOAT) + return menu_action_setting_fraction(setting, action); + if (setting->type == ST_PATH) + return menu_common_setting_set_current_path_selection(setting, + setting->default_value.string, setting->name, id, action); + + if (setting->type == ST_DIR) { if (action == MENU_ACTION_START) { @@ -284,12 +305,14 @@ static void handle_setting(rarch_setting_t *setting, if (setting->change_handler) setting->change_handler(setting); + + if (setting->flags & SD_FLAG_EXIT) + return -1; } + return 0; } - else if (setting->type == ST_PATH) - menu_common_setting_set_current_path_selection(setting, - setting->default_value.string, setting->name, id, action); - else if (setting->type == ST_STRING) + + if (setting->type == ST_STRING) { if ( (setting->flags & SD_FLAG_ALLOW_INPUT) || @@ -304,6 +327,8 @@ static void handle_setting(rarch_setting_t *setting, else menu_action_setting_driver(setting, action); } + + return 0; } static int menu_setting_set(unsigned id, const char *label, @@ -316,7 +341,7 @@ static int menu_setting_set(unsigned id, const char *label, ); if (setting) - handle_setting(setting, id, label, action); + return handle_setting(setting, id, label, action); else { setting = (rarch_setting_t*)get_last_setting( @@ -350,7 +375,7 @@ static int menu_setting_set(unsigned id, const char *label, } } - handle_setting(setting, id, label, action); + return handle_setting(setting, id, label, action); } else if (!strcmp(label, "video_shader_num_passes")) { diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index af50bd86da..c1bc44e483 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -18,7 +18,7 @@ #include "menu_input_line_cb.h" #include "menu_action.h" -void menu_action_setting_boolean( +int menu_action_setting_boolean( rarch_setting_t *setting, unsigned action) { if ( @@ -55,9 +55,14 @@ void menu_action_setting_boolean( if (setting->change_handler) setting->change_handler(setting); + + if (setting->flags & SD_FLAG_EXIT) + return -1; + + return 0; } -void menu_action_setting_unsigned_integer( +int menu_action_setting_unsigned_integer( rarch_setting_t *setting, unsigned id, unsigned action) { if (id == MENU_FILE_LINEFEED) @@ -106,9 +111,14 @@ void menu_action_setting_unsigned_integer( if (setting->change_handler) setting->change_handler(setting); + + if (setting->flags & SD_FLAG_EXIT) + return -1; + + return 0; } -void menu_action_setting_fraction( +int menu_action_setting_fraction( rarch_setting_t *setting, unsigned action) { if (!strcmp(setting->name, "video_refresh_rate_auto")) @@ -188,6 +198,11 @@ void menu_action_setting_fraction( if (setting->change_handler) setting->change_handler(setting); + + if (setting->flags & SD_FLAG_EXIT) + return -1; + + return 0; } void menu_action_setting_driver( diff --git a/frontend/menu/menu_action.h b/frontend/menu/menu_action.h index 97f7ac4b49..b48e215e3b 100644 --- a/frontend/menu/menu_action.h +++ b/frontend/menu/menu_action.h @@ -19,13 +19,13 @@ #include "../../settings_data.h" -void menu_action_setting_boolean( +int menu_action_setting_boolean( rarch_setting_t *setting, unsigned action); -void menu_action_setting_fraction( +int menu_action_setting_fraction( rarch_setting_t *setting, unsigned action); -void menu_action_setting_unsigned_integer( +int menu_action_setting_unsigned_integer( rarch_setting_t *setting, unsigned id, unsigned action); void menu_action_setting_driver( diff --git a/settings_data.c b/settings_data.c index 73dd829351..ae77b3ca8d 100644 --- a/settings_data.c +++ b/settings_data.c @@ -2375,11 +2375,11 @@ rarch_setting_t *setting_data_get_mainmenu(bool regenerate) } if (g_extern.main_is_init && !g_extern.libretro_dummy) { - CONFIG_BOOL(lists[9], "savestate", "Save State", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) - CONFIG_BOOL(lists[10], "loadstate", "Load State", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) + CONFIG_BOOL(lists[9], "savestate", "Save State", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_EXIT) + CONFIG_BOOL(lists[10], "loadstate", "Load State", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_EXIT) CONFIG_BOOL(lists[11], "take_screenshot", "Take Screenshot", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) - CONFIG_BOOL(lists[12], "resume_content", "Resume Content", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) - CONFIG_BOOL(lists[13], "restart_content", "Restart Content", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) + CONFIG_BOOL(lists[12], "resume_content", "Resume Content", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) WITH_FLAGS(SD_FLAG_EXIT) + CONFIG_BOOL(lists[13], "restart_content", "Restart Content", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) WITH_FLAGS(SD_FLAG_EXIT) } #ifndef HAVE_DYNAMIC CONFIG_BOOL(lists[14], "restart_retroarch", "Restart RetroArch", false, "", "",GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) diff --git a/settings_data.h b/settings_data.h index b1e1fb7222..c74a8a40a1 100644 --- a/settings_data.h +++ b/settings_data.h @@ -55,6 +55,7 @@ enum setting_flags SD_FLAG_ALLOW_INPUT = (1 << 5), SD_FLAG_PUSH_ACTION = (1 << 6), SD_FLAG_IS_DRIVER = (1 << 7), + SD_FLAG_EXIT = (1 << 8), }; typedef struct rarch_setting_t From af36280c792106297060160fac595535e5bfbb46 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sun, 14 Sep 2014 22:41:44 +0200 Subject: [PATCH 03/28] (Menu) Buildfix for prototypes --- frontend/menu/menu_input_line_cb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/menu/menu_input_line_cb.c b/frontend/menu/menu_input_line_cb.c index 77ceb43a20..1ec46d0fc4 100644 --- a/frontend/menu/menu_input_line_cb.c +++ b/frontend/menu/menu_input_line_cb.c @@ -30,9 +30,9 @@ #include "../../settings_data.h" /* forward decls */ -void menu_common_setting_set_current_string(rarch_setting_t *setting, +int menu_common_setting_set_current_string(rarch_setting_t *setting, const char *str); -void menu_common_set_current_string_based_on_label( +int menu_common_set_current_string_based_on_label( const char *label, const char *str); void menu_key_start_line(void *data, const char *label, From ef4b720c74495fdd39a1db91cc00e9c095005807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Higor=20Eur=C3=ADpedes?= Date: Sun, 14 Sep 2014 17:49:51 -0300 Subject: [PATCH 04/28] (qb) Check for windres --- qb/qb.comp.sh | 9 +++++++++ qb/qb.libs.sh | 1 + 2 files changed, 10 insertions(+) diff --git a/qb/qb.comp.sh b/qb/qb.comp.sh index b30e0524b9..72fbb7d599 100644 --- a/qb/qb.comp.sh +++ b/qb/qb.comp.sh @@ -52,3 +52,12 @@ EOF echo "$ECHOBUF ... $CXX" rm -f "$TEMP_CXX" "$TEMP_EXE" fi + +if [ "$OS" = "Win32" ]; then + ECHOBUF="Checking for windres" + if [ -z "$WINDRES" ]; then + WINDRES=$(which ${CROSS_COMPILE}windres) + [ "$WINDRES" ] || { echo "$ECHOBUF ... Not found. Exiting."; exit 1; } + fi + echo "$ECHOBUF ... $WINDRES" +fi diff --git a/qb/qb.libs.sh b/qb/qb.libs.sh index 7a5b260147..c91b54350e 100644 --- a/qb/qb.libs.sh +++ b/qb/qb.libs.sh @@ -232,6 +232,7 @@ create_config_make() echo "CXX = $CXX" echo "CXXFLAGS = $CXXFLAGS" fi + echo "WINDRES = $WINDRES" echo "ASFLAGS = $ASFLAGS" echo "LDFLAGS = $LDFLAGS" echo "INCLUDE_DIRS = $INCLUDE_DIRS" From 78da994e89fa14260226278988dc6d061df8ef45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Higor=20Eur=C3=ADpedes?= Date: Sun, 14 Sep 2014 17:50:29 -0300 Subject: [PATCH 05/28] (Makefile) Compile rarch.rc --- Makefile | 5 +++++ Makefile.common | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2ae5c408ed..b9b76837c7 100644 --- a/Makefile +++ b/Makefile @@ -155,6 +155,11 @@ $(OBJDIR)/%.o: %.S config.h config.mk $(HEADERS) @$(if $(Q), $(shell echo echo AS $<),) $(Q)$(CC) $(CFLAGS) $(ASFLAGS) $(DEFINES) -c -o $@ $< +$(OBJDIR)/%.o: %.rc $(HEADERS) + @mkdir -p $(dir $@) + @$(if $(Q), $(shell echo echo WINDRES $<),) + $(Q)$(WINDRES) -o $@ $< + install: $(TARGET) rm -f $(OBJDIR)/git_version.o mkdir -p $(DESTDIR)$(PREFIX)/bin 2>/dev/null || /bin/true diff --git a/Makefile.common b/Makefile.common index ea67169a93..0e1dc9ad3f 100644 --- a/Makefile.common +++ b/Makefile.common @@ -584,8 +584,8 @@ ifeq ($(HAVE_NETPLAY), 1) endif ifneq ($(findstring Win32,$(OS)),) -OBJ += media/rarch.o \ - gfx/context/win32_common.o + OBJ += media/rarch.o \ + gfx/context/win32_common.o endif # Record From 899e69f921e2ab218d4a7fb7e1f409b8f6926c9a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 14 Sep 2014 23:44:14 +0200 Subject: [PATCH 06/28] (Settings/menu) Add WITH_CMD to settings_data.c --- frontend/menu/backend/menu_common_backend.c | 27 ++++- frontend/menu/menu_action.c | 39 ++++++- settings_data.c | 116 ++++++-------------- settings_data.h | 18 ++- 4 files changed, 100 insertions(+), 100 deletions(-) diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index 1050024c3b..7c4d89060e 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -226,6 +226,9 @@ static int menu_common_setting_set_current_path_selection( menu_entries_push(driver.menu->menu_stack, start_path, label, type, driver.menu->selection_ptr); + + if (setting->cmd_trigger.idx != RARCH_CMD_NONE) + setting->cmd_trigger.triggered = true; break; case MENU_ACTION_START: *setting->value.string = '\0'; @@ -235,8 +238,12 @@ static int menu_common_setting_set_current_path_selection( if (setting->change_handler) setting->change_handler(setting); - if (setting->flags & SD_FLAG_EXIT) + if (setting->flags & SD_FLAG_EXIT + && setting->cmd_trigger.triggered) + { + setting->cmd_trigger.triggered = false; return -1; + } return 0; } @@ -249,8 +256,12 @@ static int menu_common_setting_set_current_string_path( if (setting->change_handler) setting->change_handler(setting); - if (setting->flags & SD_FLAG_EXIT) + if (setting->flags & SD_FLAG_EXIT + && setting->cmd_trigger.triggered) + { + setting->cmd_trigger.triggered = false; return -1; + } return 0; } @@ -278,8 +289,12 @@ int menu_common_setting_set_current_string( if (setting->change_handler) setting->change_handler(setting); - if (setting->flags & SD_FLAG_EXIT) + if (setting->flags & SD_FLAG_EXIT + && setting->cmd_trigger.triggered) + { + setting->cmd_trigger.triggered = false; return -1; + } return 0; } @@ -306,8 +321,12 @@ static int handle_setting(rarch_setting_t *setting, if (setting->change_handler) setting->change_handler(setting); - if (setting->flags & SD_FLAG_EXIT) + if (setting->flags & SD_FLAG_EXIT + && setting->cmd_trigger.triggered) + { + setting->cmd_trigger.triggered = false; return -1; + } } return 0; } diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index c1bc44e483..c38d35f9c1 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -36,13 +36,21 @@ int menu_action_setting_boolean( else if (action == MENU_ACTION_RIGHT) g_settings.state_slot++; else if (action == MENU_ACTION_OK) + { *setting->value.boolean = !(*setting->value.boolean); + + if (setting->cmd_trigger.idx != RARCH_CMD_NONE) + setting->cmd_trigger.triggered = true; + } } else { switch (action) { case MENU_ACTION_OK: + if (setting->cmd_trigger.idx != RARCH_CMD_NONE) + setting->cmd_trigger.triggered = true; + /* fall-through */ case MENU_ACTION_LEFT: case MENU_ACTION_RIGHT: *setting->value.boolean = !(*setting->value.boolean); @@ -56,8 +64,12 @@ int menu_action_setting_boolean( if (setting->change_handler) setting->change_handler(setting); - if (setting->flags & SD_FLAG_EXIT) + if (setting->flags & SD_FLAG_EXIT + && setting->cmd_trigger.triggered) + { + setting->cmd_trigger.triggered = false; return -1; + } return 0; } @@ -90,8 +102,11 @@ int menu_action_setting_unsigned_integer( } break; - case MENU_ACTION_RIGHT: case MENU_ACTION_OK: + if (setting->cmd_trigger.idx != RARCH_CMD_NONE) + setting->cmd_trigger.triggered = true; + /* fall-through */ + case MENU_ACTION_RIGHT: *setting->value.unsigned_integer = *setting->value.unsigned_integer + setting->step; @@ -112,8 +127,12 @@ int menu_action_setting_unsigned_integer( if (setting->change_handler) setting->change_handler(setting); - if (setting->flags & SD_FLAG_EXIT) + if (setting->flags & SD_FLAG_EXIT + && setting->cmd_trigger.triggered) + { + setting->cmd_trigger.triggered = false; return -1; + } return 0; } @@ -137,6 +156,9 @@ int menu_action_setting_fraction( /* Incase refresh rate update forced non-block video. */ rarch_main_command(RARCH_CMD_VIDEO_SET_BLOCKING_STATE); } + + if (setting->cmd_trigger.idx != RARCH_CMD_NONE) + setting->cmd_trigger.triggered = true; } } else if (!strcmp(setting->name, "fastforward_ratio")) @@ -178,8 +200,11 @@ int menu_action_setting_fraction( } break; - case MENU_ACTION_RIGHT: case MENU_ACTION_OK: + if (setting->cmd_trigger.idx != RARCH_CMD_NONE) + setting->cmd_trigger.triggered = true; + /* fall-through */ + case MENU_ACTION_RIGHT: *setting->value.fraction = *setting->value.fraction + setting->step; @@ -199,8 +224,12 @@ int menu_action_setting_fraction( if (setting->change_handler) setting->change_handler(setting); - if (setting->flags & SD_FLAG_EXIT) + if (setting->flags & SD_FLAG_EXIT + && setting->cmd_trigger.triggered) + { + setting->cmd_trigger.triggered = false; return -1; + } return 0; } diff --git a/settings_data.c b/settings_data.c index ae77b3ca8d..8bd3a674d7 100644 --- a/settings_data.c +++ b/settings_data.c @@ -39,7 +39,7 @@ #endif static void get_input_config_prefix(char *buf, size_t sizeof_buf, - const rarch_setting_t *setting) + rarch_setting_t *setting) { if (!buf) { @@ -58,7 +58,7 @@ static void get_input_config_prefix(char *buf, size_t sizeof_buf, } static void get_input_config_key(char *buf, size_t sizeof_buf, - const rarch_setting_t* setting, const char* type) + rarch_setting_t* setting, const char* type) { char prefix[32]; @@ -83,7 +83,7 @@ static void get_input_config_key(char *buf, size_t sizeof_buf, /* FIXME - make portable */ static void get_key_name(char *buf, size_t sizeof_buf, - const rarch_setting_t* setting) + rarch_setting_t* setting) { uint32_t hidkey, i; @@ -116,7 +116,7 @@ static void get_key_name(char *buf, size_t sizeof_buf, #endif static void get_button_name(char *buf, size_t sizeof_buf, - const rarch_setting_t* setting) + rarch_setting_t* setting) { if (!buf) { @@ -138,7 +138,7 @@ static void get_button_name(char *buf, size_t sizeof_buf, } static void get_axis_name(char *buf, size_t sizeof_buf, - const rarch_setting_t* setting) + rarch_setting_t* setting) { uint32_t joyaxis; @@ -162,7 +162,7 @@ static void get_axis_name(char *buf, size_t sizeof_buf, snprintf(buf, sizeof_buf, "+%u", AXIS_POS_GET(joyaxis)); } -void setting_data_reset_setting(const rarch_setting_t* setting) +void setting_data_reset_setting(rarch_setting_t* setting) { if (!setting) { @@ -219,14 +219,14 @@ void setting_data_reset_setting(const rarch_setting_t* setting) setting->change_handler(setting); } -void setting_data_reset(const rarch_setting_t* settings) +void setting_data_reset(rarch_setting_t* settings) { for (; settings->type != ST_NONE; settings++) setting_data_reset_setting(settings); } static bool setting_data_load_config( - const rarch_setting_t* settings, config_file_t* config) + rarch_setting_t* settings, config_file_t* config) { if (!settings || !config) return false; @@ -318,7 +318,7 @@ static bool setting_data_load_config( return true; } -bool setting_data_load_config_path(const rarch_setting_t* settings, +bool setting_data_load_config_path(rarch_setting_t* settings, const char* path) { config_file_t *config = (config_file_t*)config_file_new(path); @@ -332,7 +332,7 @@ bool setting_data_load_config_path(const rarch_setting_t* settings, return config; } -bool setting_data_save_config(const rarch_setting_t* settings, +bool setting_data_save_config(rarch_setting_t* settings, config_file_t* config) { if (!settings || !config) @@ -459,7 +459,7 @@ rarch_setting_t* setting_data_find_setting(rarch_setting_t* setting, return setting; } -void setting_data_set_with_string_representation(const rarch_setting_t* setting, +void setting_data_set_with_string_representation(rarch_setting_t* setting, const char* value) { if (!setting || !value) @@ -2005,9 +2005,9 @@ void setting_data_get_label(char *type_str, } } -static void general_read_handler(const void *data) +static void general_read_handler(void *data) { - const rarch_setting_t *setting = (const rarch_setting_t*)data; + rarch_setting_t *setting = (rarch_setting_t*)data; if (!setting) return; @@ -2040,63 +2040,23 @@ static void general_read_handler(const void *data) *setting->value.integer = g_settings.input.joypad_map[4]; } -static void general_write_handler(const void *data) +static void general_write_handler(void *data) { unsigned rarch_cmd = RARCH_CMD_NONE; - const rarch_setting_t *setting = (const rarch_setting_t*)data; + rarch_setting_t *setting = (rarch_setting_t*)data; if (!setting) return; - if (!strcmp(setting->name, "quit_retroarch")) + if (setting->cmd_trigger.idx != RARCH_CMD_NONE) { if (*setting->value.boolean) - { - rarch_cmd = RARCH_CMD_QUIT_RETROARCH; *setting->value.boolean = false; - } + if (setting->cmd_trigger.triggered) + rarch_cmd = setting->cmd_trigger.idx; } - else if (!strcmp(setting->name, "save_new_config")) - { - if (*setting->value.boolean) - { - rarch_cmd = RARCH_CMD_MENU_SAVE_CONFIG; - *setting->value.boolean = false; - } - } - else if (!strcmp(setting->name, "restart_retroarch")) - { - if (*setting->value.boolean) - { - rarch_cmd = RARCH_CMD_RESTART_RETROARCH; - *setting->value.boolean = false; - } - } - else if (!strcmp(setting->name, "resume_content")) - { - if (*setting->value.boolean) - { - rarch_cmd = RARCH_CMD_RESUME; - *setting->value.boolean = false; - } - } - else if (!strcmp(setting->name, "restart_content")) - { - if (*setting->value.boolean) - { - rarch_cmd = RARCH_CMD_RESET; - *setting->value.boolean = false; - } - } - else if (!strcmp(setting->name, "take_screenshot")) - { - if (*setting->value.boolean) - { - rarch_cmd = RARCH_CMD_TAKE_SCREENSHOT; - *setting->value.boolean = false; - } - } - else if (!strcmp(setting->name, "help")) + + if (!strcmp(setting->name, "help")) { if (*setting->value.boolean) { @@ -2182,22 +2142,6 @@ static void general_write_handler(const void *data) g_settings.audio.rate_control_delta = *setting->value.fraction; } } - else if (!strcmp(setting->name, "savestate")) - { - if (*setting->value.boolean) - { - rarch_cmd = RARCH_CMD_SAVE_STATE; - *setting->value.boolean = false; - } - } - else if (!strcmp(setting->name, "loadstate")) - { - if (*setting->value.boolean) - { - rarch_cmd = RARCH_CMD_LOAD_STATE; - *setting->value.boolean = false; - } - } else if (!strcmp(setting->name, "autosave_interval")) rarch_cmd = RARCH_CMD_AUTOSAVE; #ifdef HAVE_OVERLAY @@ -2264,7 +2208,7 @@ static void general_write_handler(const void *data) g_extern.has_set_verbosity = *setting->value.boolean; } - if (rarch_cmd) + if (rarch_cmd || setting->cmd_trigger.triggered) rarch_main_command(rarch_cmd); } @@ -2317,6 +2261,8 @@ static void general_write_handler(const void *data) #define WITH_VALUES(VALUES) (list[index -1]).values = VALUES; +#define WITH_CMD(VALUES) (list[index -1]).cmd_trigger.idx = VALUES; + #ifdef GEKKO #define MAX_GAMMA_SETTING 2 #else @@ -2375,19 +2321,19 @@ rarch_setting_t *setting_data_get_mainmenu(bool regenerate) } if (g_extern.main_is_init && !g_extern.libretro_dummy) { - CONFIG_BOOL(lists[9], "savestate", "Save State", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_EXIT) - CONFIG_BOOL(lists[10], "loadstate", "Load State", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_EXIT) - CONFIG_BOOL(lists[11], "take_screenshot", "Take Screenshot", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) - CONFIG_BOOL(lists[12], "resume_content", "Resume Content", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) WITH_FLAGS(SD_FLAG_EXIT) - CONFIG_BOOL(lists[13], "restart_content", "Restart Content", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) WITH_FLAGS(SD_FLAG_EXIT) + CONFIG_BOOL(lists[9], "savestate", "Save State", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_EXIT) WITH_CMD(RARCH_CMD_SAVE_STATE) + CONFIG_BOOL(lists[10], "loadstate", "Load State", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_EXIT) WITH_CMD(RARCH_CMD_LOAD_STATE) + CONFIG_BOOL(lists[11], "take_screenshot", "Take Screenshot", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) WITH_CMD(RARCH_CMD_TAKE_SCREENSHOT) + CONFIG_BOOL(lists[12], "resume_content", "Resume Content", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) WITH_FLAGS(SD_FLAG_EXIT) WITH_CMD(RARCH_CMD_RESUME) + CONFIG_BOOL(lists[13], "restart_content", "Restart Content", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) WITH_FLAGS(SD_FLAG_EXIT) WITH_CMD(RARCH_CMD_RESET) } #ifndef HAVE_DYNAMIC - CONFIG_BOOL(lists[14], "restart_retroarch", "Restart RetroArch", false, "", "",GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) + CONFIG_BOOL(lists[14], "restart_retroarch", "Restart RetroArch", false, "", "",GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) WITH_CMD(RARCH_CMD_RESTART_RETROARCH) #endif CONFIG_BOOL(lists[15], "configurations", "Configurations", false, "", "",GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) - CONFIG_BOOL(lists[16], "save_new_config", "Save New Config", false, "", "",GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) + CONFIG_BOOL(lists[16], "save_new_config", "Save New Config", false, "", "",GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) WITH_CMD(RARCH_CMD_MENU_SAVE_CONFIG) CONFIG_BOOL(lists[17], "help", "Help", false, "", "",GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) - CONFIG_BOOL(lists[18], "quit_retroarch", "Quit RetroArch", false, "", "",GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) + CONFIG_BOOL(lists[18], "quit_retroarch", "Quit RetroArch", false, "", "",GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) WITH_CMD(RARCH_CMD_QUIT_RETROARCH) END_SUB_GROUP() END_GROUP() diff --git a/settings_data.h b/settings_data.h index c74a8a40a1..ff28ea8efc 100644 --- a/settings_data.h +++ b/settings_data.h @@ -23,7 +23,7 @@ extern "C" { #endif -typedef void (*change_handler_t)(const void *data); +typedef void (*change_handler_t)(void *data); #define BINDFOR(s) (*(&(s))->value.keybind) @@ -105,6 +105,12 @@ typedef struct rarch_setting_t const char *empty_path; } dir; + struct + { + unsigned idx; + bool triggered; + } cmd_trigger; + struct { const char *off_label; @@ -117,19 +123,19 @@ typedef struct rarch_setting_t bool enforce_maxrange; } rarch_setting_t; -void setting_data_reset_setting(const rarch_setting_t* setting); -void setting_data_reset(const rarch_setting_t* settings); +void setting_data_reset_setting(rarch_setting_t* setting); +void setting_data_reset(rarch_setting_t* settings); -bool setting_data_load_config_path(const rarch_setting_t* settings, +bool setting_data_load_config_path(rarch_setting_t* settings, const char* path); -bool setting_data_save_config(const rarch_setting_t* settings, +bool setting_data_save_config(rarch_setting_t* settings, config_file_t* config); rarch_setting_t* setting_data_find_setting(rarch_setting_t* settings, const char* name); void setting_data_set_with_string_representation( - const rarch_setting_t* setting, const char* value); + rarch_setting_t* setting, const char* value); void setting_data_get_string_representation(rarch_setting_t* setting, char* buf, size_t sizeof_buf); From 1682d83831876830708c513a5e896aafe95d6571 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Sep 2014 00:21:24 +0200 Subject: [PATCH 07/28] (Menu/Settings) Add SD_FLAG_CMD_APPLY_AUTO --- settings_data.c | 77 ++++++++++++++----------------------------------- settings_data.h | 19 ++++++------ 2 files changed, 32 insertions(+), 64 deletions(-) diff --git a/settings_data.c b/settings_data.c index 8bd3a674d7..06000777c9 100644 --- a/settings_data.c +++ b/settings_data.c @@ -2050,9 +2050,13 @@ static void general_write_handler(void *data) if (setting->cmd_trigger.idx != RARCH_CMD_NONE) { - if (*setting->value.boolean) - *setting->value.boolean = false; - if (setting->cmd_trigger.triggered) + if (setting->flags & SD_FLAG_EXIT) + { + if (*setting->value.boolean) + *setting->value.boolean = false; + } + if (setting->cmd_trigger.triggered || + (setting->flags & SD_FLAG_CMD_APPLY_AUTO)) rarch_cmd = setting->cmd_trigger.idx; } @@ -2066,13 +2070,6 @@ static void general_write_handler(void *data) *setting->value.boolean = false; } } - else if (!strcmp(setting->name, "rewind_enable")) - rarch_cmd = RARCH_CMD_REWIND; - else if (!strcmp(setting->name, "soft_filter")) - { - if (*setting->value.boolean) - rarch_cmd = RARCH_CMD_VIDEO_APPLY_STATE_CHANGES; - } else if (!strcmp(setting->name, "video_smooth")) { if (driver.video_data && driver.video_poke @@ -2087,12 +2084,6 @@ static void general_write_handler(void *data) else *setting->value.boolean = false; } - else if (!strcmp(setting->name, "video_monitor_index")) - rarch_cmd = RARCH_CMD_REINIT; - else if (!strcmp(setting->name, "video_disable_composition")) - rarch_cmd = RARCH_CMD_REINIT; - else if (!strcmp(setting->name, "video_fullscreen")) - rarch_cmd = RARCH_CMD_REINIT; else if (!strcmp(setting->name, "video_rotation")) { if (driver.video && driver.video->set_rotation) @@ -2100,16 +2091,6 @@ static void general_write_handler(void *data) (*setting->value.unsigned_integer + g_extern.system.rotation) % 4); } - else if (!strcmp(setting->name, "video_gamma")) - rarch_cmd = RARCH_CMD_VIDEO_APPLY_STATE_CHANGES; - else if (!strcmp(setting->name, "video_threaded")) - rarch_cmd = RARCH_CMD_REINIT; - else if (!strcmp(setting->name, "video_swap_interval")) - rarch_cmd = RARCH_CMD_VIDEO_SET_BLOCKING_STATE; -#ifdef HAVE_OVERLAY - else if (!strcmp(setting->name, "input_overlay_opacity")) - rarch_cmd = RARCH_CMD_OVERLAY_SET_ALPHA_MOD; -#endif else if (!strcmp(setting->name, "system_bgm_enable")) { if (*setting->value.boolean) @@ -2127,8 +2108,6 @@ static void general_write_handler(void *data) } else if (!strcmp(setting->name, "audio_volume")) g_extern.audio_data.volume_gain = db_to_gain(*setting->value.fraction); - else if (!strcmp(setting->name, "audio_dsp_plugin")) - rarch_cmd = RARCH_CMD_DSP_FILTER_INIT; else if (!strcmp(setting->name, "audio_rate_control_delta")) { if (*setting->value.fraction < 0.0005) @@ -2142,14 +2121,6 @@ static void general_write_handler(void *data) g_settings.audio.rate_control_delta = *setting->value.fraction; } } - else if (!strcmp(setting->name, "autosave_interval")) - rarch_cmd = RARCH_CMD_AUTOSAVE; -#ifdef HAVE_OVERLAY - else if (!strcmp(setting->name, "input_overlay")) - rarch_cmd = RARCH_CMD_OVERLAY_REINIT; - else if (!strcmp(setting->name, "input_overlay_scale")) - rarch_cmd = RARCH_CMD_OVERLAY_SET_SCALE_FACTOR; -#endif else if (!strcmp(setting->name, "video_refresh_rate_auto")) { if (driver.video && driver.video_data) @@ -2167,8 +2138,6 @@ static void general_write_handler(void *data) if (!g_settings.video.fullscreen) rarch_cmd = RARCH_CMD_REINIT; } - else if (!strcmp(setting->name, "aspect_ratio_index")) - rarch_cmd = RARCH_CMD_VIDEO_SET_ASPECT_RATIO; else if (!strcmp(setting->name, "input_player1_joypad_index")) g_settings.input.joypad_map[0] = *setting->value.integer; else if (!strcmp(setting->name, "input_player2_joypad_index")) @@ -2183,8 +2152,6 @@ static void general_write_handler(void *data) rarch_cmd = RARCH_CMD_CORE_INFO_INIT; else if (!strcmp(setting->name, "libretro_dir_path")) rarch_cmd = RARCH_CMD_CORE_INFO_INIT; - else if (!strcmp(setting->name, "video_filter")) - rarch_cmd = RARCH_CMD_REINIT; #ifdef HAVE_NETPLAY else if (!strcmp(setting->name, "netplay_ip_address")) g_extern.has_set_netplay_ip_address = (setting->value.string[0] != '\0'); @@ -2405,16 +2372,16 @@ rarch_setting_t *setting_data_get_list(void) CONFIG_BOOL(g_settings.core_specific_config, "core_specific_config", "Configuration Per-Core", default_core_specific_config, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) CONFIG_BOOL(g_settings.load_dummy_on_core_shutdown, "dummy_on_core_shutdown", "Dummy On Core Shutdown", load_dummy_on_core_shutdown, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) CONFIG_BOOL(g_settings.fps_show, "fps_show", "Show Framerate", fps_show, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) - CONFIG_BOOL(g_settings.rewind_enable, "rewind_enable", "Rewind", rewind_enable, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) + CONFIG_BOOL(g_settings.rewind_enable, "rewind_enable", "Rewind", rewind_enable, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_CMD(RARCH_CMD_REWIND) WITH_FLAGS(SD_FLAG_CMD_APPLY_AUTO) #if 0 CONFIG_SIZE(g_settings.rewind_buffer_size, "rewind_buffer_size", "Rewind Buffer Size", rewind_buffer_size, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) #endif CONFIG_UINT(g_settings.rewind_granularity, "rewind_granularity", "Rewind Granularity", rewind_granularity, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(1, 32768, 1, true, false) CONFIG_BOOL(g_settings.block_sram_overwrite, "block_sram_overwrite", "SRAM Block overwrite", block_sram_overwrite, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) #ifdef HAVE_THREADS - CONFIG_UINT(g_settings.autosave_interval, "autosave_interval", "SRAM Autosave", autosave_interval, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, 0, 10, true, false) + CONFIG_UINT(g_settings.autosave_interval, "autosave_interval", "SRAM Autosave", autosave_interval, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, 0, 10, true, false) WITH_CMD(RARCH_CMD_AUTOSAVE) WITH_FLAGS(SD_FLAG_CMD_APPLY_AUTO) #endif - CONFIG_BOOL(g_settings.video.disable_composition, "video_disable_composition", "Window Compositing Disable", disable_composition, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) + CONFIG_BOOL(g_settings.video.disable_composition, "video_disable_composition", "Window Compositing Disable", disable_composition, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_CMD(RARCH_CMD_REINIT) WITH_FLAGS(SD_FLAG_CMD_APPLY_AUTO) CONFIG_BOOL(g_settings.pause_nonactive, "pause_nonactive", "Window Unfocus Pause", pause_nonactive, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) CONFIG_FLOAT(g_settings.fastforward_ratio, "fastforward_ratio", "Maximum Run Speed", fastforward_ratio, "%.1fx", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, 10, 0.1, true, true) CONFIG_FLOAT(g_settings.slowmotion_ratio, "slowmotion_ratio", "Slow-Motion Ratio", slowmotion_ratio, "%.1fx", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(1, 10, 1.0, true, true) @@ -2439,9 +2406,9 @@ rarch_setting_t *setting_data_get_list(void) CONFIG_BOOL(g_settings.video.shared_context, "video_shared_context", "HW Shared Context Enable", false, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) END_SUB_GROUP() START_SUB_GROUP("Monitor", GROUP_NAME) - CONFIG_UINT(g_settings.video.monitor_index, "video_monitor_index", "Monitor Index", monitor_index, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, 1, 1, true, false) + CONFIG_UINT(g_settings.video.monitor_index, "video_monitor_index", "Monitor Index", monitor_index, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, 1, 1, true, false) WITH_CMD(RARCH_CMD_REINIT) #if !defined(RARCH_CONSOLE) && !defined(RARCH_MOBILE) - CONFIG_BOOL(g_settings.video.fullscreen, "video_fullscreen", "Use Fullscreen mode", fullscreen, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) + CONFIG_BOOL(g_settings.video.fullscreen, "video_fullscreen", "Use Fullscreen mode", fullscreen, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_CMD(RARCH_CMD_REINIT) WITH_FLAGS(SD_FLAG_CMD_APPLY_AUTO) #endif CONFIG_BOOL(g_settings.video.windowed_fullscreen, "video_windowed_fullscreen", "Windowed Fullscreen Mode", windowed_fullscreen, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) CONFIG_UINT(g_settings.video.fullscreen_x, "video_fullscreen_x", "Fullscreen Width", fullscreen_x, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) @@ -2454,7 +2421,7 @@ rarch_setting_t *setting_data_get_list(void) CONFIG_BOOL(g_settings.video.force_aspect, "video_force_aspect", "Force aspect ratio", force_aspect, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) CONFIG_FLOAT(g_settings.video.aspect_ratio, "video_aspect_ratio", "Aspect Ratio", aspect_ratio, "%.2f", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) CONFIG_BOOL(g_settings.video.aspect_ratio_auto, "video_aspect_ratio_auto", "Use Auto Aspect Ratio", aspect_ratio_auto, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) - CONFIG_UINT(g_settings.video.aspect_ratio_idx, "aspect_ratio_index", "Aspect Ratio Index", aspect_ratio_idx, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, LAST_ASPECT_RATIO, 1, true, true) + CONFIG_UINT(g_settings.video.aspect_ratio_idx, "aspect_ratio_index", "Aspect Ratio Index", aspect_ratio_idx, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, LAST_ASPECT_RATIO, 1, true, true) WITH_CMD(RARCH_CMD_VIDEO_SET_ASPECT_RATIO) WITH_FLAGS(SD_FLAG_CMD_APPLY_AUTO) END_SUB_GROUP() START_SUB_GROUP("Scaling", GROUP_NAME) @@ -2476,17 +2443,17 @@ rarch_setting_t *setting_data_get_list(void) #endif CONFIG_UINT(g_settings.video.rotation, "video_rotation", "Rotation", 0, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, 3, 1, true, true) #if defined(HW_RVL) || defined(_XBOX360) - CONFIG_UINT(g_extern.console.screen.gamma_correction, "video_gamma", "Gamma", 0, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, MAX_GAMMA_SETTING, 1, true, true) + CONFIG_UINT(g_extern.console.screen.gamma_correction, "video_gamma", "Gamma", 0, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, MAX_GAMMA_SETTING, 1, true, true) WITH_CMD(RARCH_CMD_VIDEO_APPLY_STATE_CHANGES) WITH_FLAGS(SD_FLAG_CMD_APPLY_AUTO) #endif END_SUB_GROUP() START_SUB_GROUP("Synchronization", GROUP_NAME) #if defined(HAVE_THREADS) && !defined(RARCH_CONSOLE) - CONFIG_BOOL(g_settings.video.threaded, "video_threaded", "Threaded Video", video_threaded, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) + CONFIG_BOOL(g_settings.video.threaded, "video_threaded", "Threaded Video", video_threaded, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_CMD(RARCH_CMD_REINIT) WITH_FLAGS(SD_FLAG_CMD_APPLY_AUTO) #endif CONFIG_BOOL(g_settings.video.vsync, "video_vsync", "VSync", vsync, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) - CONFIG_UINT(g_settings.video.swap_interval, "video_swap_interval", "VSync Swap Interval", swap_interval, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(1, 4, 1, true, true) + CONFIG_UINT(g_settings.video.swap_interval, "video_swap_interval", "VSync Swap Interval", swap_interval, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(1, 4, 1, true, true) WITH_CMD(RARCH_CMD_VIDEO_SET_BLOCKING_STATE) WITH_FLAGS(SD_FLAG_CMD_APPLY_AUTO) CONFIG_BOOL(g_settings.video.hard_sync, "video_hard_sync", "Hard GPU Sync", hard_sync, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) CONFIG_UINT(g_settings.video.hard_sync_frames, "video_hard_sync_frames", "Hard GPU Sync Frames", hard_sync_frames, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, 3, 1, true, true) CONFIG_UINT(g_settings.video.frame_delay, "video_frame_delay", "Frame Delay", frame_delay, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, 15, 1, true, true) @@ -2502,10 +2469,10 @@ rarch_setting_t *setting_data_get_list(void) CONFIG_BOOL(g_settings.video.allow_rotate, "video_allow_rotate", "Allow rotation", allow_rotate, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) CONFIG_BOOL(g_settings.video.crop_overscan, "video_crop_overscan", "Crop Overscan (reload)", crop_overscan, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) #ifndef HAVE_FILTERS_BUILTIN - CONFIG_PATH(g_settings.video.softfilter_plugin, "video_filter", "Software filter", g_settings.video.filter_dir, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) WITH_VALUES("filt") + CONFIG_PATH(g_settings.video.softfilter_plugin, "video_filter", "Software filter", g_settings.video.filter_dir, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) WITH_VALUES("filt") WITH_CMD(RARCH_CMD_REINIT) #endif #if defined(_XBOX1) || defined(HW_RVL) - CONFIG_BOOL(g_extern.console.softfilter_enable, "soft_filter", "Soft Filter Enable", false, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) + CONFIG_BOOL(g_extern.console.softfilter_enable, "soft_filter", "Soft Filter Enable", false, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_CMD(RARCH_CMD_VIDEO_APPLY_STATE_CHANGES) #endif #ifdef _XBOX1 CONFIG_UINT(g_settings.video.swap_interval, "video_filter_flicker", "Flicker filter", 0, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, 5, 1, true, true) @@ -2552,7 +2519,7 @@ rarch_setting_t *setting_data_get_list(void) START_SUB_GROUP("Miscellaneous", GROUP_NAME) CONFIG_STRING(g_settings.audio.device, "audio_device", "Device", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_INPUT) CONFIG_UINT(g_settings.audio.out_rate, "audio_out_rate", "Audio Output Rate", out_rate, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) - CONFIG_PATH(g_settings.audio.dsp_plugin, "audio_dsp_plugin", "DSP Plugin", g_settings.audio.filter_dir, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) WITH_VALUES("dsp") + CONFIG_PATH(g_settings.audio.dsp_plugin, "audio_dsp_plugin", "DSP Plugin", g_settings.audio.filter_dir, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) WITH_VALUES("dsp") WITH_CMD(RARCH_CMD_DSP_FILTER_INIT) END_SUB_GROUP() END_GROUP() @@ -2623,9 +2590,9 @@ rarch_setting_t *setting_data_get_list(void) #ifdef HAVE_OVERLAY START_GROUP("Overlay Options") START_SUB_GROUP("State", GROUP_NAME) - CONFIG_PATH(g_settings.input.overlay, "input_overlay", "Overlay Preset", g_extern.overlay_dir, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) WITH_VALUES("cfg") - CONFIG_FLOAT(g_settings.input.overlay_opacity, "input_overlay_opacity", "Overlay Opacity", 0.7f, "%.2f", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, 1, 0.01, true, true) - CONFIG_FLOAT(g_settings.input.overlay_scale, "input_overlay_scale", "Overlay Scale", 1.0f, "%.2f", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, 2, 0.01, true, true) + CONFIG_PATH(g_settings.input.overlay, "input_overlay", "Overlay Preset", g_extern.overlay_dir, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) WITH_VALUES("cfg") WITH_CMD(RARCH_CMD_OVERLAY_REINIT) + CONFIG_FLOAT(g_settings.input.overlay_opacity, "input_overlay_opacity", "Overlay Opacity", 0.7f, "%.2f", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, 1, 0.01, true, true) WITH_CMD(RARCH_CMD_OVERLAY_SET_ALPHA_MOD) WITH_FLAGS(SD_FLAG_CMD_APPLY_AUTO) + CONFIG_FLOAT(g_settings.input.overlay_scale, "input_overlay_scale", "Overlay Scale", 1.0f, "%.2f", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, 2, 0.01, true, true) WITH_CMD(RARCH_CMD_OVERLAY_SET_SCALE_FACTOR) WITH_FLAGS(SD_FLAG_CMD_APPLY_AUTO) END_SUB_GROUP() END_GROUP() #endif diff --git a/settings_data.h b/settings_data.h index ff28ea8efc..db36820ff1 100644 --- a/settings_data.h +++ b/settings_data.h @@ -47,15 +47,16 @@ enum setting_type enum setting_flags { - SD_FLAG_PATH_DIR = (1 << 0), - SD_FLAG_PATH_FILE = (1 << 1), - SD_FLAG_ALLOW_EMPTY = (1 << 2), - SD_FLAG_VALUE_DESC = (1 << 3), - SD_FLAG_HAS_RANGE = (1 << 4), - SD_FLAG_ALLOW_INPUT = (1 << 5), - SD_FLAG_PUSH_ACTION = (1 << 6), - SD_FLAG_IS_DRIVER = (1 << 7), - SD_FLAG_EXIT = (1 << 8), + SD_FLAG_PATH_DIR = (1 << 0), + SD_FLAG_PATH_FILE = (1 << 1), + SD_FLAG_ALLOW_EMPTY = (1 << 2), + SD_FLAG_VALUE_DESC = (1 << 3), + SD_FLAG_HAS_RANGE = (1 << 4), + SD_FLAG_ALLOW_INPUT = (1 << 5), + SD_FLAG_PUSH_ACTION = (1 << 6), + SD_FLAG_IS_DRIVER = (1 << 7), + SD_FLAG_EXIT = (1 << 8), + SD_FLAG_CMD_APPLY_AUTO = (1 << 9), }; typedef struct rarch_setting_t From 696b1cdef8216f6b84bfb1dce7a8e404334b7fc7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Sep 2014 00:34:00 +0200 Subject: [PATCH 08/28] (Menu) Refator common code into calls to menu_action_setting_apply --- frontend/menu/backend/menu_common_backend.c | 47 ++----------------- frontend/menu/menu_action.c | 51 ++++++++------------- frontend/menu/menu_action.h | 2 + 3 files changed, 24 insertions(+), 76 deletions(-) diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index 7c4d89060e..0044857894 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -235,17 +235,7 @@ static int menu_common_setting_set_current_path_selection( break; } - if (setting->change_handler) - setting->change_handler(setting); - - if (setting->flags & SD_FLAG_EXIT - && setting->cmd_trigger.triggered) - { - setting->cmd_trigger.triggered = false; - return -1; - } - - return 0; + return menu_action_setting_apply(setting); } static int menu_common_setting_set_current_string_path( @@ -253,17 +243,7 @@ static int menu_common_setting_set_current_string_path( { fill_pathname_join(setting->value.string, dir, path, setting->size); - if (setting->change_handler) - setting->change_handler(setting); - - if (setting->flags & SD_FLAG_EXIT - && setting->cmd_trigger.triggered) - { - setting->cmd_trigger.triggered = false; - return -1; - } - - return 0; + return menu_action_setting_apply(setting); } int menu_common_set_current_string_based_on_label( @@ -286,17 +266,7 @@ int menu_common_setting_set_current_string( { strlcpy(setting->value.string, str, setting->size); - if (setting->change_handler) - setting->change_handler(setting); - - if (setting->flags & SD_FLAG_EXIT - && setting->cmd_trigger.triggered) - { - setting->cmd_trigger.triggered = false; - return -1; - } - - return 0; + return menu_action_setting_apply(setting); } static int handle_setting(rarch_setting_t *setting, @@ -317,16 +287,7 @@ static int handle_setting(rarch_setting_t *setting, if (action == MENU_ACTION_START) { *setting->value.string = '\0'; - - if (setting->change_handler) - setting->change_handler(setting); - - if (setting->flags & SD_FLAG_EXIT - && setting->cmd_trigger.triggered) - { - setting->cmd_trigger.triggered = false; - return -1; - } + return menu_action_setting_apply(setting); } return 0; } diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index c38d35f9c1..c484dd14ec 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -18,6 +18,21 @@ #include "menu_input_line_cb.h" #include "menu_action.h" +int menu_action_setting_apply(rarch_setting_t *setting) +{ + if (setting->change_handler) + setting->change_handler(setting); + + if (setting->flags & SD_FLAG_EXIT + && setting->cmd_trigger.triggered) + { + setting->cmd_trigger.triggered = false; + return -1; + } + + return 0; +} + int menu_action_setting_boolean( rarch_setting_t *setting, unsigned action) { @@ -61,17 +76,7 @@ int menu_action_setting_boolean( } } - if (setting->change_handler) - setting->change_handler(setting); - - if (setting->flags & SD_FLAG_EXIT - && setting->cmd_trigger.triggered) - { - setting->cmd_trigger.triggered = false; - return -1; - } - - return 0; + return menu_action_setting_apply(setting); } int menu_action_setting_unsigned_integer( @@ -124,17 +129,7 @@ int menu_action_setting_unsigned_integer( } } - if (setting->change_handler) - setting->change_handler(setting); - - if (setting->flags & SD_FLAG_EXIT - && setting->cmd_trigger.triggered) - { - setting->cmd_trigger.triggered = false; - return -1; - } - - return 0; + return menu_action_setting_apply(setting); } int menu_action_setting_fraction( @@ -221,17 +216,7 @@ int menu_action_setting_fraction( } } - if (setting->change_handler) - setting->change_handler(setting); - - if (setting->flags & SD_FLAG_EXIT - && setting->cmd_trigger.triggered) - { - setting->cmd_trigger.triggered = false; - return -1; - } - - return 0; + return menu_action_setting_apply(setting); } void menu_action_setting_driver( diff --git a/frontend/menu/menu_action.h b/frontend/menu/menu_action.h index b48e215e3b..6fb4a8b5f0 100644 --- a/frontend/menu/menu_action.h +++ b/frontend/menu/menu_action.h @@ -19,6 +19,8 @@ #include "../../settings_data.h" +int menu_action_setting_apply(rarch_setting_t *setting); + int menu_action_setting_boolean( rarch_setting_t *setting, unsigned action); From d4f01cafdf7ddf83259700c62fefa0405263b63a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 14 Sep 2014 18:20:13 -0400 Subject: [PATCH 09/28] config_file: Guard against calloc/malloc/realloc failure cases --- conf/config_file.c | 83 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 14 deletions(-) diff --git a/conf/config_file.c b/conf/config_file.c index eda476a8b4..2f00d2aef4 100644 --- a/conf/config_file.c +++ b/conf/config_file.c @@ -63,22 +63,36 @@ struct config_file struct include_list *includes; }; -static config_file_t *config_file_new_internal(const char *path, - unsigned depth); +static config_file_t *config_file_new_internal(const char *path, unsigned depth); +void config_file_free(config_file_t *conf); static char *getaline(FILE *file) { - char *newline = (char*)malloc(9); + char* newline = (char*)malloc(9); + char* newline_tmp = NULL; size_t cur_size = 8; size_t index = 0; - int in = getc(file); + + if (!newline) + return NULL; + while (in != EOF && in != '\n') { if (index == cur_size) { cur_size *= 2; newline = (char*)realloc(newline, cur_size + 1); + + if (newline_tmp) + { + newline = newline_tmp; + } + else + { + free(newline); + return NULL; + } } newline[index++] = in; @@ -173,6 +187,10 @@ static void add_include_list(config_file_t *conf, const char *path) { struct include_list *head = conf->includes; struct include_list *node = (struct include_list*)calloc(1, sizeof(*node)); + + if (!node) + return; + node->path = strdup(path); if (head) @@ -267,10 +285,19 @@ static char *strip_comment(char *str) static bool parse_line(config_file_t *conf, struct config_entry_list *list, char *line) { - if (!*line) + char* comment = NULL; + char* key = (char*)malloc(9); + char* key_tmp = NULL; + size_t cur_size = 8; + size_t index = 0; + + if (!line || !*line) return false; - char *comment = strip_comment(line); + if (!key) + return false; + + comment = strip_comment(line); /* Starting line with # and include includes config files. */ if ((comment == line) && (conf->include_depth < MAX_INCLUDE_DEPTH)) @@ -283,22 +310,30 @@ static bool parse_line(config_file_t *conf, } } else if (conf->include_depth >= MAX_INCLUDE_DEPTH) + { fprintf(stderr, "!!! #include depth exceeded for config. Might be a cycle.\n"); + } /* Skips to first character. */ while (isspace(*line)) line++; - char *key = (char*)malloc(9); - size_t cur_size = 8; - size_t index = 0; - while (isgraph(*line)) { if (index == cur_size) { cur_size *= 2; - key = (char*)realloc(key, cur_size + 1); + key_tmp = (char*)realloc(key, cur_size + 1); + + if (key_tmp) + { + key = key_tmp; + } + else + { + free(key); + return false; + } } key[index++] = *line++; @@ -365,7 +400,16 @@ static config_file_t *config_file_new_internal( { struct config_entry_list *list = (struct config_entry_list*) calloc(1, sizeof(*list)); - char *line = getaline(file); + char *line = NULL; + + if (!list) + { + config_file_free(conf); + fclose(file); + return NULL; + } + + line = getaline(file); if (line) { @@ -375,6 +419,7 @@ static config_file_t *config_file_new_internal( conf->tail->next = list; else conf->entries = list; + conf->tail = list; } @@ -410,9 +455,14 @@ config_file_t *config_file_new_from_string(const char *from_string) { struct config_entry_list *list = (struct config_entry_list*) calloc(1, sizeof(*list)); - char* line = lines->elems[i].data; - + + if (!list) + { + config_file_free(conf); + return NULL; + } + if (line) { if (parse_line(conf, list, line)) @@ -421,6 +471,7 @@ config_file_t *config_file_new_from_string(const char *from_string) conf->tail->next = list; else conf->entries = list; + conf->tail = list; } } @@ -703,6 +754,10 @@ void config_set_string(config_file_t *conf, const char *key, const char *val) struct config_entry_list *elem = (struct config_entry_list*) calloc(1, sizeof(*elem)); + + if (!elem) + return; + elem->key = strdup(key); elem->value = strdup(val); From b4de99c318f59d133eb8641a908560e088036fef Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 15 Sep 2014 00:51:57 +0200 Subject: [PATCH 10/28] (OSX) Cleanups --- apple/OSX/settings.m | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/apple/OSX/settings.m b/apple/OSX/settings.m index 0b2fd68b8c..fb8bb1394f 100644 --- a/apple/OSX/settings.m +++ b/apple/OSX/settings.m @@ -304,10 +304,8 @@ NSWindowDelegate> if ([item isKindOfClass:[NSNumber class]]) { - const rarch_setting_t *setting_data, *setting; - - setting_data = (const rarch_setting_t*)setting_data_get_list(); - setting = (const rarch_setting_t*)&setting_data[[item intValue]]; + rarch_setting_t *setting_data = (rarch_setting_t*)setting_data_get_list(); + rarch_setting_t *setting = (rarch_setting_t*)&setting_data[[item intValue]]; switch (setting->type) { @@ -336,12 +334,9 @@ NSWindowDelegate> if ([item isKindOfClass:[NSNumber class]]) { - NSString *editor_string; - const rarch_setting_t *setting_data, *setting; - - setting_data = (const rarch_setting_t *)setting_data_get_list(); - setting = (const rarch_setting_t*)&setting_data[[item intValue]]; - editor_string = (NSString*)editor.string; + rarch_setting_t *setting_data = (rarch_setting_t *)setting_data_get_list(); + rarch_setting_t *setting = (rarch_setting_t*)&setting_data[[item intValue]]; + NSString *editor_string = (NSString*)editor.string; setting_data_set_with_string_representation(setting, editor_string.UTF8String); } From 416307fcd321956b0c66c6e711cec1cbcb0d8f37 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 15 Sep 2014 01:34:58 +0200 Subject: [PATCH 11/28] (OSX) Add GLUI to OSX solution --- apple/OSX/OSX/RetroArch_OSX.xcodeproj/project.pbxproj | 2 ++ frontend/menu/disp/glui.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/apple/OSX/OSX/RetroArch_OSX.xcodeproj/project.pbxproj b/apple/OSX/OSX/RetroArch_OSX.xcodeproj/project.pbxproj index 647e2f8995..70bdb15714 100644 --- a/apple/OSX/OSX/RetroArch_OSX.xcodeproj/project.pbxproj +++ b/apple/OSX/OSX/RetroArch_OSX.xcodeproj/project.pbxproj @@ -351,6 +351,7 @@ "-DHAVE_CG", "-DHAVE_7ZIP", "-DHAVE_LAKKA", + "-DHAVE_GLUI", ); PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; @@ -419,6 +420,7 @@ "-DHAVE_CG", "-DHAVE_7ZIP", "-DHAVE_LAKKA", + "-DHAVE_GLUI", ); PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; diff --git a/frontend/menu/disp/glui.c b/frontend/menu/disp/glui.c index 95d746f781..a9492b5788 100644 --- a/frontend/menu/disp/glui.c +++ b/frontend/menu/disp/glui.c @@ -342,6 +342,8 @@ static void glui_context_reset(void *data) { menu_handle_t *menu = (menu_handle_t*)data; gl_t *gl = (gl_t*)driver_video_resolve(NULL); + + (void)gl; driver.gfx_use_rgba = true; From ab0492f4cdd5687fa0a1f78c4d5699b6989a87f6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Sep 2014 02:08:00 +0200 Subject: [PATCH 12/28] Rewrite two settings relying on cmds --- settings_data.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/settings_data.c b/settings_data.c index 06000777c9..2ceaf5b1be 100644 --- a/settings_data.c +++ b/settings_data.c @@ -2148,10 +2148,6 @@ static void general_write_handler(void *data) g_settings.input.joypad_map[3] = *setting->value.integer; else if (!strcmp(setting->name, "input_player5_joypad_index")) g_settings.input.joypad_map[4] = *setting->value.integer; - else if (!strcmp(setting->name, "libretro_info_path")) - rarch_cmd = RARCH_CMD_CORE_INFO_INIT; - else if (!strcmp(setting->name, "libretro_dir_path")) - rarch_cmd = RARCH_CMD_CORE_INFO_INIT; #ifdef HAVE_NETPLAY else if (!strcmp(setting->name, "netplay_ip_address")) g_extern.has_set_netplay_ip_address = (setting->value.string[0] != '\0'); @@ -2635,8 +2631,8 @@ rarch_setting_t *setting_data_get_list(void) #endif CONFIG_PATH(g_settings.libretro, "libretro_path", "Libretro Path", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) - CONFIG_DIR(g_settings.libretro_directory, "libretro_dir_path", "Core Directory", g_defaults.core_dir, "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR) - CONFIG_DIR(g_settings.libretro_info_path, "libretro_info_path", "Core Info Directory", g_defaults.core_info_dir, "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR) + CONFIG_DIR(g_settings.libretro_directory, "libretro_dir_path", "Core Directory", g_defaults.core_dir, "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR) WITH_CMD(RARCH_CMD_CORE_INFO_INIT) + CONFIG_DIR(g_settings.libretro_info_path, "libretro_info_path", "Core Info Directory", g_defaults.core_info_dir, "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR) WITH_CMD(RARCH_CMD_CORE_INFO_INIT) CONFIG_PATH(g_settings.core_options_path, "core_options_path", "Core Options Path", "", "Paths", SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) CONFIG_PATH(g_settings.cheat_database, "cheat_database_path", "Cheat Database", "", "Paths", SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) CONFIG_PATH(g_settings.cheat_settings_path, "cheat_settings_path", "Cheat Settings", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) From f1ab2ece8ced9778e5eb5d3d88ab68385e4677f8 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 14 Sep 2014 20:18:39 -0400 Subject: [PATCH 13/28] Fix a realloc guard mistake I made in config file. --- conf/config_file.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conf/config_file.c b/conf/config_file.c index 2f00d2aef4..d4d5eb10ec 100644 --- a/conf/config_file.c +++ b/conf/config_file.c @@ -82,7 +82,7 @@ static char *getaline(FILE *file) if (index == cur_size) { cur_size *= 2; - newline = (char*)realloc(newline, cur_size + 1); + newline_tmp = (char*)realloc(newline, cur_size + 1); if (newline_tmp) { @@ -459,6 +459,7 @@ config_file_t *config_file_new_from_string(const char *from_string) if (!list) { + string_list_free(lines); config_file_free(conf); return NULL; } @@ -479,7 +480,7 @@ config_file_t *config_file_new_from_string(const char *from_string) if (list != conf->tail) free(list); } - + string_list_free(lines); return conf; From 7d6ebf75bda193d693de3088c719f911428b0ed9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 14 Sep 2014 21:24:03 -0400 Subject: [PATCH 14/28] playlist: early exit if NULL is passed to content_playlist_free_entry --- playlist.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/playlist.c b/playlist.c index 0bf3a7f8ba..b953399bca 100644 --- a/playlist.c +++ b/playlist.c @@ -61,6 +61,9 @@ void content_playlist_get_index(content_playlist_t *playlist, static void content_playlist_free_entry( struct content_playlist_entry *entry) { + if (!entry) + return; + if (entry->path) free(entry->path); entry->path = NULL; From 89676e8424dbf3a1f1d9397e06e43749ae60041f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Sep 2014 04:12:27 +0200 Subject: [PATCH 15/28] Add Playlist Directory path setting --- frontend/frontend.c | 2 ++ frontend/menu/disp/shared.h | 2 ++ frontend/menu/menu_common.c | 1 + general.h | 2 ++ retroarch.cfg | 4 ++++ settings.c | 10 ++++++++++ settings_data.c | 1 + 7 files changed, 22 insertions(+) diff --git a/frontend/frontend.c b/frontend/frontend.c index 73b7c764ba..378f13b011 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -274,6 +274,8 @@ static void check_defaults_dirs(void) path_mkdir(g_defaults.audio_filter_dir); if (*g_defaults.assets_dir) path_mkdir(g_defaults.assets_dir); + if (*g_defaults.playlist_dir) + path_mkdir(g_defaults.playlist_dir); if (*g_defaults.core_dir) path_mkdir(g_defaults.core_dir); if (*g_defaults.core_info_dir) diff --git a/frontend/menu/disp/shared.h b/frontend/menu/disp/shared.h index e3fb7f061f..03e2d01207 100644 --- a/frontend/menu/disp/shared.h +++ b/frontend/menu/disp/shared.h @@ -80,6 +80,8 @@ static void get_title(const char *label, const char *dir, snprintf(title, sizeof_title, "DSP FILTER %s", dir); else if (!strcmp(label, "rgui_browser_directory")) snprintf(title, sizeof_title, "BROWSER DIR %s", dir); + else if (!strcmp(label, "playlist_directory")) + snprintf(title, sizeof_title, "PLAYLIST DIR %s", dir); else if (!strcmp(label, "content_directory")) snprintf(title, sizeof_title, "CONTENT DIR %s", dir); else if (!strcmp(label, "screenshot_directory")) diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index ecfc4d1f2d..6861d5b0f9 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -444,6 +444,7 @@ unsigned menu_common_type_is(const char *label, unsigned type) !strcmp(label, "overlay_directory") || !strcmp(label, "screenshot_directory") || !strcmp(label, "joypad_autoconfig_dir") || + !strcmp(label, "playlist_directory") || !strcmp(label, "extraction_directory") || !strcmp(label, "system_directory")) return MENU_FILE_DIRECTORY; diff --git a/general.h b/general.h index 629aa231ad..76e998c6e5 100644 --- a/general.h +++ b/general.h @@ -197,6 +197,7 @@ struct defaults char sram_dir[PATH_MAX]; char screenshot_dir[PATH_MAX]; char system_dir[PATH_MAX]; + char playlist_dir[PATH_MAX]; struct { @@ -365,6 +366,7 @@ struct settings char system_directory[PATH_MAX]; char extraction_directory[PATH_MAX]; + char playlist_directory[PATH_MAX]; bool rewind_enable; size_t rewind_buffer_size; diff --git a/retroarch.cfg b/retroarch.cfg index 080e1df44e..a8019d5269 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -12,6 +12,10 @@ # will be extracted to this directory. # extraction_directory = +# If set to a directory, the content history playlist will be saved +# to this directory along with any other playlists. +# playlist_directory = + # Automatically saves a savestate at the end of RetroArch's lifetime. # The path is $SRAM_PATH.auto. # RetroArch will automatically load any savestate with this path on startup if savestate_auto_load is set. diff --git a/settings.c b/settings.c index f28b5c4602..d7eef4cd2c 100644 --- a/settings.c +++ b/settings.c @@ -452,6 +452,7 @@ void config_set_defaults(void) *g_settings.input.overlay = '\0'; *g_settings.content_directory = '\0'; *g_settings.assets_directory = '\0'; + *g_settings.playlist_directory = '\0'; *g_settings.video.shader_path = '\0'; *g_settings.video.shader_dir = '\0'; *g_settings.video.filter_dir = '\0'; @@ -488,6 +489,9 @@ void config_set_defaults(void) if (*g_defaults.assets_dir) strlcpy(g_settings.assets_directory, g_defaults.assets_dir, sizeof(g_settings.assets_directory)); + if (*g_defaults.playlist_dir) + strlcpy(g_settings.playlist_directory, + g_defaults.playlist_dir, sizeof(g_settings.playlist_directory)); if (*g_defaults.core_dir) fill_pathname_expand_special(g_settings.libretro_directory, g_defaults.core_dir, sizeof(g_settings.libretro_directory)); @@ -1067,10 +1071,13 @@ bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_PATH(extraction_directory, "extraction_directory"); CONFIG_GET_PATH(content_directory, "content_directory"); CONFIG_GET_PATH(assets_directory, "assets_directory"); + CONFIG_GET_PATH(playlist_directory, "playlist_directory"); if (!strcmp(g_settings.content_directory, "default")) *g_settings.content_directory = '\0'; if (!strcmp(g_settings.assets_directory, "default")) *g_settings.assets_directory = '\0'; + if (!strcmp(g_settings.playlist_directory, "default")) + *g_settings.playlist_directory = '\0'; #ifdef HAVE_MENU CONFIG_GET_PATH(menu_content_directory, "rgui_browser_directory"); if (!strcmp(g_settings.menu_content_directory, "default")) @@ -1507,6 +1514,9 @@ bool config_save_file(const char *path) config_set_path(conf, "assets_directory", *g_settings.assets_directory ? g_settings.assets_directory : "default"); + config_set_path(conf, "playlist_directory", + *g_settings.playlist_directory ? + g_settings.playlist_directory : "default"); #ifdef HAVE_MENU config_set_path(conf, "rgui_browser_directory", *g_settings.menu_content_directory ? diff --git a/settings_data.c b/settings_data.c index 2ceaf5b1be..f3580abc58 100644 --- a/settings_data.c +++ b/settings_data.c @@ -2649,6 +2649,7 @@ rarch_setting_t *setting_data_get_list(void) #endif CONFIG_DIR(g_settings.screenshot_directory, "screenshot_directory", "Screenshot Directory", "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR) CONFIG_DIR(g_settings.input.autoconfig_dir, "joypad_autoconfig_dir", "Joypad Autoconfig Directory", "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR) + CONFIG_DIR(g_settings.playlist_directory, "playlist_directory", "Playlist Directory", "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR) CONFIG_DIR(g_extern.savefile_dir, "savefile_directory", "Savefile Directory", "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler); CONFIG_DIR(g_extern.savestate_dir, "savestate_directory", "Savestate Directory", "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) CONFIG_DIR(g_settings.system_directory, "system_directory", "System Directory", "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) From c6469c8341eac7ce6e0cec6993c1f9a778951a43 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Sep 2014 04:20:45 +0200 Subject: [PATCH 16/28] Set history path to playlists directory if playlist directory is non-NULL --- settings.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/settings.c b/settings.c index d7eef4cd2c..e1f7f00b12 100644 --- a/settings.c +++ b/settings.c @@ -1132,9 +1132,16 @@ bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_INT(network_cmd_port, "network_cmd_port"); CONFIG_GET_BOOL(stdin_cmd_enable, "stdin_cmd_enable"); - fill_pathname_resolve_relative(g_settings.content_history_path, - g_extern.config_path, "retroarch-content-history.txt", - sizeof(g_settings.content_history_path)); + if (g_settings.playlist_directory[0] != '\0') + fill_pathname_join(g_settings.content_history_path, + g_settings.playlist_directory, + "retroarch-content-history.txt", + sizeof(g_settings.content_history_path)); + else + fill_pathname_resolve_relative(g_settings.content_history_path, + g_extern.config_path, "retroarch-content-history.txt", + sizeof(g_settings.content_history_path)); + CONFIG_GET_PATH(content_history_path, "game_history_path"); CONFIG_GET_INT(content_history_size, "game_history_size"); From 5e43f375c6c0ccb65defc55a967b54e8982f401b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Sep 2014 04:45:57 +0200 Subject: [PATCH 17/28] Create playlist in playlist_read_file if it doesn't already exist --- playlist.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/playlist.c b/playlist.c index b953399bca..e89dd0a1ac 100644 --- a/playlist.c +++ b/playlist.c @@ -235,6 +235,13 @@ end: return true; } +static void playlist_create_new(const char *path) +{ + FILE *file = fopen(path, "w"); + if (file) + fclose(file); +} + content_playlist_t *content_playlist_init(const char *path, size_t size) { RARCH_LOG("Opening playlist: %s.\n", path); @@ -253,6 +260,9 @@ content_playlist_t *content_playlist_init(const char *path, size_t size) playlist->cap = size; + if (!path_file_exists(path)) + playlist_create_new(path); + if (!content_playlist_read_file(playlist, path)) goto error; From cbce0c7b8a6e4f49afe4f33e992b7c02c67ea2e3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Sep 2014 05:49:48 +0200 Subject: [PATCH 18/28] Create write_empty_file helper function in file_path.c --- file_path.c | 11 +++++++++++ file_path.h | 1 + playlist.c | 10 ---------- retroarch.c | 15 ++++++++++++--- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/file_path.c b/file_path.c index 2c2f61a11e..245be4b23c 100644 --- a/file_path.c +++ b/file_path.c @@ -80,6 +80,17 @@ bool write_file(const char *path, const void *data, size_t size) return ret; } +bool write_empty_file(const char *path) +{ + FILE *file = fopen(path, "w"); + if (!file) + return false; + + fclose(file); + + return true; +} + /* Generic compressed file loader. */ #ifdef HAVE_COMPRESSION long read_compressed_file(const char * path, void **buf) diff --git a/file_path.h b/file_path.h index bb10e4c6bc..cd5f9123a7 100644 --- a/file_path.h +++ b/file_path.h @@ -46,6 +46,7 @@ long read_compressed_file(const char * path, void **buf); long read_file(const char *path, void **buf); bool read_file_string(const char *path, char **buf); bool write_file(const char *path, const void *buf, size_t size); +bool write_empty_file(const char *path); union string_list_elem_attr { diff --git a/playlist.c b/playlist.c index e89dd0a1ac..b953399bca 100644 --- a/playlist.c +++ b/playlist.c @@ -235,13 +235,6 @@ end: return true; } -static void playlist_create_new(const char *path) -{ - FILE *file = fopen(path, "w"); - if (file) - fclose(file); -} - content_playlist_t *content_playlist_init(const char *path, size_t size) { RARCH_LOG("Opening playlist: %s.\n", path); @@ -260,9 +253,6 @@ content_playlist_t *content_playlist_init(const char *path, size_t size) playlist->cap = size; - if (!path_file_exists(path)) - playlist_create_new(path); - if (!content_playlist_read_file(playlist, path)) goto error; diff --git a/retroarch.c b/retroarch.c index 5217ff7c0c..a2d2d86674 100644 --- a/retroarch.c +++ b/retroarch.c @@ -3479,9 +3479,18 @@ void rarch_main_command(unsigned cmd) break; case RARCH_CMD_HISTORY_INIT: if (!g_extern.history) - g_extern.history = content_playlist_init( - g_settings.content_history_path, - g_settings.content_history_size); + { + bool init_history = true; + + if (!path_file_exists(g_settings.content_history_path)) + init_history = write_empty_file( + g_settings.content_history_path); + + if (init_history) + g_extern.history = content_playlist_init( + g_settings.content_history_path, + g_settings.content_history_size); + } break; case RARCH_CMD_HISTORY_DEINIT: if (g_extern.history) From 958c4cb5e029f9b189d53612c87e0d4b3461035f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Sep 2014 06:14:42 +0200 Subject: [PATCH 19/28] (rewind.c) style/indent nits --- rewind.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/rewind.c b/rewind.c index f2eb81c992..04c6878663 100644 --- a/rewind.c +++ b/rewind.c @@ -133,17 +133,21 @@ state_manager_t *state_manager_new(size_t state_size, size_t buffer_size) state->data = (uint8_t*)malloc(buffer_size); - state->thisblock = (uint8_t*)calloc(state->blocksize + sizeof(uint16_t) * 4 + 16, 1); - state->nextblock = (uint8_t*)calloc(state->blocksize + sizeof(uint16_t) * 4 + 16, 1); + state->thisblock = (uint8_t*) + calloc(state->blocksize + sizeof(uint16_t) * 4 + 16, 1); + state->nextblock = (uint8_t*) + calloc(state->blocksize + sizeof(uint16_t) * 4 + 16, 1); if (!state->data || !state->thisblock || !state->nextblock) goto error; /* Force in a different byte at the end, so we don't need to check * bounds in the innermost loop (it's expensive). * - * There is also a large amount of data that's the same, to stop the other scan - * There is also some padding at the end. This is so we don't read outside the - * buffer end if we're reading in large blocks; + * There is also a large amount of data that's the same, to stop + * the other scan. + * + * There is also some padding at the end. This is so we don't + * read outside the buffer end if we're reading in large blocks; * * It doesn't make any difference to us, but sacrificing 16 bytes to get * Valgrind happy is worth it. */ From 11866d42f890fbbde27b8c667c74de14ae6920f6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Sep 2014 06:43:50 +0200 Subject: [PATCH 20/28] Cleanups --- thread/gx_pthread.h | 18 ++++++++----- thread/psp_pthread.h | 20 +++++++++------ tools/retroarch-joyconfig.c | 50 +++++++++++++++++++++++++------------ wii/mem2_manager.c | 45 +++++++++++++++------------------ 4 files changed, 79 insertions(+), 54 deletions(-) diff --git a/thread/gx_pthread.h b/thread/gx_pthread.h index 60b9df97d6..36a8449cfa 100644 --- a/thread/gx_pthread.h +++ b/thread/gx_pthread.h @@ -86,13 +86,16 @@ typedef int pthread_attr_t; typedef cond_t pthread_cond_t; typedef cond_t pthread_condattr_t; -static inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) +static inline int pthread_create(pthread_t *thread, + const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) { *thread = 0; - return OSCreateThread(thread, start_routine, 0 /* unused */, arg, 0, STACKSIZE, 64, 0 /* unused */); + return OSCreateThread(thread, start_routine, 0 /* unused */, arg, + 0, STACKSIZE, 64, 0 /* unused */); } -static inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) +static inline int pthread_mutex_init(pthread_mutex_t *mutex, + const pthread_mutexattr_t *attr) { return OSInitMutex(mutex); } @@ -135,17 +138,20 @@ static inline int pthread_mutex_trylock(pthread_mutex_t *mutex) return OSTryLockMutex(*mutex); } -static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) +static inline int pthread_cond_wait(pthread_cond_t *cond, + pthread_mutex_t *mutex) { return OSWaitCond(*cond, *mutex); } -static inline int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime) +static inline int pthread_cond_timedwait(pthread_cond_t *cond, + pthread_mutex_t *mutex, const struct timespec *abstime) { return LWP_CondTimedWait(*cond, *mutex, abstime); } -static inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) +static inline int pthread_cond_init(pthread_cond_t *cond, + const pthread_condattr_t *attr) { return OSInitCond(cond); } diff --git a/thread/psp_pthread.h b/thread/psp_pthread.h index 329dd65a5a..0d881fb67f 100644 --- a/thread/psp_pthread.h +++ b/thread/psp_pthread.h @@ -33,7 +33,7 @@ typedef int pthread_attr_t; typedef SceUID pthread_cond_t; typedef SceUID pthread_condattr_t; -// use pointer values to create unique names for threads/mutexes +/* Use pointer values to create unique names for threads/mutexes */ char name_buffer[256]; typedef void* (*sthreadEntry)(void *argp); @@ -52,11 +52,13 @@ static int psp_thread_wrap(SceSize args, void *argp) return (int)sthread_args->start_routine(sthread_args->arg); } -static inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) +static inline int pthread_create(pthread_t *thread, + const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) { sprintf(name_buffer, "0x%08X", (uint32_t) thread); - *thread = sceKernelCreateThread(name_buffer,psp_thread_wrap, 0x20, STACKSIZE, 0, NULL); + *thread = sceKernelCreateThread(name_buffer, + psp_thread_wrap, 0x20, STACKSIZE, 0, NULL); sthread_args_struct sthread_args; sthread_args.arg = arg; @@ -65,7 +67,8 @@ static inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, return sceKernelStartThread(*thread, sizeof(sthread_args), &sthread_args); } -static inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) +static inline int pthread_mutex_init(pthread_mutex_t *mutex, + const pthread_mutexattr_t *attr) { sprintf(name_buffer, "0x%08X", (uint32_t) mutex); @@ -105,19 +108,22 @@ static inline int pthread_mutex_trylock(pthread_mutex_t *mutex) return 1; } -static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) +static inline int pthread_cond_wait(pthread_cond_t *cond, + pthread_mutex_t *mutex) { sceKernelDelayThread(10000); return 1; } -static inline int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime) +static inline int pthread_cond_timedwait(pthread_cond_t *cond, + pthread_mutex_t *mutex, const struct timespec *abstime) { //FIXME: stub return 1; } -static inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) +static inline int pthread_cond_init(pthread_cond_t *cond, + const pthread_condattr_t *attr) { //FIXME: stub return 1; diff --git a/tools/retroarch-joyconfig.c b/tools/retroarch-joyconfig.c index 350958271f..3adc698cf2 100644 --- a/tools/retroarch-joyconfig.c +++ b/tools/retroarch-joyconfig.c @@ -27,8 +27,10 @@ #include #include "../compat/posix_string.h" -// Need to be present for build to work, but it's not *really* used. -// Better than having to build special versions of lots of objects with special #ifdefs. +/* Need to be present for build to work, but it's not *really* used. + * Better than having to build special versions of lots of objects + * with special #ifdefs. + */ struct settings g_settings; struct global g_extern; driver_t driver; @@ -100,7 +102,8 @@ static void poll_joypad(const rarch_joypad_driver_t *driver, } } -static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, int joypad) +static void get_binds(config_file_t *conf, config_file_t *auto_conf, + int player, int joypad) { int i, timeout_cnt; const rarch_joypad_driver_t *driver = input_joypad_init_driver(g_driver); @@ -146,9 +149,13 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, if (abs(initial) < 20000) initial = 0; - // Certain joypads (such as XBox360 controller on Linux) has a default negative axis for shoulder triggers, - // which makes configuration very awkward. - // If default negative, we can't trigger on the negative axis, and similar with defaulted positive axes. + /* Certain joypads (such as XBox360 controller on Linux) + * has a default negative axis for shoulder triggers, + * which makes configuration very awkward. + * + * If default negative, we can't trigger on the negative axis, + * and similar with defaulted positive axes. + */ if (initial) fprintf(stderr, "Axis %d is defaulted to %s axis value of %d.\n", i, initial > 0 ? "positive" : "negative", initial); @@ -183,9 +190,10 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, { old_poll = new_poll; - // To avoid pegging CPU. - // Ideally use an event-based joypad scheme, - // but it adds far more complexity, so, meh. + /* To avoid pegging CPU. + * Ideally use an event-based joypad scheme, + * but it adds far more complexity, so, meh. + */ rarch_sleep(10); if (timeout_ticks) @@ -206,7 +214,9 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, fprintf(stderr, "\tJoybutton pressed: %d\n", j); char key[64]; snprintf(key, sizeof(key), "%s_%s_btn", - input_config_get_prefix(player_index, input_config_bind_map[i].meta), input_config_bind_map[i].base); + input_config_get_prefix(player_index, + input_config_bind_map[i].meta), + input_config_bind_map[i].base); config_set_int(conf, key, j); if (auto_conf) @@ -230,7 +240,8 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, bool require_negative = initial_axes[j] > 0; bool require_positive = initial_axes[j] < 0; - // Block the axis config until we're sure axes have returned to their neutral state. + /* Block the axis config until we're sure + * axes have returned to their neutral state. */ if (same_axis) { if (abs(value) < 10000 || @@ -239,7 +250,8 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, block_axis = false; } - // If axes are in their neutral state, we can't allow it. + /* If axes are in their neutral state, + * we can't allow it. */ if (require_negative && value >= 0) continue; if (require_positive && value <= 0) @@ -251,7 +263,8 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, if (abs(value) > 20000) { last_axis = j; - fprintf(stderr, "\tJoyaxis moved: Axis %d, Value %d\n", j, value); + fprintf(stderr, "\tJoyaxis moved: Axis %d, Value %d\n", + j, value); char buf[8]; snprintf(buf, sizeof(buf), @@ -259,7 +272,9 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, char key[64]; snprintf(key, sizeof(key), "%s_%s_axis", - input_config_get_prefix(player_index, input_config_bind_map[i].meta), input_config_bind_map[i].base); + input_config_get_prefix(player_index, + input_config_bind_map[i].meta), + input_config_bind_map[i].base); config_set_string(conf, key, buf); @@ -298,7 +313,9 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, char key[64]; snprintf(key, sizeof(key), "%s_%s_btn", - input_config_get_prefix(player_index, input_config_bind_map[i].meta), input_config_bind_map[i].base); + input_config_get_prefix(player_index, + input_config_bind_map[i].meta), + input_config_bind_map[i].base); config_set_string(conf, key, buf); @@ -394,7 +411,8 @@ static void parse_input(int argc, char *argv[]) } else if (g_player > MAX_PLAYERS) { - fprintf(stderr, "Player number must be from 1 to %d.\n", MAX_PLAYERS); + fprintf(stderr, "Player number must be from 1 to %d.\n", + MAX_PLAYERS); exit(1); } break; diff --git a/wii/mem2_manager.c b/wii/mem2_manager.c index 26dc80a26c..cf78908589 100644 --- a/wii/mem2_manager.c +++ b/wii/mem2_manager.c @@ -73,15 +73,20 @@ bool gx_init_mem2(void) u32 level; _CPU_ISR_Disable(level); - // BIG NOTE: MEM2 on the Wii is 64MB, but a portion of that is reserved for - // IOS. libogc by default defines the "safe" area for MEM2 to go from - // 0x90002000 to 0x933E0000. However, from my testing, I've found I need to - // reserve about 256KB for stuff like network and USB to work correctly. - // However, other sources says these functions need at least 0xE0000 bytes, - // 7/8 of a megabyte, of reserved memory to do this. My initial testing - // shows that we can work with only 128KB, but we use 256KB becuse testing - // has shown some stuff being iffy with only 128KB, mainly wiimote stuff. - // If some stuff mysteriously stops working, try fiddling with this size. + /* BIG NOTE: MEM2 on the Wii is 64MB, but a portion + * of that is reserved for IOS. + * + * libogc by default defines the "safe" area for MEM2 + * to go from 0x90002000 to 0x933E0000. + * + * However, from my testing, I've found I need to + * reserve about 256KB for stuff like network and USB to work correctly. + * However, other sources says these functions need at least 0xE0000 bytes, + * 7/8 of a megabyte, of reserved memory to do this. My initial testing + * shows that we can work with only 128KB, but we use 256KB becuse testing + * has shown some stuff being iffy with only 128KB, mainly Wiimote stuff. + * If some stuff mysteriously stops working, try fiddling with this size. + */ u32 size = SYS_GetArena2Size() - 1024 * 256; void *heap_ptr = (void *) ROUNDUP32(((u32) SYS_GetArena2Hi() - size)); @@ -94,17 +99,9 @@ bool gx_init_mem2(void) void *_mem2_memalign(u8 align, u32 size) { - void *ptr; - - if(size == 0) - return NULL; - - ptr = __lwp_heap_allocate(&gx_mem2_heap, size); - - if (ptr == NULL) - return NULL; - - return ptr; + if(size != 0) + return __lwp_heap_allocate(&gx_mem2_heap, size); + return NULL; } void *_mem2_malloc(u32 size) @@ -114,10 +111,8 @@ void *_mem2_malloc(u32 size) void _mem2_free(void *ptr) { - if(!ptr) - return; - - __lwp_heap_free(&gx_mem2_heap, ptr); + if(ptr) + __lwp_heap_free(&gx_mem2_heap, ptr); } void *_mem2_realloc(void *ptr, u32 newsize) @@ -246,7 +241,7 @@ __attribute__ ((used)) void __wrap_free(void *p) __attribute__ ((used)) void *__wrap_realloc(void *p, size_t size) { void *n; - // ptr from mem2 + /* ptr from mem2 */ if (((u32) p & 0x10000000) != 0) { n = _mem2_realloc(p, size); From 8437e4bd2a32fddeba27264f7410c49ba771d0a4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Sep 2014 07:03:54 +0200 Subject: [PATCH 21/28] Style/indent nits --- input/overlay.c | 8 ++-- logger/ios_logger_override.h | 3 +- logger/xdk1_logger_override.h | 21 ++++++--- msvc/msvc-stdint/stdint.h | 83 ++++++++++++++++++----------------- msvc/msvc_compat.h | 8 ++-- netplay.c | 51 +++++++++++++-------- performance.c | 68 +++++++++++++++++----------- 7 files changed, 141 insertions(+), 101 deletions(-) diff --git a/input/overlay.c b/input/overlay.c index c46a700892..342f1646e9 100644 --- a/input/overlay.c +++ b/input/overlay.c @@ -677,10 +677,9 @@ static bool inside_hitbox(const struct overlay_desc *desc, float x, float y) case OVERLAY_HITBOX_RECT: return (fabs(x - desc->x) <= desc->range_x_mod) && (fabs(y - desc->y) <= desc->range_y_mod); - - default: - return false; } + + return false; } static inline float clamp(float val, float lower, float upper) @@ -689,8 +688,7 @@ static inline float clamp(float val, float lower, float upper) return lower; else if (val > upper) return upper; - else - return val; + return val; } void input_overlay_poll(input_overlay_t *ol, input_overlay_state_t *out, diff --git a/logger/ios_logger_override.h b/logger/ios_logger_override.h index b91f4a7c6c..5b912ce0db 100644 --- a/logger/ios_logger_override.h +++ b/logger/ios_logger_override.h @@ -49,7 +49,8 @@ static inline void RARCH_LOG(const char *fmt, ...) va_end(ap); } -static inline void RARCH_LOG_OUTPUT_V(const char *tag, const char *fmt, va_list ap) +static inline void RARCH_LOG_OUTPUT_V(const char *tag, + const char *fmt, va_list ap) { RARCH_LOG_V(tag, fmt, ap); } diff --git a/logger/xdk1_logger_override.h b/logger/xdk1_logger_override.h index 421bef47a5..c45558d560 100644 --- a/logger/xdk1_logger_override.h +++ b/logger/xdk1_logger_override.h @@ -29,9 +29,11 @@ static inline void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap) { char msg_new[1024], buffer[1024]; #ifdef IS_SALAMANDER - snprintf(msg_new, sizeof(msg_new), "RetroArch Salamander: %s%s", tag ? tag : "", fmt); + snprintf(msg_new, sizeof(msg_new), + "RetroArch Salamander: %s%s", tag ? tag : "", fmt); #else - snprintf(msg_new, sizeof(msg_new), "RetroArch: %s%s", tag ? tag : "", fmt); + snprintf(msg_new, sizeof(msg_new), + "RetroArch: %s%s", tag ? tag : "", fmt); #endif wvsprintf(buffer, msg_new, ap); OutputDebugStringA(buffer); @@ -47,7 +49,8 @@ static inline void RARCH_LOG(const char *fmt, ...) va_end(ap); } -static inline void RARCH_LOG_OUTPUT_V(const char *tag, const char *msg, va_list ap) +static inline void RARCH_LOG_OUTPUT_V(const char *tag, + const char *msg, va_list ap) { RARCH_LOG_V(tag, msg, ap); } @@ -64,9 +67,11 @@ static inline void RARCH_WARN_V(const char *tag, const char *fmt, va_list ap) { char msg_new[1024], buffer[1024]; #ifdef IS_SALAMANDER - snprintf(msg_new, sizeof(msg_new), "RetroArch Salamander [WARN] :: %s%s", tag ? tag : "", fmt); + snprintf(msg_new, sizeof(msg_new), + "RetroArch Salamander [WARN] :: %s%s", tag ? tag : "", fmt); #else - snprintf(msg_new, sizeof(msg_new), "RetroArch [WARN] :: %s%s", tag ? tag : "", fmt); + snprintf(msg_new, sizeof(msg_new), + "RetroArch [WARN] :: %s%s", tag ? tag : "", fmt); #endif wvsprintf(buffer, msg_new, ap); OutputDebugStringA(buffer); @@ -86,9 +91,11 @@ static inline void RARCH_ERR_V(const char *tag, const char *fmt, ...) { char msg_new[1024]; #ifdef IS_SALAMANDER - snprintf(msg_new, sizeof(msg_new), "RetroArch Salamander [ERR] :: %s%s", tag ? tag : "", fmt); + snprintf(msg_new, sizeof(msg_new), + "RetroArch Salamander [ERR] :: %s%s", tag ? tag : "", fmt); #else - snprintf(msg_new, sizeof(msg_new), "RetroArch [ERR] :: %s%s", tag ? tag : "", fmt); + snprintf(msg_new, sizeof(msg_new), + "RetroArch [ERR] :: %s%s", tag ? tag : "", fmt); #endif OutputDebugStringA(fmt); } diff --git a/msvc/msvc-stdint/stdint.h b/msvc/msvc-stdint/stdint.h index 9d8fe7b0ad..7df295eb49 100644 --- a/msvc/msvc-stdint/stdint.h +++ b/msvc/msvc-stdint/stdint.h @@ -32,7 +32,7 @@ #define __RARCH_STDINT_H #if _MSC_VER && (_MSC_VER < 1600) -//pre-MSVC 2010 needs an implementation of stdint.h +/* pre-MSVC 2010 needs an implementation of stdint.h */ #if _MSC_VER > 1000 #pragma once @@ -40,10 +40,11 @@ #include -// For Visual Studio 6 in C++ mode and for many Visual Studio versions when -// compiling for ARM we should wrap include with 'extern "C++" {}' -// or compiler give many errors like this: -// error C2733: second C linkage of overloaded function 'wmemchr' not allowed +/* For Visual Studio 6 in C++ mode and for many Visual Studio versions when + * compiling for ARM we should wrap include with 'extern "C++" {}' + * or compiler give many errors like this: + * error C2733: second C linkage of overloaded function 'wmemchr' not allowed + */ #ifdef __cplusplus extern "C" { #endif @@ -52,7 +53,7 @@ extern "C" { } #endif -// Define _W64 macros to mark types changing their size, like intptr_t. +/* Define _W64 macros to mark types changing their size, like intptr_t. */ #ifndef _W64 # if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 # define _W64 __w64 @@ -62,13 +63,14 @@ extern "C" { #endif -// 7.18.1 Integer types +/* 7.18.1 Integer types */ -// 7.18.1.1 Exact-width integer types +/* 7.18.1.1 Exact-width integer types */ -// Visual Studio 6 and Embedded Visual C++ 4 doesn't -// realize that, e.g. char has the same size as __int8 -// so we give up on __intX for them. +/* Visual Studio 6 and Embedded Visual C++ 4 doesn't + * realize that, e.g. char has the same size as __int8 + * so we give up on __intX for them. + */ #if (_MSC_VER < 1300) typedef signed char int8_t; typedef signed short int16_t; @@ -88,7 +90,7 @@ typedef signed __int64 int64_t; typedef unsigned __int64 uint64_t; -// 7.18.1.2 Minimum-width integer types +/* 7.18.1.2 Minimum-width integer types */ typedef int8_t int_least8_t; typedef int16_t int_least16_t; typedef int32_t int_least32_t; @@ -98,7 +100,7 @@ typedef uint16_t uint_least16_t; typedef uint32_t uint_least32_t; typedef uint64_t uint_least64_t; -// 7.18.1.3 Fastest minimum-width integer types +/* 7.18.1.3 Fastest minimum-width integer types */ typedef int8_t int_fast8_t; typedef int16_t int_fast16_t; typedef int32_t int_fast32_t; @@ -108,25 +110,26 @@ typedef uint16_t uint_fast16_t; typedef uint32_t uint_fast32_t; typedef uint64_t uint_fast64_t; -// 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ +/* 7.18.1.4 Integer types capable of holding object pointers */ +#ifdef _WIN64 /* [ */ typedef signed __int64 intptr_t; typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ +#else /* _WIN64 ][ */ typedef _W64 signed int intptr_t; typedef _W64 unsigned int uintptr_t; #endif // _WIN64 ] -// 7.18.1.5 Greatest-width integer types +/* 7.18.1.5 Greatest-width integer types */ typedef int64_t intmax_t; typedef uint64_t uintmax_t; -// 7.18.2 Limits of specified-width integer types +/* 7.18.2 Limits of specified-width integer types */ -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) +/* [ See footnote 220 at page 257 and footnote 221 at page 259 */ -// 7.18.2.1 Limits of exact-width integer types +/* 7.18.2.1 Limits of exact-width integer types */ #define INT8_MIN ((int8_t)_I8_MIN) #define INT8_MAX _I8_MAX #define INT16_MIN ((int16_t)_I16_MIN) @@ -140,7 +143,7 @@ typedef uint64_t uintmax_t; #define UINT32_MAX _UI32_MAX #define UINT64_MAX _UI64_MAX -// 7.18.2.2 Limits of minimum-width integer types +/* 7.18.2.2 Limits of minimum-width integer types */ #define INT_LEAST8_MIN INT8_MIN #define INT_LEAST8_MAX INT8_MAX #define INT_LEAST16_MIN INT16_MIN @@ -154,7 +157,7 @@ typedef uint64_t uintmax_t; #define UINT_LEAST32_MAX UINT32_MAX #define UINT_LEAST64_MAX UINT64_MAX -// 7.18.2.3 Limits of fastest minimum-width integer types +/* 7.18.2.3 Limits of fastest minimum-width integer types */ #define INT_FAST8_MIN INT8_MIN #define INT_FAST8_MAX INT8_MAX #define INT_FAST16_MIN INT16_MIN @@ -168,23 +171,23 @@ typedef uint64_t uintmax_t; #define UINT_FAST32_MAX UINT32_MAX #define UINT_FAST64_MAX UINT64_MAX -// 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ +#ifdef _WIN64 /* [ */ # define INTPTR_MIN INT64_MIN # define INTPTR_MAX INT64_MAX # define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ +#else /* _WIN64 ][ */ # define INTPTR_MIN INT32_MIN # define INTPTR_MAX INT32_MAX # define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] +#endif /* _WIN64 ] */ -// 7.18.2.5 Limits of greatest-width integer types +/* 7.18.2.5 Limits of greatest-width integer types */ #define INTMAX_MIN INT64_MIN #define INTMAX_MAX INT64_MAX #define UINTMAX_MAX UINT64_MAX -// 7.18.3 Limits of other integer types +/* 7.18.3 Limits of other integer types */ #ifdef _WIN64 // [ # define PTRDIFF_MIN _I64_MIN @@ -205,25 +208,25 @@ typedef uint64_t uintmax_t; # endif // _WIN64 ] #endif // SIZE_MAX ] -// WCHAR_MIN and WCHAR_MAX are also defined in -#ifndef WCHAR_MIN // [ +/* WCHAR_MIN and WCHAR_MAX are also defined in */ +#ifndef WCHAR_MIN /* [ */ # define WCHAR_MIN 0 -#endif // WCHAR_MIN ] +#endif /* WCHAR_MIN ] */ #ifndef WCHAR_MAX // [ # define WCHAR_MAX _UI16_MAX -#endif // WCHAR_MAX ] +#endif /* WCHAR_MAX ] */ #define WINT_MIN 0 #define WINT_MAX _UI16_MAX -#endif // __STDC_LIMIT_MACROS ] +#endif /* __STDC_LIMIT_MACROS ] */ +/* 7.18.4 Limits of other integer types */ -// 7.18.4 Limits of other integer types +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) +/* [ See footnote 224 at page 260 */ -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 - -// 7.18.4.1 Macros for minimum-width integer constants +/* 7.18.4.1 Macros for minimum-width integer constants */ #define INT8_C(val) val##i8 #define INT16_C(val) val##i16 @@ -235,14 +238,14 @@ typedef uint64_t uintmax_t; #define UINT32_C(val) val##ui32 #define UINT64_C(val) val##ui64 -// 7.18.4.2 Macros for greatest-width integer constants +/* 7.18.4.2 Macros for greatest-width integer constants */ #define INTMAX_C INT64_C #define UINTMAX_C UINT64_C -#endif // __STDC_CONSTANT_MACROS ] +#endif /* __STDC_CONSTANT_MACROS ] */ #else -//sanity for everything else +/* Sanity for everything else */ #include #endif diff --git a/msvc/msvc_compat.h b/msvc/msvc_compat.h index a8432834a5..e65ae493b4 100644 --- a/msvc/msvc_compat.h +++ b/msvc/msvc_compat.h @@ -19,12 +19,14 @@ #ifdef _MSC_VER -#undef UNICODE // Do not bother with UNICODE at this time. +#undef UNICODE /* Do not bother with UNICODE at this time. */ #include #include #include -// Python headers defines ssize_t and sets HAVE_SSIZE_T. Cannot duplicate these efforts. +/* Python headers defines ssize_t and sets HAVE_SSIZE_T. + * Cannot duplicate these efforts. + */ #ifndef HAVE_SSIZE_T #if defined(_WIN64) typedef __int64 ssize_t; @@ -41,7 +43,7 @@ typedef int ssize_t; #undef strncasecmp #define strncasecmp _strnicmp -// Disable some of the annoying warnings. +/* Disable some of the annoying warnings. */ #pragma warning(disable : 4800) #pragma warning(disable : 4805) #pragma warning(disable : 4244) diff --git a/netplay.c b/netplay.c index 248fca1a69..b2e4a52ce1 100644 --- a/netplay.c +++ b/netplay.c @@ -87,17 +87,25 @@ struct netplay struct delta_frame *buffer; size_t buffer_size; - size_t self_ptr; // Ptr where we are now. - size_t other_ptr; // Points to the last reliable state that self ever had. - size_t read_ptr; // Ptr to where we are reading. Generally, other_ptr <= read_ptr <= self_ptr. - size_t tmp_ptr; // A temporary pointer used on replay. + /* Pointer where we are now. */ + size_t self_ptr; + /* Points to the last reliable state that self ever had. */ + size_t other_ptr; + /* Pointer to where we are reading. + * Generally, other_ptr <= read_ptr <= self_ptr. */ + size_t read_ptr; + /* A temporary pointer used on replay. */ + size_t tmp_ptr; size_t state_size; - bool is_replay; // Are we replaying old frames? - bool can_poll; // We don't want to poll several times on a frame. + /* Are we replaying old frames? */ + bool is_replay; + /* We don't want to poll several times on a frame. */ + bool can_poll; - // To compat UDP packet loss we also send old data along with the packets. + /* To compat UDP packet loss we also send + * old data along with the packets. */ uint32_t packet_buffer[UDP_FRAME_PACKETS * 2]; uint32_t frame_count; uint32_t read_frame_count; @@ -109,7 +117,7 @@ struct netplay unsigned timeout_cnt; - // Spectating. + /* Spectating. */ bool spectate; bool spectate_client; int spectate_fds[MAX_SPECTATORS]; @@ -117,11 +125,11 @@ struct netplay size_t spectate_input_ptr; size_t spectate_input_size; - // Player flipping - // Flipping state. If ptr >= flip_frame, we apply the flip. - // If not, we apply the opposite, effectively creating a trigger point. - // To avoid collition we need to make sure our client/host is synced up - // well after flip_frame before allowing another flip. + /* Player flipping + * Flipping state. If ptr >= flip_frame, we apply the flip. + * If not, we apply the opposite, effectively creating a trigger point. + * To avoid collition we need to make sure our client/host is synced up + * well after flip_frame before allowing another flip. */ bool flip; uint32_t flip_frame; }; @@ -167,11 +175,13 @@ static void warn_hangup(void) void input_poll_net(void) { - if (!netplay_should_skip(g_extern.netplay) && netplay_can_poll(g_extern.netplay)) + if (!netplay_should_skip(g_extern.netplay) + && netplay_can_poll(g_extern.netplay)) netplay_poll(g_extern.netplay); } -void video_frame_net(const void *data, unsigned width, unsigned height, size_t pitch) +void video_frame_net(const void *data, unsigned width, + unsigned height, size_t pitch) { if (!netplay_should_skip(g_extern.netplay)) g_extern.netplay->cbs.frame_cb(data, width, height, pitch); @@ -190,7 +200,8 @@ size_t audio_sample_batch_net(const int16_t *data, size_t frames) return frames; } -int16_t input_state_net(unsigned port, unsigned device, unsigned index, unsigned id) +int16_t input_state_net(unsigned port, unsigned device, + unsigned index, unsigned id) { if (netplay_is_alive(g_extern.netplay)) return netplay_input_state(g_extern.netplay, port, device, index, id); @@ -614,7 +625,7 @@ static bool get_info(netplay_t *handle) return false; } - // Send SRAM data to our Player 2. + /* Send SRAM data to our Player 2. */ const void *sram = pretro_get_memory_data(RETRO_MEMORY_SAVE_RAM); unsigned sram_size = pretro_get_memory_size(RETRO_MEMORY_SAVE_RAM); if (!send_all(handle->fd, sram, sram_size)) @@ -682,7 +693,8 @@ static bool bsv_parse_header(const uint32_t *header, uint32_t magic) uint32_t in_crc = swap_if_big32(header[CRC_INDEX]); if (in_crc != g_extern.content_crc) { - RARCH_ERR("CRC32 mismatch, got 0x%x, expected 0x%x.\n", in_crc, g_extern.content_crc); + RARCH_ERR("CRC32 mismatch, got 0x%x, expected 0x%x.\n", in_crc, + g_extern.content_crc); return false; } @@ -1134,13 +1146,14 @@ static bool netplay_get_cmd(netplay_t *handle) { case NETPLAY_CMD_FLIP_PLAYERS: { + uint32_t flip_frame; + if (cmd_size != sizeof(uint32_t)) { RARCH_ERR("CMD_FLIP_PLAYERS has unexpected command size.\n"); return netplay_cmd_nak(handle); } - uint32_t flip_frame; if (!recv_all(handle->fd, &flip_frame, sizeof(flip_frame))) { RARCH_ERR("Failed to receive CMD_FLIP_PLAYERS argument.\n"); diff --git a/performance.c b/performance.c index a450dbc47d..cf3a0c4147 100644 --- a/performance.c +++ b/performance.c @@ -85,7 +85,8 @@ unsigned perf_ptr_libretro; void rarch_perf_register(struct retro_perf_counter *perf) { - if (!g_extern.perfcnt_enable || perf->registered || perf_ptr_rarch >= MAX_COUNTERS) + if (!g_extern.perfcnt_enable || perf->registered + || perf_ptr_rarch >= MAX_COUNTERS) return; perf_counters_rarch[perf_ptr_rarch++] = perf; @@ -107,7 +108,8 @@ void retro_perf_clear(void) memset(perf_counters_libretro, 0, sizeof(perf_counters_libretro)); } -static void log_counters(const struct retro_perf_counter **counters, unsigned num) +static void log_counters( + const struct retro_perf_counter **counters, unsigned num) { unsigned i; for (i = 0; i < num; i++) @@ -116,7 +118,8 @@ static void log_counters(const struct retro_perf_counter **counters, unsigned nu { RARCH_LOG(PERF_LOG_FMT, counters[i]->ident, - (unsigned long long)counters[i]->total / (unsigned long long)counters[i]->call_cnt, + (unsigned long long)counters[i]->total / + (unsigned long long)counters[i]->call_cnt, (unsigned long long)counters[i]->call_cnt); } } @@ -147,7 +150,8 @@ retro_perf_tick_t rarch_get_perf_counter(void) #elif defined(__linux__) || defined(__QNX__) struct timespec tv; if (clock_gettime(CLOCK_MONOTONIC, &tv) == 0) - time = (retro_perf_tick_t)tv.tv_sec * 1000000000 + (retro_perf_tick_t)tv.tv_nsec; + time = (retro_perf_tick_t)tv.tv_sec * 1000000000 + + (retro_perf_tick_t)tv.tv_nsec; else time = 0; @@ -194,7 +198,8 @@ retro_time_t rarch_get_time_usec(void) { #if defined(_WIN32) static LARGE_INTEGER freq; - if (!freq.QuadPart && !QueryPerformanceFrequency(&freq)) // Frequency is guaranteed to not change. + /* Frequency is guaranteed to not change. */ + if (!freq.QuadPart && !QueryPerformanceFrequency(&freq)) return 0; LARGE_INTEGER count; @@ -205,7 +210,8 @@ retro_time_t rarch_get_time_usec(void) return sys_time_get_system_time(); #elif defined(GEKKO) return ticks_to_microsecs(gettime()); -#elif defined(__MACH__) // OSX doesn't have clock_gettime ... +#elif defined(__MACH__) + /* OSX doesn't have clock_gettime. */ clock_serv_t cclock; mach_timespec_t mts; host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); @@ -239,8 +245,8 @@ retro_time_t rarch_get_time_usec(void) #ifdef CPU_X86 static void x86_cpuid(int func, int flags[4]) { - // On Android, we compile RetroArch with PIC, and we are not allowed to clobber the ebx - // register. + /* On Android, we compile RetroArch with PIC, and we + * are not allowed to clobber the ebx register. */ #ifdef __x86_64__ #define REG_b "rbx" #define REG_S "rsi" @@ -264,18 +270,21 @@ static void x86_cpuid(int func, int flags[4]) #endif } -// Only runs on i686 and above. Needs to be conditionally run. +/* Only runs on i686 and above. Needs to be conditionally run. */ static uint64_t xgetbv_x86(uint32_t index) { #if defined(__GNUC__) uint32_t eax, edx; asm volatile ( - // Older GCC versions (Apple's GCC for example) do not understand xgetbv instruction. - // Stamp out the machine code directly. + /* Older GCC versions (Apple's GCC for example) do + * not understand xgetbv instruction. + * Stamp out the machine code directly. + */ ".byte 0x0f, 0x01, 0xd0\n" : "=a"(eax), "=d"(edx) : "c"(index)); return ((uint64_t)edx << 32) | eax; -#elif _MSC_FULL_VER >= 160040219 // Intrinsic only works on 2010 SP1 and above. +#elif _MSC_FULL_VER >= 160040219 + /* Intrinsic only works on 2010 SP1 and above. */ return _xgetbv(index); #else RARCH_WARN("Unknown compiler. Cannot check xgetbv bits.\n"); @@ -287,15 +296,16 @@ static uint64_t xgetbv_x86(uint32_t index) #if defined(__ARM_NEON__) static void arm_enable_runfast_mode(void) { - // RunFast mode. Enables flush-to-zero and some floating point optimizations. + /* RunFast mode. Enables flush-to-zero and some + * floating point optimizations. */ static const unsigned x = 0x04086060; static const unsigned y = 0x03000000; int r; asm volatile( - "fmrx %0, fpscr \n\t" // r0 = FPSCR - "and %0, %0, %1 \n\t" // r0 = r0 & 0x04086060 - "orr %0, %0, %2 \n\t" // r0 = r0 | 0x03000000 - "fmxr fpscr, %0 \n\t" // FPSCR = r0 + "fmrx %0, fpscr \n\t" /* r0 = FPSCR */ + "and %0, %0, %1 \n\t" /* r0 = r0 & 0x04086060 */ + "orr %0, %0, %2 \n\t" /* r0 = r0 | 0x03000000 */ + "fmxr fpscr, %0 \n\t" /* FPSCR = r0 */ : "=r"(r) : "r"(x), "r"(y) ); @@ -304,7 +314,8 @@ static void arm_enable_runfast_mode(void) unsigned rarch_get_cpu_cores(void) { -#if defined(_WIN32) && !defined(_XBOX) // Win32 +#if defined(_WIN32) && !defined(_XBOX) + /* Win32 */ SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); return sysinfo.dwNumberOfProcessors; @@ -312,13 +323,15 @@ unsigned rarch_get_cpu_cores(void) return android_getCpuCount(); #elif defined(GEKKO) return 1; -#elif defined(_SC_NPROCESSORS_ONLN) // Linux, most unix-likes. +#elif defined(_SC_NPROCESSORS_ONLN) + /* Linux, most UNIX-likes. */ long ret = sysconf(_SC_NPROCESSORS_ONLN); if (ret <= 0) return (unsigned)1; return ret; -#elif defined(BSD) || defined(__APPLE__) // BSD - // Copypasta from stackoverflow, dunno if it works. +#elif defined(BSD) || defined(__APPLE__) + /* BSD */ + /* Copypasta from stackoverflow, dunno if it works. */ int num_cpu = 0; int mib[4]; size_t len = sizeof(num_cpu); @@ -337,7 +350,7 @@ unsigned rarch_get_cpu_cores(void) #elif defined(_XBOX360) return 3; #else - // No idea, assume single core. + /* No idea, assume single core. */ return 1; #endif } @@ -356,7 +369,7 @@ uint64_t rarch_get_cpu_features(void) RARCH_LOG("[CPUID]: Vendor: %s\n", vendor); unsigned max_flag = flags[0]; - if (max_flag < 1) // Does CPUID not support func = 1? (unlikely ...) + if (max_flag < 1) /* Does CPUID not support func = 1? (unlikely ...) */ return 0; x86_cpuid(1, flags); @@ -366,7 +379,7 @@ uint64_t rarch_get_cpu_features(void) if (flags[3] & (1 << 25)) { - // SSE also implies MMXEXT (according to FFmpeg source). + /* SSE also implies MMXEXT (according to FFmpeg source). */ cpu |= RETRO_SIMD_SSE; cpu |= RETRO_SIMD_MMXEXT; } @@ -390,8 +403,11 @@ uint64_t rarch_get_cpu_features(void) cpu |= RETRO_SIMD_AES; const int avx_flags = (1 << 27) | (1 << 28); - // Must only perform xgetbv check if we have AVX CPU support (guaranteed to have at least i686). - if (((flags[2] & avx_flags) == avx_flags) && ((xgetbv_x86(0) & 0x6) == 0x6)) + + /* Must only perform xgetbv check if we have + * AVX CPU support (guaranteed to have at least i686). */ + if (((flags[2] & avx_flags) == avx_flags) + && ((xgetbv_x86(0) & 0x6) == 0x6)) cpu |= RETRO_SIMD_AVX; if (max_flag >= 7) From 48a44e8e64ccad83cd4155cc31b452853453aa32 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Sep 2014 07:08:17 +0200 Subject: [PATCH 22/28] (Menu) Take out RARCH_MENU_TOGGLE for old_input_state - no longer needed --- frontend/menu/menu_common.c | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index 6861d5b0f9..28f80f4cf9 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -315,7 +315,6 @@ bool menu_iterate(void) { driver.menu->need_refresh = true; rarch_main_set_state(RARCH_ACTION_STATE_MENU_PREINIT_FINISHED); - driver.menu->old_input_state |= 1ULL << RARCH_MENU_TOGGLE; } rarch_input_poll(); From 3c05bc4b528be772568c1201a861472e471693d5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Sep 2014 07:23:50 +0200 Subject: [PATCH 23/28] (Menu) Disable going back to main menu when pressing menu toggle button (will later be exposed again as a toggleable option) --- frontend/menu/menu_common.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index 28f80f4cf9..5b0afb74b4 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -380,8 +380,11 @@ bool menu_iterate(void) if (driver.menu_ctx && driver.menu_ctx->input_postprocess) driver.menu_ctx->input_postprocess(driver.menu->old_input_state); +#if 0 + /* Go back to Main Menu when exiting */ if (ret < 0) menu_flush_stack_type(driver.menu->menu_stack, MENU_SETTINGS); +#endif if (ret) return false; From 71f6abb71fb7d63375300b1843e4ecc36e63e80d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Sep 2014 07:31:33 +0200 Subject: [PATCH 24/28] (Menu/Settings) Only show Core Disk Options if core supports it --- settings_data.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/settings_data.c b/settings_data.c index f3580abc58..4660a472f8 100644 --- a/settings_data.c +++ b/settings_data.c @@ -2273,7 +2273,9 @@ rarch_setting_t *setting_data_get_mainmenu(bool regenerate) CONFIG_BOOL(lists[3], "load_content", "Load Content", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) CONFIG_BOOL(lists[4], "core_options", "Core Options", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) CONFIG_BOOL(lists[5], "core_information", "Core Information", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) - if (g_extern.main_is_init && !g_extern.libretro_dummy) + if (g_extern.main_is_init + && !g_extern.libretro_dummy + && g_extern.system.disk_control.get_num_images) { CONFIG_BOOL(lists[6], "disk_options", "Core Disk Options", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) } From e53c7d590f67e4e090e384b94634e72e8b69105f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Sep 2014 07:38:28 +0200 Subject: [PATCH 25/28] (Lakka) Fix menu toggle --- frontend/menu/backend/menu_lakka_backend.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontend/menu/backend/menu_lakka_backend.c b/frontend/menu/backend/menu_lakka_backend.c index 5b8398ab59..a7a55cbad6 100644 --- a/frontend/menu/backend/menu_lakka_backend.c +++ b/frontend/menu/backend/menu_lakka_backend.c @@ -331,6 +331,13 @@ static int menu_lakka_iterate(unsigned action) return 0; } + if (action == MENU_ACTION_TOGGLE && + g_extern.main_is_init && !g_extern.libretro_dummy) + { + rarch_main_command(RARCH_CMD_RESUME); + return -1; + } + active_category = (menu_category_t*)&categories[menu_active_category]; if (active_category) From 35cc778bb3ccdd24581f5fcae68351231196cc9d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Sep 2014 07:42:35 +0200 Subject: [PATCH 26/28] (Lakka) Implement setting cmd_trigger --- frontend/menu/backend/menu_lakka_backend.c | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/frontend/menu/backend/menu_lakka_backend.c b/frontend/menu/backend/menu_lakka_backend.c index a7a55cbad6..7fb3282044 100644 --- a/frontend/menu/backend/menu_lakka_backend.c +++ b/frontend/menu/backend/menu_lakka_backend.c @@ -357,25 +357,26 @@ static int menu_lakka_iterate(unsigned action) if (action && depth == 1 && menu_active_category == 0 && active_subitem->setting) { + rarch_setting_t *setting = (rarch_setting_t*) + active_subitem->setting; + switch (action) { + case MENU_ACTION_OK: + if (setting->cmd_trigger.idx != RARCH_CMD_NONE) + setting->cmd_trigger.triggered = true; + /* fall-through */ case MENU_ACTION_LEFT: case MENU_ACTION_RIGHT: - case MENU_ACTION_OK: case MENU_ACTION_START: - { - rarch_setting_t *setting = (rarch_setting_t*) - active_subitem->setting; - - if (setting->type == ST_BOOL) - menu_action_setting_boolean(setting, action); - else if (setting->type == ST_UINT) - menu_action_setting_unsigned_integer(setting, 0, action); - else if (setting->type == ST_FLOAT) - menu_action_setting_fraction(setting, action); - else if (setting->type == ST_STRING) - menu_action_setting_driver(setting, action); - } + if (setting->type == ST_BOOL) + menu_action_setting_boolean(setting, action); + else if (setting->type == ST_UINT) + menu_action_setting_unsigned_integer(setting, 0, action); + else if (setting->type == ST_FLOAT) + menu_action_setting_fraction(setting, action); + else if (setting->type == ST_STRING) + menu_action_setting_driver(setting, action); break; default: break; From 756356870b3540da8fc34f550fecaaf986e59b39 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Sep 2014 07:52:08 +0200 Subject: [PATCH 27/28] (Menu) Refactor more code to menu_action.c --- frontend/menu/backend/menu_common_backend.c | 37 ++------------------- frontend/menu/menu_action.c | 31 +++++++++++++++++ frontend/menu/menu_action.h | 9 +++++ frontend/menu/menu_input_line_cb.c | 12 +++---- 4 files changed, 47 insertions(+), 42 deletions(-) diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index 0044857894..f92b00bf4b 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -238,37 +238,6 @@ static int menu_common_setting_set_current_path_selection( return menu_action_setting_apply(setting); } -static int menu_common_setting_set_current_string_path( - rarch_setting_t *setting, const char *dir, const char *path) -{ - fill_pathname_join(setting->value.string, dir, path, setting->size); - - return menu_action_setting_apply(setting); -} - -int menu_common_set_current_string_based_on_label( - const char *label, const char *str) -{ - if (!strcmp(label, "video_shader_preset_save_as")) - { -#ifdef HAVE_SHADER_MANAGER - if (driver.menu_ctx && driver.menu_ctx->backend - && driver.menu_ctx->backend->shader_manager_save_preset) - driver.menu_ctx->backend->shader_manager_save_preset(str, false); -#endif - } - - return 0; -} - -int menu_common_setting_set_current_string( - rarch_setting_t *setting, const char *str) -{ - strlcpy(setting->value.string, str, setting->size); - - return menu_action_setting_apply(setting); -} - static int handle_setting(rarch_setting_t *setting, unsigned id, const char *label, unsigned action) { @@ -1237,7 +1206,7 @@ static int menu_action_ok(const char *menu_path, } else if ((setting && setting->type == ST_PATH)) { - menu_common_setting_set_current_string_path(setting, menu_path, path); + menu_action_setting_set_current_string_path(setting, menu_path, path); menu_entries_pop_stack(driver.menu->menu_stack, setting->name); } else if (!strcmp(menu_label, "disk_image_append")) @@ -1296,7 +1265,7 @@ static int menu_action_ok(const char *menu_path, case MENU_FILE_AUDIOFILTER: case MENU_FILE_VIDEOFILTER: - menu_common_setting_set_current_string_path(setting, menu_path, path); + menu_action_setting_set_current_string_path(setting, menu_path, path); menu_entries_pop_stack(driver.menu->menu_stack, setting->name); return 0; @@ -1370,7 +1339,7 @@ static int menu_action_ok(const char *menu_path, if (setting && setting->type == ST_DIR) { - menu_common_setting_set_current_string(setting, menu_path); + menu_action_setting_set_current_string(setting, menu_path); menu_entries_pop_stack(driver.menu->menu_stack, setting->name); } diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index c484dd14ec..54813f66c9 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -246,3 +246,34 @@ void menu_action_setting_driver( } } } + +int menu_action_setting_set_current_string( + rarch_setting_t *setting, const char *str) +{ + strlcpy(setting->value.string, str, setting->size); + + return menu_action_setting_apply(setting); +} + +int menu_action_set_current_string_based_on_label( + const char *label, const char *str) +{ + if (!strcmp(label, "video_shader_preset_save_as")) + { +#ifdef HAVE_SHADER_MANAGER + if (driver.menu_ctx && driver.menu_ctx->backend + && driver.menu_ctx->backend->shader_manager_save_preset) + driver.menu_ctx->backend->shader_manager_save_preset(str, false); +#endif + } + + return 0; +} + +int menu_action_setting_set_current_string_path( + rarch_setting_t *setting, const char *dir, const char *path) +{ + fill_pathname_join(setting->value.string, dir, path, setting->size); + + return menu_action_setting_apply(setting); +} diff --git a/frontend/menu/menu_action.h b/frontend/menu/menu_action.h index 6fb4a8b5f0..17cff7eac7 100644 --- a/frontend/menu/menu_action.h +++ b/frontend/menu/menu_action.h @@ -33,4 +33,13 @@ int menu_action_setting_unsigned_integer( void menu_action_setting_driver( rarch_setting_t *setting, unsigned action); +int menu_action_set_current_string_based_on_label( + const char *label, const char *str); + +int menu_action_setting_set_current_string( + rarch_setting_t *setting, const char *str); + +int menu_action_setting_set_current_string_path( + rarch_setting_t *setting, const char *dir, const char *path); + #endif diff --git a/frontend/menu/menu_input_line_cb.c b/frontend/menu/menu_input_line_cb.c index 1ec46d0fc4..fdeaa2f62c 100644 --- a/frontend/menu/menu_input_line_cb.c +++ b/frontend/menu/menu_input_line_cb.c @@ -25,16 +25,11 @@ #include #include #include "menu_common.h" +#include "menu_action.h" #include "../../input/keyboard_line.h" #include "menu_input_line_cb.h" #include "../../settings_data.h" -/* forward decls */ -int menu_common_setting_set_current_string(rarch_setting_t *setting, - const char *str); -int menu_common_set_current_string_based_on_label( - const char *label, const char *str); - void menu_key_start_line(void *data, const char *label, const char *label_setting, input_keyboard_line_complete_t cb) { @@ -100,9 +95,10 @@ void st_string_callback(void *userdata, const char *str) if ((current_setting = (rarch_setting_t*) setting_data_find_setting( setting_data, menu->keyboard.label_setting))) - menu_common_setting_set_current_string(current_setting, str); + menu_action_setting_set_current_string(current_setting, str); else - menu_common_set_current_string_based_on_label(menu->keyboard.label_setting, str); + menu_action_set_current_string_based_on_label( + menu->keyboard.label_setting, str); } menu_key_end_line(menu); } From a71b42e4b3eb047b7654f39a6b01a8b18efeec8a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Sep 2014 08:03:58 +0200 Subject: [PATCH 28/28] (RARCH_CONSOLE/RARCH_MOBILE) Add default playlist dir for consoles/mobile --- frontend/platform/platform_android.c | 2 ++ frontend/platform/platform_gx.c | 2 ++ frontend/platform/platform_ps3.c | 2 ++ frontend/platform/platform_psp.c | 2 ++ frontend/platform/platform_qnx.c | 2 ++ frontend/platform/platform_xdk.c | 2 ++ 6 files changed, 12 insertions(+) diff --git a/frontend/platform/platform_android.c b/frontend/platform/platform_android.c index 3a6a410848..5fd7b0ea90 100644 --- a/frontend/platform/platform_android.c +++ b/frontend/platform/platform_android.c @@ -620,6 +620,8 @@ static void frontend_android_get_environment_settings(int *argc, path, "info", sizeof(g_defaults.core_info_dir)); fill_pathname_join(g_defaults.autoconfig_dir, path, "autoconfig", sizeof(g_defaults.autoconfig_dir)); + fill_pathname_join(g_defaults.playlist_dir, + path, "playlists", sizeof(g_defaults.playlist_dir)); } } } diff --git a/frontend/platform/platform_gx.c b/frontend/platform/platform_gx.c index 2b99f6c394..e17d8dd348 100644 --- a/frontend/platform/platform_gx.c +++ b/frontend/platform/platform_gx.c @@ -198,6 +198,8 @@ static void frontend_gx_get_environment_settings(int *argc, char *argv[], "savefiles", sizeof(g_defaults.sram_dir)); fill_pathname_join(g_defaults.savestate_dir, g_defaults.port_dir, "savefiles", sizeof(g_defaults.savestate_dir)); + fill_pathname_join(g_defaults.playlist_dir, g_defaults.port_dir, + "playlists", sizeof(g_defaults.playlist_dir)); #ifdef IS_SALAMANDER if (*argc > 2 && argv[1] != NULL && argv[2] != NULL) diff --git a/frontend/platform/platform_ps3.c b/frontend/platform/platform_ps3.c index 2e2085d8c7..23eae56aa9 100644 --- a/frontend/platform/platform_ps3.c +++ b/frontend/platform/platform_ps3.c @@ -207,6 +207,8 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[], "overlays", sizeof(g_defaults.overlay_dir)); fill_pathname_join(g_defaults.assets_dir, g_defaults.core_dir, "media", sizeof(g_defaults.assets_dir)); + fill_pathname_join(g_defaults.playlist_dir, g_defaults.core_dir, + "playlists", sizeof(g_defaults.playlist_dir)); } #ifndef IS_SALAMANDER diff --git a/frontend/platform/platform_psp.c b/frontend/platform/platform_psp.c index a2cebc40a0..5e713bd757 100644 --- a/frontend/platform/platform_psp.c +++ b/frontend/platform/platform_psp.c @@ -77,6 +77,8 @@ static void frontend_psp_get_environment_settings(int *argc, char *argv[], "savefiles", sizeof(g_defaults.sram_dir)); fill_pathname_join(g_defaults.system_dir, g_defaults.core_dir, "system", sizeof(g_defaults.system_dir)); + fill_pathname_join(g_defaults.playlist_dir, g_defaults.core_dir, + "playlists", sizeof(g_defaults.playlist_dir)); fill_pathname_join(g_defaults.config_path, g_defaults.port_dir, "retroarch.cfg", sizeof(g_defaults.config_path)); diff --git a/frontend/platform/platform_qnx.c b/frontend/platform/platform_qnx.c index 1f7473437a..735d8ccac2 100644 --- a/frontend/platform/platform_qnx.c +++ b/frontend/platform/platform_qnx.c @@ -55,6 +55,8 @@ static void frontend_qnx_get_environment_settings(int *argc, char *argv[], "lib", sizeof(g_defaults.core_dir)); fill_pathname_join(g_defaults.core_info_dir, "app/native", "info", sizeof(g_defaults.core_info_dir)); + fill_pathname_join(g_defaults.playlist_dir, "app/native", + "playlists", sizeof(g_defaults.playlist_dir)); } const frontend_ctx_driver_t frontend_ctx_qnx = { diff --git a/frontend/platform/platform_xdk.c b/frontend/platform/platform_xdk.c index 2380f19996..23728c33b7 100644 --- a/frontend/platform/platform_xdk.c +++ b/frontend/platform/platform_xdk.c @@ -162,6 +162,8 @@ static void frontend_xdk_get_environment_settings(int *argc, char *argv[], "game:", sizeof(g_defaults.screenshot_dir)); strlcpy(g_defaults.savestate_dir, "game:\\savestates", sizeof(g_defaults.savestate_dir)); + strlcpy(g_defaults.playlist_dir, + "game:\\playlists", sizeof(g_defaults.playlist_dir)); strlcpy(g_defaults.sram_dir, "game:\\savefiles", sizeof(g_defaults.sram_dir)); strlcpy(g_defaults.system_dir,