From ca9f081d27c81e984a9d30777d73a46bc29d43db Mon Sep 17 00:00:00 2001 From: Themaister Date: Thu, 20 Dec 2012 20:23:53 +0100 Subject: [PATCH] Make input overlay configurable. --- driver.c | 11 ++++++++++- general.h | 2 ++ input/overlay.c | 6 ++---- retroarch.cfg | 3 +++ settings.c | 2 ++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/driver.c b/driver.c index d01ca085d4..de955af2a4 100644 --- a/driver.c +++ b/driver.c @@ -721,8 +721,17 @@ void init_video_input(void) // TODO: This should probably be done somewhere else. if (driver.overlay) + { input_overlay_free(driver.overlay); - driver.overlay = input_overlay_new(NULL); + driver.overlay = NULL; + } + + if (*g_settings.input.overlay) + { + driver.overlay = input_overlay_new(g_settings.input.overlay); + if (!driver.overlay) + RARCH_ERR("Failed to load overlay.\n"); + } } void uninit_video_input(void) diff --git a/general.h b/general.h index f0240a322e..1eef86098c 100644 --- a/general.h +++ b/general.h @@ -185,6 +185,8 @@ struct settings unsigned turbo_period; unsigned turbo_duty_cycle; + + char overlay[PATH_MAX]; } input; char libretro[PATH_MAX]; diff --git a/input/overlay.c b/input/overlay.c index d92313681b..1bcd999ac3 100644 --- a/input/overlay.c +++ b/input/overlay.c @@ -28,9 +28,8 @@ struct input_overlay input_overlay_t *input_overlay_new(const char *overlay) { - (void)overlay; - input_overlay_t *ol = (input_overlay_t*)calloc(1, sizeof(*ol)); + if (!ol) goto error; @@ -46,9 +45,8 @@ input_overlay_t *input_overlay_new(const char *overlay) if (!ol->iface) goto error; - // Test hardcoded. struct texture_image img = {0}; - if (!texture_image_load("/tmp/basic_overlay.png", &img)) + if (!texture_image_load(overlay, &img)) { RARCH_ERR("Failed to load overlay image.\n"); goto error; diff --git a/retroarch.cfg b/retroarch.cfg index 5880f94dd8..65d17bdf0f 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -196,6 +196,9 @@ # Defines axis threshold. Possible values are [0.0, 1.0] # input_axis_threshold = 0.5 +# Path to input overlay +# input_overlay = + # Keyboard input. Will recognize normal keypresses and special keys like "left", "right", and so on. # Keyboard input, Joypad and Joyaxis will all obey the "nul" bind, which disables the bind completely, # rather than relying on a default. diff --git a/settings.c b/settings.c index ff9a28a8c9..36ddc4d8a5 100644 --- a/settings.c +++ b/settings.c @@ -564,6 +564,8 @@ bool config_load_file(const char *path) CONFIG_GET_INT(input.turbo_period, "input_turbo_period"); CONFIG_GET_INT(input.turbo_duty_cycle, "input_duty_cycle"); + CONFIG_GET_PATH(input.overlay, "input_overlay"); + if (config_get_string(conf, "environment_variables", &g_extern.system.environment)) {