No more dependency on driver_t for driver->input

This commit is contained in:
twinaphex 2015-11-29 19:18:59 +01:00
parent 7a6f444823
commit d181870caa
3 changed files with 10 additions and 20 deletions

View File

@ -202,7 +202,6 @@ typedef struct driver
{ {
frontend_ctx_driver_t *frontend_ctx; frontend_ctx_driver_t *frontend_ctx;
const ui_companion_driver_t *ui_companion; const ui_companion_driver_t *ui_companion;
const input_driver_t *input;
const camera_driver_t *camera; const camera_driver_t *camera;
const location_driver_t *location; const location_driver_t *location;
const record_driver_t *recording; const record_driver_t *recording;

View File

@ -427,7 +427,6 @@ error:
static void init_video_input(const input_driver_t *tmp) 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(); const input_driver_t **input = input_get_double_ptr();
if (*input) if (*input)
return; return;
@ -620,7 +619,6 @@ static bool init_video(void)
const struct retro_game_geometry *geom = NULL; const struct retro_game_geometry *geom = NULL;
video_info_t video = {0}; video_info_t video = {0};
static uint16_t dummy_pixels[32] = {0}; static uint16_t dummy_pixels[32] = {0};
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
rarch_system_info_t *system = rarch_system_info_get_ptr(); rarch_system_info_t *system = rarch_system_info_get_ptr();
struct retro_system_av_info *av_info = struct retro_system_av_info *av_info =

View File

@ -82,6 +82,7 @@ struct turbo_buttons
unsigned count; unsigned count;
}; };
static const input_driver_t *main_input;
static void *main_input_data; static void *main_input_data;
static bool flushing_input; static bool flushing_input;
static bool block_libretro_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) const input_driver_t *input_get_ptr(void)
{ {
driver_t *driver = driver_get_ptr(); return main_input;
if (!driver)
return NULL;
return driver->input;
} }
const input_driver_t **input_get_double_ptr(void) const input_driver_t **input_get_double_ptr(void)
{ {
driver_t *driver = driver_get_ptr(); return &main_input;
if (!driver)
return NULL;
return &driver->input;
} }
/** /**
@ -221,7 +216,7 @@ void input_driver_set(const input_driver_t **input, void **input_data)
if (input && input_data) if (input && input_data)
{ {
*input = driver->input; *input = main_input;
*input_data = main_input_data; *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) 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(); const input_driver_t *input = input_get_ptr();
settings_t *settings = config_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); input->poll(main_input_data);
return true; return true;
case RARCH_INPUT_CTL_INIT: case RARCH_INPUT_CTL_INIT:
if (driver && input) if (input)
main_input_data = input->init(); main_input_data = input->init();
if (!main_input_data) if (!main_input_data)
return false; return false;
return true; return true;
case RARCH_INPUT_CTL_DEINIT: case RARCH_INPUT_CTL_DEINIT:
if (!driver || !input) if (!input)
return false; return false;
input->free(main_input_data); input->free(main_input_data);
return true; return true;
@ -692,8 +686,7 @@ bool input_driver_ctl(enum rarch_input_ctl_state state, void *data)
block_hotkey = false; block_hotkey = false;
nonblock_state = false; nonblock_state = false;
memset(&turbo_btns, 0, sizeof(turbo_buttons_t)); memset(&turbo_btns, 0, sizeof(turbo_buttons_t));
if (!driver) main_input = NULL;
return false;
main_input_data = NULL; main_input_data = NULL;
return true; return true;
case RARCH_INPUT_CTL_GRAB_STDIN: 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); int i = find_driver_index("input_driver", settings->input.driver);
if (i >= 0) 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 else
{ {
unsigned d; 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_LOG_OUTPUT("\t%s\n", input_driver_find_ident(d));
RARCH_WARN("Going to default to first input driver...\n"); 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; return false;
retro_fail(1, "find_input_driver()"); retro_fail(1, "find_input_driver()");
return false; return false;