From eb895f99474eb1d1b9f01de51b6e47dd990859ea Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 18 Sep 2021 21:14:15 +0200 Subject: [PATCH] move more code out of retroarch.c --- input/input_driver.c | 23 +++++++++++++++++++++++ input/input_remapping.h | 14 ++++++++++++++ retroarch.c | 21 --------------------- retroarch_data.h | 12 ------------ 4 files changed, 37 insertions(+), 33 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index 16b05f6bc5..b035fce588 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -24,6 +24,7 @@ #include "input_driver.h" #include "input_keymaps.h" +#include "input_remapping.h" #include "input_osk.h" #ifdef HAVE_NETWORKING @@ -2143,3 +2144,25 @@ bool input_driver_find_driver( return true; } + +void input_mapper_reset(void *data) +{ + unsigned i; + input_mapper_t *handle = (input_mapper_t*)data; + + for (i = 0; i < MAX_USERS; i++) + { + unsigned j; + for (j = 0; j < 8; j++) + { + handle->analog_value[i][j] = 0; + handle->buttons[i].data[j] = 0; + handle->buttons[i].analogs[j] = 0; + handle->buttons[i].analog_buttons[j] = 0; + } + } + for (i = 0; i < RETROK_LAST; i++) + handle->key_button[i] = 0; + for (i = 0; i < (RETROK_LAST / 32 + 1); i++) + handle->keys[i] = 0; +} diff --git a/input/input_remapping.h b/input/input_remapping.h index 3a79f79371..2eef5fb252 100644 --- a/input/input_remapping.h +++ b/input/input_remapping.h @@ -23,6 +23,18 @@ #include #include +typedef struct input_mapper +{ + /* Left X, Left Y, Right X, Right Y */ + int16_t analog_value[MAX_USERS][8]; + /* The whole keyboard state */ + uint32_t keys[RETROK_LAST / 32 + 1]; + /* RetroPad button state of remapped keyboard keys */ + unsigned key_button[RETROK_LAST]; + /* This is a bitmask of (1 << key_bind_id). */ + input_bits_t buttons[MAX_USERS]; +} input_mapper_t; + RETRO_BEGIN_DECLS /** @@ -183,6 +195,8 @@ void config_read_keybinds_conf(void *data); */ void input_config_set_autoconfig_binds(unsigned port, void *data); +void input_mapper_reset(void *data); + RETRO_END_DECLS #endif diff --git a/retroarch.c b/retroarch.c index aa9026692b..64b109e347 100644 --- a/retroarch.c +++ b/retroarch.c @@ -28911,27 +28911,6 @@ static const menu_ctx_driver_t *menu_driver_find_driver( } #endif -static void input_mapper_reset(input_mapper_t *handle) -{ - unsigned i; - for (i = 0; i < MAX_USERS; i++) - { - unsigned j; - for (j = 0; j < 8; j++) - { - handle->analog_value[i][j] = 0; - handle->buttons[i].data[j] = 0; - handle->buttons[i].analogs[j] = 0; - handle->buttons[i].analog_buttons[j] = 0; - } - } - for (i = 0; i < RETROK_LAST; i++) - handle->key_button[i] = 0; - for (i = 0; i < (RETROK_LAST / 32 + 1); i++) - handle->keys[i] = 0; -} - - /** * retroarch_main_init: * @argc : Count of (commandline) arguments. diff --git a/retroarch_data.h b/retroarch_data.h index 223290bd5e..7e8d7e6394 100644 --- a/retroarch_data.h +++ b/retroarch_data.h @@ -1075,18 +1075,6 @@ typedef struct input_game_focus_state typedef bool(*runahead_load_state_function)(const void*, size_t); #endif -typedef struct input_mapper -{ - /* Left X, Left Y, Right X, Right Y */ - int16_t analog_value[MAX_USERS][8]; - /* The whole keyboard state */ - uint32_t keys[RETROK_LAST / 32 + 1]; - /* RetroPad button state of remapped keyboard keys */ - unsigned key_button[RETROK_LAST]; - /* This is a bitmask of (1 << key_bind_id). */ - input_bits_t buttons[MAX_USERS]; -} input_mapper_t; - #ifdef HAVE_DISCORD /* The Discord API specifies these variables: - userId --------- char[24] - the userId of the player asking to join