mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 10:10:57 +00:00
Start wrapping settings->input.binds
This commit is contained in:
parent
129da8a802
commit
d66aff8fbd
@ -1159,10 +1159,10 @@ static void config_set_defaults(void)
|
||||
retro_assert(sizeof(settings->input.binds[0]) >= sizeof(retro_keybinds_1));
|
||||
retro_assert(sizeof(settings->input.binds[1]) >= sizeof(retro_keybinds_rest));
|
||||
|
||||
memcpy(settings->input.binds[0], retro_keybinds_1, sizeof(retro_keybinds_1));
|
||||
memcpy(input_config_get_binds(0), retro_keybinds_1, sizeof(retro_keybinds_1));
|
||||
|
||||
for (i = 1; i < MAX_USERS; i++)
|
||||
memcpy(settings->input.binds[i], retro_keybinds_rest,
|
||||
memcpy(input_config_get_binds(i), retro_keybinds_rest,
|
||||
sizeof(retro_keybinds_rest));
|
||||
|
||||
input_config_reset();
|
||||
@ -1174,8 +1174,9 @@ static void config_set_defaults(void)
|
||||
{
|
||||
for (j = 0; j < RARCH_BIND_LIST_END; j++)
|
||||
{
|
||||
if (settings->input.binds[i][j].valid)
|
||||
retro_assert(j == settings->input.binds[i][j].id);
|
||||
const struct retro_keybind *keyval = input_config_get_specific_bind(i, j);
|
||||
if (keyval->valid)
|
||||
retro_assert(j == keyval->id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2799,7 +2800,6 @@ static void save_keybind(config_file_t *conf, const char *prefix,
|
||||
static void save_keybinds_user(config_file_t *conf, unsigned user)
|
||||
{
|
||||
unsigned i = 0;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
for (i = 0; input_config_bind_map_get_valid(i); i++)
|
||||
{
|
||||
@ -2808,7 +2808,7 @@ static void save_keybinds_user(config_file_t *conf, unsigned user)
|
||||
|
||||
if (prefix)
|
||||
save_keybind(conf, prefix, input_config_bind_map_get_base(i),
|
||||
&settings->input.binds[user][i], true, true);
|
||||
input_config_get_specific_bind(user, i), true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2936,7 +2936,7 @@ bool config_save_autoconf_profile(const char *path, unsigned user)
|
||||
for (i = 0; i < RARCH_FIRST_META_KEY; i++)
|
||||
{
|
||||
save_keybind(conf, "input", input_config_bind_map_get_base(i),
|
||||
&settings->input.binds[user][i], false, false);
|
||||
input_config_get_specific_bind(user, i), false, false);
|
||||
}
|
||||
|
||||
ret = config_file_write(conf, autoconf_file);
|
||||
|
@ -114,7 +114,7 @@ static PyObject *py_read_input(PyObject *self, PyObject *args)
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
py_binds[i] = settings->input.binds[i];
|
||||
py_binds[i] = input_config_get_binds(i);
|
||||
|
||||
(void)self;
|
||||
|
||||
@ -143,7 +143,7 @@ static PyObject *py_read_analog(PyObject *self, PyObject *args)
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
py_binds[i] = settings->input.binds[i];
|
||||
py_binds[i] = input_config_get_binds(i);
|
||||
|
||||
(void)self;
|
||||
|
||||
@ -399,7 +399,7 @@ float py_state_get(py_state_t *handle, const char *id,
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
{
|
||||
struct retro_keybind *general_binds = settings->input.binds[i];
|
||||
struct retro_keybind *general_binds = input_config_get_binds(i);
|
||||
struct retro_keybind *auto_binds = input_autoconfigure_get_binds(i);
|
||||
enum analog_dpad_mode dpad_mode = settings->input.analog_dpad_mode[i];
|
||||
|
||||
@ -414,7 +414,7 @@ float py_state_get(py_state_t *handle, const char *id,
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
{
|
||||
struct retro_keybind *general_binds = settings->input.binds[i];
|
||||
struct retro_keybind *general_binds = input_config_get_binds(i);
|
||||
struct retro_keybind *auto_binds = input_autoconfigure_get_binds(i);
|
||||
input_pop_analog_dpad(general_binds);
|
||||
input_pop_analog_dpad(auto_binds);
|
||||
|
@ -1246,7 +1246,8 @@ static bool android_input_key_pressed(void *data, int key)
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if( settings->input.binds[0][key].valid
|
||||
&& android_keyboard_port_input_pressed(settings->input.binds[0],key))
|
||||
&& android_keyboard_port_input_pressed(input_config_get_binds(0),
|
||||
key))
|
||||
return true;
|
||||
|
||||
joypad_info.joy_idx = 0;
|
||||
|
@ -146,6 +146,18 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
const struct retro_keybind *input_config_get_specific_bind(unsigned i, unsigned j)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
return &settings->input.binds[i][j];
|
||||
}
|
||||
|
||||
struct retro_keybind *input_config_get_binds(unsigned i)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
return settings->input.binds[i];
|
||||
}
|
||||
|
||||
static const void *input_config_bind_map_get(unsigned i)
|
||||
{
|
||||
return (const struct input_bind_map*)&input_config_bind_map[i];
|
||||
|
@ -89,6 +89,10 @@ void input_config_set_vid(unsigned port, unsigned vid);
|
||||
|
||||
int32_t input_config_get_vid(unsigned port);
|
||||
|
||||
const struct retro_keybind *input_config_get_specific_bind(unsigned i, unsigned j);
|
||||
|
||||
struct retro_keybind *input_config_get_binds(unsigned i);
|
||||
|
||||
void input_config_reset(void);
|
||||
|
||||
#endif
|
||||
|
@ -25,6 +25,7 @@
|
||||
#endif
|
||||
|
||||
#include "input_driver.h"
|
||||
#include "input_config.h"
|
||||
#include "input_keyboard.h"
|
||||
#include "input_remapping.h"
|
||||
|
||||
@ -278,7 +279,7 @@ void input_poll(void)
|
||||
|
||||
for (i = 0; i < max_users; i++)
|
||||
{
|
||||
libretro_input_binds[i] = settings->input.binds[i];
|
||||
libretro_input_binds[i] = input_config_get_binds(i);
|
||||
input_driver_turbo_btns.frame_enable[i] = 0;
|
||||
}
|
||||
|
||||
@ -486,10 +487,10 @@ void state_tracker_update_input(uint16_t *input1, uint16_t *input2)
|
||||
|
||||
for (i = 0; i < max_users; i++)
|
||||
{
|
||||
struct retro_keybind *general_binds = settings->input.binds[i];
|
||||
struct retro_keybind *general_binds = input_config_get_binds(i);
|
||||
struct retro_keybind *auto_binds = input_autoconfigure_get_binds(i);
|
||||
enum analog_dpad_mode dpad_mode = (enum analog_dpad_mode)settings->input.analog_dpad_mode[i];
|
||||
binds[i] = settings->input.binds[i];
|
||||
binds[i] = input_config_get_binds(i);
|
||||
|
||||
if (dpad_mode == ANALOG_DPAD_NONE)
|
||||
continue;
|
||||
@ -528,7 +529,7 @@ void state_tracker_update_input(uint16_t *input1, uint16_t *input2)
|
||||
|
||||
for (i = 0; i < max_users; i++)
|
||||
{
|
||||
struct retro_keybind *general_binds = settings->input.binds[i];
|
||||
struct retro_keybind *general_binds = input_config_get_binds(i);
|
||||
struct retro_keybind *auto_binds = input_autoconfigure_get_binds(i);
|
||||
|
||||
input_pop_analog_dpad(general_binds);
|
||||
@ -565,10 +566,10 @@ static INLINE bool input_menu_keys_pressed_internal(
|
||||
joypad_info.axis_threshold = settings->input.axis_threshold;
|
||||
|
||||
if (sec && input_joypad_pressed(sec,
|
||||
joypad_info, port, settings->input.binds[0], i))
|
||||
joypad_info, port, input_config_get_binds(0), i))
|
||||
return true;
|
||||
if (first && input_joypad_pressed(first,
|
||||
joypad_info, port, settings->input.binds[0], i))
|
||||
joypad_info, port, input_config_get_binds(0), i))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -708,18 +709,19 @@ uint64_t input_menu_keys_pressed(
|
||||
&& current_input->keyboard_mapping_is_blocked(current_input_data))
|
||||
input_driver_block_hotkey = true;
|
||||
|
||||
binds_norm = &settings->input.binds[0][RARCH_ENABLE_HOTKEY];
|
||||
binds_norm = input_config_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++)
|
||||
binds[i] = settings->input.binds[i];
|
||||
binds[i] = input_config_get_binds(i);
|
||||
|
||||
if (check_input_driver_block_hotkey(binds_norm, binds_auto))
|
||||
{
|
||||
joypad_info.joy_idx = settings->input.joypad_map[0];
|
||||
joypad_info.auto_binds = input_autoconfigure_get_binds(joypad_info.joy_idx);
|
||||
const struct retro_keybind *htkey = input_config_get_specific_bind(0, RARCH_ENABLE_HOTKEY);
|
||||
|
||||
if (settings->input.binds[0][RARCH_ENABLE_HOTKEY].valid
|
||||
if (htkey->valid
|
||||
&& current_input->input_state(current_input_data, joypad_info,
|
||||
&binds[0], 0, RETRO_DEVICE_JOYPAD, 0, RARCH_ENABLE_HOTKEY))
|
||||
input_driver_block_libretro_input = true;
|
||||
@ -728,22 +730,27 @@ uint64_t input_menu_keys_pressed(
|
||||
}
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if ( ((settings->input.menu_toggle_gamepad_combo != INPUT_TOGGLE_NONE) &&
|
||||
input_driver_toggle_button_combo(
|
||||
settings->input.menu_toggle_gamepad_combo, &old_input))
|
||||
|| input_menu_keys_pressed_internal(
|
||||
binds, settings, joypad_info, RARCH_MENU_TOGGLE, max_users,
|
||||
settings->input.binds[0][RARCH_MENU_TOGGLE].valid,
|
||||
settings->input.all_users_control_menu))
|
||||
ret |= (UINT64_C(1) << RARCH_MENU_TOGGLE);
|
||||
{
|
||||
const struct retro_keybind *mtkey = input_config_get_specific_bind(0, RARCH_MENU_TOGGLE);
|
||||
if ( ((settings->input.menu_toggle_gamepad_combo != INPUT_TOGGLE_NONE) &&
|
||||
input_driver_toggle_button_combo(
|
||||
settings->input.menu_toggle_gamepad_combo, &old_input))
|
||||
|| input_menu_keys_pressed_internal(
|
||||
binds, settings, joypad_info, RARCH_MENU_TOGGLE, max_users,
|
||||
mtkey->valid,
|
||||
settings->input.all_users_control_menu))
|
||||
ret |= (UINT64_C(1) << RARCH_MENU_TOGGLE);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; i < RARCH_BIND_LIST_END; i++)
|
||||
{
|
||||
const struct retro_keybind *mtkey =
|
||||
input_config_get_specific_bind(0, i);
|
||||
if (i != RARCH_MENU_TOGGLE &&
|
||||
input_menu_keys_pressed_internal(binds,
|
||||
settings, joypad_info, i, max_users,
|
||||
settings->input.binds[0][i].valid,
|
||||
mtkey->valid,
|
||||
settings->input.all_users_control_menu))
|
||||
ret |= (UINT64_C(1) << i);
|
||||
|
||||
@ -758,6 +765,10 @@ uint64_t input_menu_keys_pressed(
|
||||
if (!menu_input_dialog_get_display_kb())
|
||||
{
|
||||
unsigned ids[13][2];
|
||||
const struct retro_keybind *quitkey =
|
||||
input_config_get_specific_bind(0, RARCH_QUIT_KEY);
|
||||
const struct retro_keybind *fskey =
|
||||
input_config_get_specific_bind(0, RARCH_FULLSCREEN_TOGGLE_KEY);
|
||||
|
||||
ids[0][0] = RETROK_SPACE;
|
||||
ids[0][1] = RETRO_DEVICE_ID_JOYPAD_START;
|
||||
@ -777,9 +788,9 @@ uint64_t input_menu_keys_pressed(
|
||||
ids[7][1] = RETRO_DEVICE_ID_JOYPAD_L;
|
||||
ids[8][0] = RETROK_PAGEDOWN;
|
||||
ids[8][1] = RETRO_DEVICE_ID_JOYPAD_R;
|
||||
ids[9][0] = settings->input.binds[0][RARCH_QUIT_KEY].key;
|
||||
ids[9][0] = quitkey->key;
|
||||
ids[9][1] = RARCH_QUIT_KEY;
|
||||
ids[10][0] = settings->input.binds[0][RARCH_FULLSCREEN_TOGGLE_KEY].key;
|
||||
ids[10][0] = fskey->key;
|
||||
ids[10][1] = RARCH_FULLSCREEN_TOGGLE_KEY;
|
||||
ids[11][0] = RETROK_BACKSPACE;
|
||||
ids[11][1] = RETRO_DEVICE_ID_JOYPAD_B;
|
||||
@ -904,13 +915,13 @@ uint64_t input_keys_pressed(
|
||||
rarch_joypad_info_t joypad_info;
|
||||
uint64_t ret = 0;
|
||||
settings_t *settings = config_get_ptr();
|
||||
const struct retro_keybind *binds = settings->input.binds[0];
|
||||
const struct retro_keybind *binds = input_config_get_binds(0);
|
||||
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 *focus_binds_auto = input_autoconfigure_get_specific_bind(0, RARCH_GAME_FOCUS_TOGGLE);
|
||||
const struct retro_keybind *focus_normal = &binds[RARCH_GAME_FOCUS_TOGGLE];
|
||||
bool enable_hotkey_valid = settings && settings->input.binds[0][RARCH_ENABLE_HOTKEY].valid;
|
||||
const struct retro_keybind *enable_hotkey = input_config_get_specific_bind(0, RARCH_ENABLE_HOTKEY);
|
||||
bool game_focus_toggle_valid = false;
|
||||
|
||||
joypad_info.joy_idx = 0;
|
||||
@ -928,7 +939,7 @@ uint64_t input_keys_pressed(
|
||||
{
|
||||
joypad_info.joy_idx = settings->input.joypad_map[0];
|
||||
joypad_info.auto_binds = input_autoconfigure_get_binds(joypad_info.joy_idx);
|
||||
if ( enable_hotkey_valid
|
||||
if ( enable_hotkey->valid
|
||||
&& current_input->input_state(
|
||||
current_input_data, joypad_info, &binds, 0,
|
||||
RETRO_DEVICE_JOYPAD, 0, RARCH_ENABLE_HOTKEY))
|
||||
|
@ -96,9 +96,7 @@ int menu_dialog_iterate(char *s, size_t len, const char *label)
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(binds); i++)
|
||||
{
|
||||
const struct retro_keybind *keybind =
|
||||
(const struct retro_keybind*)
|
||||
&settings->input.binds[0][binds[i]];
|
||||
const struct retro_keybind *keybind = input_config_get_specific_bind(0, binds[i]);
|
||||
const struct retro_keybind *auto_bind =
|
||||
(const struct retro_keybind*)
|
||||
input_config_get_bind_auto(0, binds[i]);
|
||||
|
@ -71,6 +71,7 @@
|
||||
#include "audio/audio_driver.h"
|
||||
#include "camera/camera_driver.h"
|
||||
#include "record/record_driver.h"
|
||||
#include "input/input_config.h"
|
||||
#include "input/input_driver.h"
|
||||
#include "ui/ui_companion_driver.h"
|
||||
#include "core.h"
|
||||
@ -1140,7 +1141,7 @@ int runloop_iterate(unsigned *sleep_ms)
|
||||
/* Update binds for analog dpad modes. */
|
||||
for (i = 0; i < settings->input.max_users; i++)
|
||||
{
|
||||
struct retro_keybind *general_binds = settings->input.binds[i];
|
||||
struct retro_keybind *general_binds = input_config_get_binds(i);
|
||||
struct retro_keybind *auto_binds = input_autoconfigure_get_binds(i);
|
||||
enum analog_dpad_mode dpad_mode = (enum analog_dpad_mode)settings->input.analog_dpad_mode[i];
|
||||
|
||||
@ -1163,7 +1164,7 @@ int runloop_iterate(unsigned *sleep_ms)
|
||||
|
||||
for (i = 0; i < settings->input.max_users; i++)
|
||||
{
|
||||
struct retro_keybind *general_binds = settings->input.binds[i];
|
||||
struct retro_keybind *general_binds = input_config_get_binds(i);
|
||||
struct retro_keybind *auto_binds = input_autoconfigure_get_binds(i);
|
||||
enum analog_dpad_mode dpad_mode = (enum analog_dpad_mode)settings->input.analog_dpad_mode[i];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user