mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
Pass device input mask to menu_input_frame
This commit is contained in:
parent
1a20e19c51
commit
6512e95945
@ -197,7 +197,7 @@ bool input_driver_set_rumble_state(unsigned port,
|
||||
return false;
|
||||
}
|
||||
|
||||
retro_input_t input_driver_keys_pressed(void)
|
||||
retro_input_t input_driver_keys_pressed(uint64_t *device_type)
|
||||
{
|
||||
int key;
|
||||
retro_input_t ret = 0;
|
||||
@ -207,13 +207,16 @@ retro_input_t input_driver_keys_pressed(void)
|
||||
for (key = 0; key < RARCH_BIND_LIST_END; key++)
|
||||
{
|
||||
bool state = false;
|
||||
enum input_device_type type = INPUT_DEVICE_TYPE_NONE;
|
||||
enum input_device_type device = INPUT_DEVICE_TYPE_NONE;
|
||||
if ((!driver->block_libretro_input && ((key < RARCH_FIRST_META_KEY)))
|
||||
|| !driver->block_hotkey)
|
||||
state = input->key_pressed(driver->input_data, key, &type);
|
||||
state = input->key_pressed(driver->input_data, key, &device);
|
||||
|
||||
if (key >= RARCH_FIRST_META_KEY)
|
||||
state |= input->meta_key_pressed(driver->input_data, key, &type);
|
||||
state |= input->meta_key_pressed(driver->input_data, key, &device);
|
||||
|
||||
if (device == INPUT_DEVICE_TYPE_JOYPAD)
|
||||
BIT64_SET(*device_type, key);
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
state |= input_overlay_key_pressed(key);
|
||||
|
@ -151,7 +151,7 @@ void find_input_driver(void);
|
||||
bool input_driver_set_rumble_state(unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength);
|
||||
|
||||
retro_input_t input_driver_keys_pressed(void);
|
||||
retro_input_t input_driver_keys_pressed(uint64_t *device);
|
||||
|
||||
int16_t input_driver_state(const struct retro_keybind **retro_keybinds,
|
||||
unsigned port, unsigned device, unsigned index, unsigned id);
|
||||
|
@ -79,6 +79,8 @@ typedef struct menu_input
|
||||
{
|
||||
struct menu_bind_state binds;
|
||||
|
||||
uint64_t devices_mask;
|
||||
|
||||
struct
|
||||
{
|
||||
int16_t x;
|
||||
@ -1200,7 +1202,7 @@ void menu_input_post_iterate(int *ret, unsigned action)
|
||||
*ret |= menu_input_pointer_post_iterate(cbs, &entry, action);
|
||||
}
|
||||
|
||||
unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input)
|
||||
unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input, retro_input_t *devices)
|
||||
{
|
||||
bool mouse_enabled;
|
||||
float delta_time;
|
||||
@ -1265,6 +1267,7 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input)
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time);
|
||||
|
||||
menu_input->delay.count += delta_time / IDEAL_DT;
|
||||
menu_input->devices_mask = *devices;
|
||||
|
||||
if (menu_input->keyboard.display)
|
||||
{
|
||||
@ -1301,7 +1304,17 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input)
|
||||
ret = MENU_ACTION_INFO;
|
||||
else if (trigger_input & (UINT64_C(1) << RARCH_MENU_TOGGLE))
|
||||
ret = MENU_ACTION_TOGGLE;
|
||||
|
||||
|
||||
unsigned j;
|
||||
for (j = 0; j < 64; j++)
|
||||
{
|
||||
bool joypad_pressed = BIT64_GET(*devices, j);
|
||||
if (joypad_pressed)
|
||||
RARCH_LOG("Button %d pressed on gamepad\n", j);
|
||||
else
|
||||
RARCH_LOG("Button %d pressed on keyboard\n", j);
|
||||
}
|
||||
|
||||
mouse_enabled = settings->menu.mouse.enable;
|
||||
#ifdef HAVE_OVERLAY
|
||||
mouse_enabled = mouse_enabled ||
|
||||
@ -1320,4 +1333,3 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ void menu_input_st_string_callback(void *userdata, const char *str);
|
||||
|
||||
void menu_input_st_cheat_callback(void *userdata, const char *str);
|
||||
|
||||
unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_state);
|
||||
unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_state, retro_input_t *devices_mask);
|
||||
|
||||
void menu_input_post_iterate(int *ret, unsigned action);
|
||||
|
||||
|
16
runloop.c
16
runloop.c
@ -655,12 +655,12 @@ static bool check_block_hotkey(driver_t *driver, settings_t *settings,
|
||||
* Returns: Input sample containg a mask of all pressed keys.
|
||||
*/
|
||||
static INLINE retro_input_t input_keys_pressed(driver_t *driver,
|
||||
settings_t *settings, global_t *global)
|
||||
settings_t *settings, global_t *global, uint64_t *devices)
|
||||
{
|
||||
unsigned i;
|
||||
const struct retro_keybind *binds[MAX_USERS];
|
||||
retro_input_t ret = 0;
|
||||
enum input_device_type type = INPUT_DEVICE_TYPE_NONE;
|
||||
retro_input_t ret = 0;
|
||||
enum input_device_type device = INPUT_DEVICE_TYPE_NONE;
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
binds[i] = settings->input.binds[i];
|
||||
@ -672,7 +672,8 @@ static INLINE retro_input_t input_keys_pressed(driver_t *driver,
|
||||
|
||||
driver->block_libretro_input = check_block_hotkey(driver,
|
||||
settings, driver->input->key_pressed(
|
||||
driver->input_data, RARCH_ENABLE_HOTKEY, &type));
|
||||
driver->input_data, RARCH_ENABLE_HOTKEY, &device));
|
||||
|
||||
|
||||
for (i = 0; i < settings->input.max_users; i++)
|
||||
{
|
||||
@ -691,7 +692,7 @@ static INLINE retro_input_t input_keys_pressed(driver_t *driver,
|
||||
i, RETRO_DEVICE_JOYPAD, 0, RARCH_TURBO_ENABLE);
|
||||
}
|
||||
|
||||
ret = input_driver_keys_pressed();
|
||||
ret = input_driver_keys_pressed(devices);
|
||||
|
||||
for (i = 0; i < settings->input.max_users; i++)
|
||||
{
|
||||
@ -891,10 +892,11 @@ int rarch_main_iterate(unsigned *sleep_ms)
|
||||
event_cmd_state_t cmd;
|
||||
retro_time_t current, target, to_sleep_ms;
|
||||
static retro_input_t last_input = 0;
|
||||
uint64_t devices = 0;
|
||||
driver_t *driver = driver_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
retro_input_t input = input_keys_pressed(driver, settings, global);
|
||||
retro_input_t input = input_keys_pressed(driver, settings, global, &devices);
|
||||
rarch_system_info_t *system = rarch_system_info_get_ptr();
|
||||
retro_input_t old_input = last_input;
|
||||
last_input = input;
|
||||
@ -979,7 +981,7 @@ int rarch_main_iterate(unsigned *sleep_ms)
|
||||
#ifdef HAVE_MENU
|
||||
if (menu_driver_alive())
|
||||
{
|
||||
if (menu_driver_iterate((enum menu_action)menu_input_frame(input, trigger_input)) == -1)
|
||||
if (menu_driver_iterate((enum menu_action)menu_input_frame(input, trigger_input, &devices)) == -1)
|
||||
rarch_ctl(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED, NULL);
|
||||
|
||||
if (!input && settings->menu.pause_libretro)
|
||||
|
Loading…
x
Reference in New Issue
Block a user