Don't go through all these slow wrapper functions

This commit is contained in:
twinaphex 2017-04-25 20:47:21 +02:00
parent 840034d4a0
commit 3087ceb482
6 changed files with 54 additions and 54 deletions

View File

@ -81,7 +81,8 @@ static const char *bind_user_prefix[MAX_USERS] = {
static int input_config_vid[MAX_USERS]; static int input_config_vid[MAX_USERS];
static int input_config_pid[MAX_USERS]; static int input_config_pid[MAX_USERS];
static struct retro_keybind input_config_binds[MAX_USERS][RARCH_BIND_LIST_END]; struct retro_keybind input_config_binds[MAX_USERS][RARCH_BIND_LIST_END];
struct retro_keybind input_autoconf_binds[MAX_USERS][RARCH_BIND_LIST_END];
#define DECLARE_BIND(x, bind, desc) { true, 0, #x, desc, bind } #define DECLARE_BIND(x, bind, desc) { true, 0, #x, desc, bind }
#define DECLARE_META_BIND(level, x, bind, desc) { true, level, #x, desc, bind } #define DECLARE_META_BIND(level, x, bind, desc) { true, level, #x, desc, bind }
@ -607,3 +608,13 @@ void input_config_reset(void)
input_config_pid[i] = 0; input_config_pid[i] = 0;
} }
} }
const struct retro_keybind *input_autoconfigure_get_specific_bind(unsigned i, unsigned j)
{
return &input_autoconf_binds[i][j];
}
struct retro_keybind *input_autoconfigure_get_binds(unsigned i)
{
return input_autoconf_binds[i];
}

View File

