From e2d510e4f60f6c410f80b5f8eb06df9945d974c0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 10 Jul 2015 18:44:11 +0200 Subject: [PATCH] (GX) No longer depend on global pointer in input driver --- input/drivers/gx_input.c | 4 ++-- input/drivers_joypad/gx_joypad.c | 7 +++---- input/input_driver.c | 8 ++++++++ input/input_driver.h | 2 ++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/input/drivers/gx_input.c b/input/drivers/gx_input.c index 1e17fd7472..178f2690e9 100644 --- a/input/drivers/gx_input.c +++ b/input/drivers/gx_input.c @@ -37,6 +37,7 @@ typedef struct gx_input { bool blocked; const input_device_driver_t *joypad; + uint64_t lifecycle_state; } gx_input_t; static int16_t gx_input_state(void *data, const struct retro_keybind **binds, @@ -94,9 +95,8 @@ static void gx_input_poll(void *data) static bool gx_input_key_pressed(void *data, int key) { settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); gx_input_t *gx = (gx_input_t*)data; - return (global->lifecycle_state & (1ULL << key)) || + return (gx->lifecycle_state & (1ULL << key)) || input_joypad_pressed(gx->joypad, 0, settings->input.binds[0], key); } diff --git a/input/drivers_joypad/gx_joypad.c b/input/drivers_joypad/gx_joypad.c index 49d3c34857..00df9a0918 100644 --- a/input/drivers_joypad/gx_joypad.c +++ b/input/drivers_joypad/gx_joypad.c @@ -350,7 +350,7 @@ static void gx_joypad_poll(void) { unsigned i, j, port; uint8_t gcpad = 0; - global_t *global = global_get_ptr(); + gx_input_t *gx = (gx_input_t*)input_driver_get_ptr(); pad_state[0] = 0; pad_state[1] = 0; @@ -540,9 +540,8 @@ static void gx_joypad_poll(void) } uint64_t *state_p1 = &pad_state[0]; - uint64_t *lifecycle_state = &global->lifecycle_state; - *lifecycle_state &= ~((1ULL << RARCH_MENU_TOGGLE)); + gx->lifecycle_state &= ~((1ULL << RARCH_MENU_TOGGLE)); if (g_menu) { @@ -555,7 +554,7 @@ static void gx_joypad_poll(void) | (1ULL << GX_CLASSIC_HOME) #endif )) - *lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE); + gx->lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE); } static bool gx_joypad_init(void *data) diff --git a/input/input_driver.c b/input/input_driver.c index 81e121a7d0..b5c4c5559d 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -178,6 +178,14 @@ static const input_driver_t *input_get_ptr(driver_t *driver) return driver->input; } +input_driver_t *input_driver_get_ptr(void) +{ + driver_t *driver = driver_get_ptr(); + if (!driver) + return NULL; + return driver->input_data; +} + /** * input_driver_set_rumble_state: * @port : User number. diff --git a/input/input_driver.h b/input/input_driver.h index 9d0414529b..d921bc2236 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -98,6 +98,8 @@ extern input_driver_t input_qnx; extern input_driver_t input_rwebinput; extern input_driver_t input_null; +input_driver_t *input_driver_get_ptr(void); + /** * input_driver_find_handle: * @index : index of driver to get handle to.