From d181870caa447dc001ff63b60d9533b133f01de5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 29 Nov 2015 19:18:59 +0100 Subject: [PATCH] No more dependency on driver_t for driver->input --- driver.h | 1 - gfx/video_driver.c | 2 -- input/input_driver.c | 27 ++++++++++----------------- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/driver.h b/driver.h index d3fce34da7..5ecad2eb06 100644 --- a/driver.h +++ b/driver.h @@ -202,7 +202,6 @@ typedef struct driver { frontend_ctx_driver_t *frontend_ctx; const ui_companion_driver_t *ui_companion; - const input_driver_t *input; const camera_driver_t *camera; const location_driver_t *location; const record_driver_t *recording; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index f399542c74..b635733c6f 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -427,7 +427,6 @@ error: static void init_video_input(const input_driver_t *tmp) { - driver_t *driver = driver_get_ptr(); const input_driver_t **input = input_get_double_ptr(); if (*input) return; @@ -620,7 +619,6 @@ static bool init_video(void) const struct retro_game_geometry *geom = NULL; video_info_t video = {0}; static uint16_t dummy_pixels[32] = {0}; - driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); rarch_system_info_t *system = rarch_system_info_get_ptr(); struct retro_system_av_info *av_info = diff --git a/input/input_driver.c b/input/input_driver.c index 30bc608cd4..451a5a40c5 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -82,6 +82,7 @@ struct turbo_buttons unsigned count; }; +static const input_driver_t *main_input; static void *main_input_data; static bool flushing_input; static bool block_libretro_input; @@ -133,18 +134,12 @@ const char* config_get_input_driver_options(void) const input_driver_t *input_get_ptr(void) { - driver_t *driver = driver_get_ptr(); - if (!driver) - return NULL; - return driver->input; + return main_input; } const input_driver_t **input_get_double_ptr(void) { - driver_t *driver = driver_get_ptr(); - if (!driver) - return NULL; - return &driver->input; + return &main_input; } /** @@ -221,7 +216,7 @@ void input_driver_set(const input_driver_t **input, void **input_data) if (input && input_data) { - *input = driver->input; + *input = main_input; *input_data = main_input_data; } @@ -662,7 +657,6 @@ bool input_driver_data_ptr_is_same(void *data) bool input_driver_ctl(enum rarch_input_ctl_state state, void *data) { - driver_t *driver = driver_get_ptr(); const input_driver_t *input = input_get_ptr(); settings_t *settings = config_get_ptr(); @@ -676,14 +670,14 @@ bool input_driver_ctl(enum rarch_input_ctl_state state, void *data) input->poll(main_input_data); return true; case RARCH_INPUT_CTL_INIT: - if (driver && input) + if (input) main_input_data = input->init(); if (!main_input_data) return false; return true; case RARCH_INPUT_CTL_DEINIT: - if (!driver || !input) + if (!input) return false; input->free(main_input_data); return true; @@ -692,8 +686,7 @@ bool input_driver_ctl(enum rarch_input_ctl_state state, void *data) block_hotkey = false; nonblock_state = false; memset(&turbo_btns, 0, sizeof(turbo_buttons_t)); - if (!driver) - return false; + main_input = NULL; main_input_data = NULL; return true; case RARCH_INPUT_CTL_GRAB_STDIN: @@ -709,7 +702,7 @@ bool input_driver_ctl(enum rarch_input_ctl_state state, void *data) { int i = find_driver_index("input_driver", settings->input.driver); if (i >= 0) - driver->input = (const input_driver_t*)input_driver_find_handle(i); + main_input = (const input_driver_t*)input_driver_find_handle(i); else { unsigned d; @@ -720,9 +713,9 @@ bool input_driver_ctl(enum rarch_input_ctl_state state, void *data) 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); + main_input = (const input_driver_t*)input_driver_find_handle(0); - if (!driver->input) + if (!main_input) return false; retro_fail(1, "find_input_driver()"); return false;