@ -21,6 +21,9 @@
#include "input_driver.h" #include "input_driver.h"
extern struct retro_keybind input_config_binds[MAX_USERS][RARCH_BIND_LIST_END];
extern struct retro_keybind input_autoconf_binds[MAX_USERS][RARCH_BIND_LIST_END];
const char *input_config_bind_map_get_base(unsigned i); const char *input_config_bind_map_get_base(unsigned i);
unsigned input_config_bind_map_get_meta(unsigned i); unsigned input_config_bind_map_get_meta(unsigned i);
@ -95,6 +98,11 @@ const struct retro_keybind *input_config_get_specific_bind(unsigned i, unsigned
struct retro_keybind *input_config_get_binds(unsigned i); struct retro_keybind *input_config_get_binds(unsigned i);
const struct retro_keybind *
input_autoconfigure_get_specific_bind(unsigned i, unsigned j);
struct retro_keybind *input_autoconfigure_get_binds(unsigned i);
void input_config_reset(void); void input_config_reset(void);
#endif #endif

View File

@ -279,7 +279,7 @@ void input_poll(void)
for (i = 0; i < max_users; i++) for (i = 0; i < max_users; i++)
{ {
libretro_input_binds[i] = input_config_get_binds(i); libretro_input_binds[i] = input_config_binds[i];
input_driver_turbo_btns.frame_enable[i] = 0; input_driver_turbo_btns.frame_enable[i] = 0;
} }
@ -293,7 +293,7 @@ void input_poll(void)
if (libretro_input_binds[i][RARCH_TURBO_ENABLE].valid) if (libretro_input_binds[i][RARCH_TURBO_ENABLE].valid)
{ {
joypad_info.joy_idx = settings->input.joypad_map[i]; joypad_info.joy_idx = settings->input.joypad_map[i];
joypad_info.auto_binds = input_autoconfigure_get_binds(joypad_info.joy_idx); joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx];
input_driver_turbo_btns.frame_enable[i] = current_input->input_state( input_driver_turbo_btns.frame_enable[i] = current_input->input_state(
current_input_data, joypad_info, libretro_input_binds, current_input_data, joypad_info, libretro_input_binds,
@ -387,7 +387,7 @@ int16_t input_state(unsigned port, unsigned device,
joypad_info.axis_threshold = settings->input.axis_threshold; joypad_info.axis_threshold = settings->input.axis_threshold;
joypad_info.joy_idx = settings->input.joypad_map[port]; joypad_info.joy_idx = settings->input.joypad_map[port];
joypad_info.auto_binds = input_autoconfigure_get_binds(joypad_info.joy_idx); joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx];
res = current_input->input_state( res = current_input->input_state(
current_input_data, joypad_info, libretro_input_binds, port, device, idx, id); current_input_data, joypad_info, libretro_input_binds, port, device, idx, id);
@ -487,10 +487,10 @@ void state_tracker_update_input(uint16_t *input1, uint16_t *input2)
for (i = 0; i < max_users; i++) for (i = 0; i < max_users; i++)
{ {
struct retro_keybind *general_binds = input_config_get_binds(i); struct retro_keybind *general_binds = input_config_binds[i];
struct retro_keybind *auto_binds = input_autoconfigure_get_binds(i); struct retro_keybind *auto_binds = input_autoconf_binds[i];
enum analog_dpad_mode dpad_mode = (enum analog_dpad_mode)settings->input.analog_dpad_mode[i]; enum analog_dpad_mode dpad_mode = (enum analog_dpad_mode)settings->input.analog_dpad_mode[i];
binds[i] = input_config_get_binds(i); binds[i] = input_config_binds[i];
if (dpad_mode == ANALOG_DPAD_NONE) if (dpad_mode == ANALOG_DPAD_NONE)
continue; continue;
@ -511,7 +511,7 @@ void state_tracker_update_input(uint16_t *input1, uint16_t *input2)
if (binds[0][id].valid) if (binds[0][id].valid)
{ {
joypad_info.joy_idx = settings->input.joypad_map[0]; joypad_info.joy_idx = settings->input.joypad_map[0];
joypad_info.auto_binds = input_autoconfigure_get_binds(joypad_info.joy_idx); joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx];
*input1 |= (current_input->input_state(current_input_data, joypad_info, *input1 |= (current_input->input_state(current_input_data, joypad_info,
binds, binds,
0, RETRO_DEVICE_JOYPAD, 0, id) ? 1 : 0) << i; 0, RETRO_DEVICE_JOYPAD, 0, id) ? 1 : 0) << i;
@ -519,7 +519,7 @@ void state_tracker_update_input(uint16_t *input1, uint16_t *input2)
if (binds[1][id].valid) if (binds[1][id].valid)
{ {
joypad_info.joy_idx = settings->input.joypad_map[1]; joypad_info.joy_idx = settings->input.joypad_map[1];
joypad_info.auto_binds = input_autoconfigure_get_binds(joypad_info.joy_idx); joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx];
*input2 |= (current_input->input_state(current_input_data, joypad_info, *input2 |= (current_input->input_state(current_input_data, joypad_info,
binds, binds,
1, RETRO_DEVICE_JOYPAD, 0, id) ? 1 : 0) << i; 1, RETRO_DEVICE_JOYPAD, 0, id) ? 1 : 0) << i;
@ -529,8 +529,8 @@ void state_tracker_update_input(uint16_t *input1, uint16_t *input2)
for (i = 0; i < max_users; i++) for (i = 0; i < max_users; i++)
{ {
struct retro_keybind *general_binds = input_config_get_binds(i); struct retro_keybind *general_binds = input_config_binds[i];
struct retro_keybind *auto_binds = input_autoconfigure_get_binds(i); struct retro_keybind *auto_binds = input_autoconf_binds[i];
input_pop_analog_dpad(general_binds); input_pop_analog_dpad(general_binds);
input_pop_analog_dpad(auto_binds); input_pop_analog_dpad(auto_binds);
@ -562,14 +562,14 @@ static INLINE bool input_menu_keys_pressed_internal(
? current_input->get_sec_joypad_driver(current_input_data) : NULL; ? current_input->get_sec_joypad_driver(current_input_data) : NULL;
joypad_info.joy_idx = settings->input.joypad_map[port]; joypad_info.joy_idx = settings->input.joypad_map[port];
joypad_info.auto_binds = input_autoconfigure_get_binds(joypad_info.joy_idx); joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx];
joypad_info.axis_threshold = settings->input.axis_threshold; joypad_info.axis_threshold = settings->input.axis_threshold;
if (sec && input_joypad_pressed(sec, if (sec && input_joypad_pressed(sec,
joypad_info, port, input_config_get_binds(0), i)) joypad_info, port, input_config_binds[0], i))
return true; return true;
if (first && input_joypad_pressed(first, if (first && input_joypad_pressed(first,
joypad_info, port, input_config_get_binds(0), i)) joypad_info, port, input_config_binds[0], i))
return true; return true;
} }
} }
@ -693,7 +693,7 @@ uint64_t input_menu_keys_pressed(
for (i = 0; i < max_users; i++) for (i = 0; i < max_users; i++)
{ {
struct retro_keybind *auto_binds = input_autoconfigure_get_binds(i); struct retro_keybind *auto_binds = input_autoconf_binds[i];
input_push_analog_dpad(auto_binds, ANALOG_DPAD_LSTICK); input_push_analog_dpad(auto_binds, ANALOG_DPAD_LSTICK);
} }
@ -709,17 +709,17 @@ uint64_t input_menu_keys_pressed(
&& current_input->keyboard_mapping_is_blocked(current_input_data)) && current_input->keyboard_mapping_is_blocked(current_input_data))
input_driver_block_hotkey = true; input_driver_block_hotkey = true;
binds_norm = input_config_get_specific_bind(0, RARCH_ENABLE_HOTKEY); binds_norm = &input_config_binds[0][RARCH_ENABLE_HOTKEY];
binds_auto = input_autoconfigure_get_specific_bind(0, RARCH_ENABLE_HOTKEY); binds_auto = input_autoconfigure_get_specific_bind(0, RARCH_ENABLE_HOTKEY);
for (i = 0; i < max_users; i++) for (i = 0; i < max_users; i++)
binds[i] = input_config_get_binds(i); binds[i] = input_config_binds[i];
if (check_input_driver_block_hotkey(binds_norm, binds_auto)) if (check_input_driver_block_hotkey(binds_norm, binds_auto))
{ {
joypad_info.joy_idx = settings->input.joypad_map[0]; joypad_info.joy_idx = settings->input.joypad_map[0];
joypad_info.auto_binds = input_autoconfigure_get_binds(joypad_info.joy_idx); joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx];
const struct retro_keybind *htkey = input_config_get_specific_bind(0, RARCH_ENABLE_HOTKEY); const struct retro_keybind *htkey = &input_config_binds[0][RARCH_ENABLE_HOTKEY];
if (htkey->valid if (htkey->valid
&& current_input->input_state(current_input_data, joypad_info, && current_input->input_state(current_input_data, joypad_info,
@ -731,7 +731,7 @@ uint64_t input_menu_keys_pressed(
#ifdef HAVE_MENU #ifdef HAVE_MENU
{ {
const struct retro_keybind *mtkey = input_config_get_specific_bind(0, RARCH_MENU_TOGGLE); const struct retro_keybind *mtkey = &input_config_binds[0][RARCH_MENU_TOGGLE];
if ( ((settings->input.menu_toggle_gamepad_combo != INPUT_TOGGLE_NONE) && if ( ((settings->input.menu_toggle_gamepad_combo != INPUT_TOGGLE_NONE) &&
input_driver_toggle_button_combo( input_driver_toggle_button_combo(
settings->input.menu_toggle_gamepad_combo, &old_input)) settings->input.menu_toggle_gamepad_combo, &old_input))
@ -745,8 +745,7 @@ uint64_t input_menu_keys_pressed(
for (i = 0; i < RARCH_BIND_LIST_END; i++) for (i = 0; i < RARCH_BIND_LIST_END; i++)
{ {
const struct retro_keybind *mtkey = const struct retro_keybind *mtkey = &input_config_binds[0][i];
input_config_get_specific_bind(0, i);
if (i != RARCH_MENU_TOGGLE && if (i != RARCH_MENU_TOGGLE &&
input_menu_keys_pressed_internal(binds, input_menu_keys_pressed_internal(binds,
settings, joypad_info, i, max_users, settings, joypad_info, i, max_users,
@ -758,17 +757,15 @@ uint64_t input_menu_keys_pressed(
for (i = 0; i < max_users; i++) for (i = 0; i < max_users; i++)
{ {
struct retro_keybind *auto_binds = input_autoconfigure_get_binds(i); struct retro_keybind *auto_binds = input_autoconf_binds[i];
input_pop_analog_dpad(auto_binds); input_pop_analog_dpad(auto_binds);
} }
if (!menu_input_dialog_get_display_kb()) if (!menu_input_dialog_get_display_kb())
{ {
unsigned ids[13][2]; unsigned ids[13][2];
const struct retro_keybind *quitkey = const struct retro_keybind *quitkey = &input_config_binds[0][RARCH_QUIT_KEY];
input_config_get_specific_bind(0, RARCH_QUIT_KEY); const struct retro_keybind *fskey = &input_config_binds[0][RARCH_FULLSCREEN_TOGGLE_KEY];
const struct retro_keybind *fskey =
input_config_get_specific_bind(0, RARCH_FULLSCREEN_TOGGLE_KEY);
ids[0][0] = RETROK_SPACE; ids[0][0] = RETROK_SPACE;
ids[0][1] = RETRO_DEVICE_ID_JOYPAD_START; ids[0][1] = RETRO_DEVICE_ID_JOYPAD_START;
@ -848,7 +845,7 @@ static INLINE bool input_keys_pressed_internal(
bool bind_valid = binds[i].valid; bool bind_valid = binds[i].valid;
joypad_info.joy_idx = settings->input.joypad_map[0]; joypad_info.joy_idx = settings->input.joypad_map[0];
joypad_info.auto_binds = input_autoconfigure_get_binds(joypad_info.joy_idx); joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx];
joypad_info.axis_threshold = settings->input.axis_threshold; joypad_info.axis_threshold = settings->input.axis_threshold;
if (bind_valid && current_input->input_state(current_input_data, if (bind_valid && current_input->input_state(current_input_data,
@ -915,13 +912,13 @@ uint64_t input_keys_pressed(
rarch_joypad_info_t joypad_info; rarch_joypad_info_t joypad_info;
uint64_t ret = 0; uint64_t ret = 0;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
const struct retro_keybind *binds = input_config_get_binds(0); const struct retro_keybind *binds = input_config_binds[0];
const struct retro_keybind *binds_auto = input_autoconfigure_get_specific_bind(0, RARCH_ENABLE_HOTKEY); const struct retro_keybind *binds_auto = input_autoconfigure_get_specific_bind(0, RARCH_ENABLE_HOTKEY);
const struct retro_keybind *binds_norm = &binds[RARCH_ENABLE_HOTKEY]; const struct retro_keybind *binds_norm = &binds[RARCH_ENABLE_HOTKEY];
const struct retro_keybind *focus_binds_auto = input_autoconfigure_get_specific_bind(0, RARCH_GAME_FOCUS_TOGGLE); const struct retro_keybind *focus_binds_auto = input_autoconfigure_get_specific_bind(0, RARCH_GAME_FOCUS_TOGGLE);
const struct retro_keybind *focus_normal = &binds[RARCH_GAME_FOCUS_TOGGLE]; const struct retro_keybind *focus_normal = &binds[RARCH_GAME_FOCUS_TOGGLE];
const struct retro_keybind *enable_hotkey = input_config_get_specific_bind(0, RARCH_ENABLE_HOTKEY); const struct retro_keybind *enable_hotkey = &input_config_binds[0][RARCH_ENABLE_HOTKEY];
bool game_focus_toggle_valid = false; bool game_focus_toggle_valid = false;
joypad_info.joy_idx = 0; joypad_info.joy_idx = 0;
@ -938,7 +935,7 @@ uint64_t input_keys_pressed(
if (check_input_driver_block_hotkey(binds_norm, binds_auto)) if (check_input_driver_block_hotkey(binds_norm, binds_auto))
{ {
joypad_info.joy_idx = settings->input.joypad_map[0]; joypad_info.joy_idx = settings->input.joypad_map[0];
joypad_info.auto_binds = input_autoconfigure_get_binds(joypad_info.joy_idx); joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx];
if ( enable_hotkey->valid if ( enable_hotkey->valid
&& current_input->input_state( && current_input->input_state(
current_input_data, joypad_info, &binds, 0, current_input_data, joypad_info, &binds, 0,
@ -956,7 +953,7 @@ uint64_t input_keys_pressed(
focus_normal, focus_binds_auto) && game_focus_toggle_valid) focus_normal, focus_binds_auto) && game_focus_toggle_valid)
{ {
joypad_info.joy_idx = settings->input.joypad_map[0]; joypad_info.joy_idx = settings->input.joypad_map[0];
joypad_info.auto_binds = input_autoconfigure_get_binds(joypad_info.joy_idx); joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx];
if (current_input->input_state(current_input_data, joypad_info, &binds, 0, if (current_input->input_state(current_input_data, joypad_info, &binds, 0,
RETRO_DEVICE_JOYPAD, 0, RARCH_GAME_FOCUS_TOGGLE)) RETRO_DEVICE_JOYPAD, 0, RARCH_GAME_FOCUS_TOGGLE))
input_driver_block_hotkey = false; input_driver_block_hotkey = false;
@ -1026,7 +1023,7 @@ bool input_driver_init(void)
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
for (i = 0; i < MAX_USERS; i++) for (i = 0; i < MAX_USERS; i++)
libretro_input_binds[i] = input_config_get_binds(i); libretro_input_binds[i] = input_config_binds[i];
if (current_input) if (current_input)
current_input_data = current_input->init(settings->input.joypad_driver); current_input_data = current_input->init(settings->input.joypad_driver);

View File

@ -1141,8 +1141,8 @@ int runloop_iterate(unsigned *sleep_ms)
/* Update binds for analog dpad modes. */ /* Update binds for analog dpad modes. */
for (i = 0; i < settings->input.max_users; i++) for (i = 0; i < settings->input.max_users; i++)
{ {
struct retro_keybind *general_binds = input_config_get_binds(i); struct retro_keybind *general_binds = input_config_binds[i];
struct retro_keybind *auto_binds = input_autoconfigure_get_binds(i); struct retro_keybind *auto_binds = input_autoconf_binds[i];
enum analog_dpad_mode dpad_mode = (enum analog_dpad_mode)settings->input.analog_dpad_mode[i]; enum analog_dpad_mode dpad_mode = (enum analog_dpad_mode)settings->input.analog_dpad_mode[i];
if (dpad_mode == ANALOG_DPAD_NONE) if (dpad_mode == ANALOG_DPAD_NONE)
@ -1164,8 +1164,8 @@ int runloop_iterate(unsigned *sleep_ms)
for (i = 0; i < settings->input.max_users; i++) for (i = 0; i < settings->input.max_users; i++)
{ {
struct retro_keybind *general_binds = input_config_get_binds(i); struct retro_keybind *general_binds = input_config_binds[i];
struct retro_keybind *auto_binds = input_autoconfigure_get_binds(i); struct retro_keybind *auto_binds = input_autoconf_binds[i];
enum analog_dpad_mode dpad_mode = (enum analog_dpad_mode)settings->input.analog_dpad_mode[i]; enum analog_dpad_mode dpad_mode = (enum analog_dpad_mode)settings->input.analog_dpad_mode[i];
if (dpad_mode == ANALOG_DPAD_NONE) if (dpad_mode == ANALOG_DPAD_NONE)

View File

@ -51,7 +51,6 @@ typedef struct autoconfig_params
} autoconfig_params_t; } autoconfig_params_t;
static bool input_autoconfigured[MAX_USERS]; static bool input_autoconfigured[MAX_USERS];
static struct retro_keybind input_autoconf_binds[MAX_USERS][RARCH_BIND_LIST_END];
static unsigned input_device_name_index[MAX_USERS]; static unsigned input_device_name_index[MAX_USERS];
/* Adds an index for devices with the same name, /* Adds an index for devices with the same name,
@ -395,16 +394,6 @@ error:
return false; return false;
} }
const struct retro_keybind *input_autoconfigure_get_specific_bind(unsigned i, unsigned j)
{
return &input_autoconf_binds[i][j];
}
struct retro_keybind *input_autoconfigure_get_binds(unsigned i)
{
return input_autoconf_binds[i];
}
void input_autoconfigure_reset(void) void input_autoconfigure_reset(void)
{ {
unsigned i, j; unsigned i, j;

View File

@ -221,11 +221,6 @@ void path_init_savefile_new(void);
bool input_is_autoconfigured(unsigned i); bool input_is_autoconfigured(unsigned i);
const struct retro_keybind *
input_autoconfigure_get_specific_bind(unsigned i, unsigned j);
struct retro_keybind *input_autoconfigure_get_binds(unsigned i);
unsigned input_autoconfigure_get_device_name_index(unsigned i); unsigned input_autoconfigure_get_device_name_index(unsigned i);
void input_autoconfigure_reset(void); void input_autoconfigure_reset(void);