From 73ce9c0d2376d33881a376fa5be07796b0cc1870 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 25 Nov 2015 18:33:18 +0100 Subject: [PATCH] Add another RARCH_INPUT_CTL_* command --- driver.c | 2 +- gfx/video_driver.c | 2 +- input/input_driver.c | 49 ++++++++++++++++++++++---------------------- input/input_driver.h | 3 +-- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/driver.c b/driver.c index 8a3df89fac..60fc685bc7 100644 --- a/driver.c +++ b/driver.c @@ -222,7 +222,7 @@ void init_drivers_pre(void) { audio_driver_ctl(RARCH_AUDIO_CTL_FIND_DRIVER, NULL); video_driver_ctl(RARCH_DISPLAY_CTL_FIND_DRIVER, NULL); - find_input_driver(); + input_driver_ctl(RARCH_INPUT_CTL_FIND_DRIVER, NULL); find_camera_driver(); find_location_driver(); #ifdef HAVE_MENU diff --git a/gfx/video_driver.c b/gfx/video_driver.c index a738a673bb..140960cdde 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -425,7 +425,7 @@ static void init_video_input(const input_driver_t *tmp) if (tmp) driver->input = tmp; else - find_input_driver(); + input_driver_ctl(RARCH_INPUT_CTL_FIND_DRIVER, NULL); /* This should never really happen as tmp (driver.input) is always * found before this in find_driver_input(), or we have aborted diff --git a/input/input_driver.c b/input/input_driver.c index 2dfe0b0dee..5d9bc33153 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -112,30 +112,6 @@ const char* config_get_input_driver_options(void) return char_list_new_special(STRING_LIST_INPUT_DRIVERS, NULL); } -void find_input_driver(void) -{ - driver_t *driver = driver_get_ptr(); - settings_t *settings = config_get_ptr(); - int i = find_driver_index("input_driver", settings->input.driver); - - if (i >= 0) - driver->input = (const input_driver_t*)input_driver_find_handle(i); - else - { - unsigned d; - RARCH_ERR("Couldn't find any input driver named \"%s\"\n", - settings->input.driver); - RARCH_LOG_OUTPUT("Available input drivers are:\n"); - for (d = 0; input_driver_find_handle(d); d++) - RARCH_LOG_OUTPUT("\t%s\n", input_driver_find_ident(d)); - RARCH_WARN("Going to default to first input driver...\n"); - - driver->input = (const input_driver_t*)input_driver_find_handle(0); - - if (!driver->input) - retro_fail(1, "find_input_driver()"); - } -} const input_driver_t *input_get_ptr(void *data) { @@ -310,6 +286,31 @@ bool input_driver_ctl(enum rarch_input_ctl_state state, void *data) return driver->input->keyboard_mapping_is_blocked( driver->input_data); return false; + case RARCH_INPUT_CTL_FIND_DRIVER: + { + int i = find_driver_index("input_driver", settings->input.driver); + if (i >= 0) + driver->input = (const input_driver_t*)input_driver_find_handle(i); + else + { + unsigned d; + RARCH_ERR("Couldn't find any input driver named \"%s\"\n", + settings->input.driver); + RARCH_LOG_OUTPUT("Available input drivers are:\n"); + for (d = 0; input_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", input_driver_find_ident(d)); + RARCH_WARN("Going to default to first input driver...\n"); + + driver->input = (const input_driver_t*)input_driver_find_handle(0); + + if (!driver->input) + return false; + retro_fail(1, "find_input_driver()"); + return false; + } + } + + return true; case RARCH_INPUT_CTL_NONE: default: break; diff --git a/input/input_driver.h b/input/input_driver.h index 3d08813a80..cec8a8a945 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -51,6 +51,7 @@ enum rarch_input_ctl_state RARCH_INPUT_CTL_NONE = 0, RARCH_INPUT_CTL_INIT, RARCH_INPUT_CTL_DEINIT, + RARCH_INPUT_CTL_FIND_DRIVER, RARCH_INPUT_CTL_GRAB_STDIN, RARCH_INPUT_CTL_KB_MAPPING_IS_BLOCKED }; @@ -147,8 +148,6 @@ const char *input_driver_find_ident(int index); **/ const char* config_get_input_driver_options(void); -void find_input_driver(void); - /** * input_driver_set_rumble_state: * @port : User number.