mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
Get rid of button_is_pressed
This commit is contained in:
parent
36bf1ad112
commit
cfe9d60f51
@ -746,15 +746,28 @@ static int16_t dinput_input_state(
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT:
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_PAUSE:
|
||||
{
|
||||
unsigned new_id = dinput_retro_id_to_rarch(id);
|
||||
unsigned new_id = dinput_retro_id_to_rarch(id);
|
||||
const uint64_t bind_joykey = input_config_binds[port][new_id].joykey;
|
||||
const uint64_t bind_joyaxis = input_config_binds[port][new_id].joyaxis;
|
||||
const uint64_t autobind_joykey = input_autoconf_binds[port][new_id].joykey;
|
||||
const uint64_t autobind_joyaxis= input_autoconf_binds[port][new_id].joyaxis;
|
||||
uint16_t port = joypad_info->joy_idx;
|
||||
float axis_threshold = joypad_info->axis_threshold;
|
||||
const uint64_t joykey = (bind_joykey != NO_BTN)
|
||||
? bind_joykey : autobind_joykey;
|
||||
const uint32_t joyaxis = (bind_joyaxis != AXIS_NONE)
|
||||
? bind_joyaxis : autobind_joyaxis;
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info,
|
||||
binds[port], new_id))
|
||||
if ((uint16_t)joykey != NO_BTN && joypad->button(
|
||||
port, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (joyaxis != AXIS_NONE &&
|
||||
((float)abs(joypad->axis(port, joyaxis))
|
||||
/ 0x8000) > axis_threshold)
|
||||
return 1;
|
||||
else if (
|
||||
binds[port][new_id].key < RETROK_LAST
|
||||
binds[port][new_id].key < RETROK_LAST
|
||||
&& !keyboard_mapping_blocked
|
||||
&& di->state[rarch_keysym_lut
|
||||
[(enum retro_key)binds[port][new_id].key]] & 0x80
|
||||
@ -764,11 +777,11 @@ static int16_t dinput_input_state(
|
||||
{
|
||||
settings = config_get_ptr();
|
||||
if (
|
||||
settings->uints.input_mouse_index[port] == 0
|
||||
&& dinput_mouse_button_pressed(
|
||||
di, port, binds[port][new_id].mbutton)
|
||||
settings->uints.input_mouse_index[port] == 0
|
||||
&& dinput_mouse_button_pressed(
|
||||
di, port, binds[port][new_id].mbutton)
|
||||
)
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1134,23 +1134,38 @@ static int16_t udev_input_state(
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT:
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT:
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: /* deprecated */
|
||||
id = udev_retro_id_to_rarch(id);
|
||||
if (!keyboard_mapping_blocked)
|
||||
if ((binds[port][id].key < RETROK_LAST)
|
||||
&& udev_keyboard_pressed(udev, binds[port]
|
||||
[id].key))
|
||||
return 1;
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
unsigned new_id = id;
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port],
|
||||
new_id)
|
||||
|| udev_mouse_button_pressed(udev, port,
|
||||
binds[port][new_id].mbutton)
|
||||
)
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
unsigned new_id = udev_retro_id_to_rarch(id);
|
||||
const uint64_t bind_joykey = input_config_binds[port][new_id].joykey;
|
||||
const uint64_t bind_joyaxis = input_config_binds[port][new_id].joyaxis;
|
||||
const uint64_t autobind_joykey = input_autoconf_binds[port][new_id].joykey;
|
||||
const uint64_t autobind_joyaxis= input_autoconf_binds[port][new_id].joyaxis;
|
||||
uint16_t port = joypad_info->joy_idx;
|
||||
float axis_threshold = joypad_info->axis_threshold;
|
||||
const uint64_t joykey = (bind_joykey != NO_BTN)
|
||||
? bind_joykey : autobind_joykey;
|
||||
const uint32_t joyaxis = (bind_joyaxis != AXIS_NONE)
|
||||
? bind_joyaxis : autobind_joyaxis;
|
||||
if (!keyboard_mapping_blocked)
|
||||
if ((binds[port][new_id].key < RETROK_LAST)
|
||||
&& udev_keyboard_pressed(udev, binds[port]
|
||||
[new_id].key))
|
||||
return 1;
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
if ((uint16_t)joykey != NO_BTN && joypad->button(
|
||||
port, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (joyaxis != AXIS_NONE &&
|
||||
((float)abs(joypad->axis(port, joyaxis))
|
||||
/ 0x8000) > axis_threshold)
|
||||
return 1;
|
||||
if (udev_mouse_button_pressed(udev, port,
|
||||
binds[port][new_id].mbutton))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
/*deprecated*/
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_X:
|
||||
{
|
||||
|
@ -643,9 +643,11 @@ static int16_t winraw_input_lightgun_state(
|
||||
const struct retro_keybind **binds,
|
||||
bool keyboard_mapping_blocked,
|
||||
unsigned port,
|
||||
unsigned device,
|
||||
unsigned idx,
|
||||
unsigned id)
|
||||
unsigned id,
|
||||
float axis_threshold,
|
||||
const uint64_t joykey,
|
||||
const uint32_t joyaxis
|
||||
)
|
||||
{
|
||||
if (!keyboard_mapping_blocked)
|
||||
if ((binds[port][id].key < RETROK_LAST)
|
||||
@ -654,13 +656,17 @@ static int16_t winraw_input_lightgun_state(
|
||||
return 1;
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if ((uint16_t)joykey != NO_BTN && joypad->button(
|
||||
port, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (joyaxis != AXIS_NONE &&
|
||||
((float)abs(joypad->axis(port, joyaxis))
|
||||
/ 0x8000) > axis_threshold)
|
||||
return 1;
|
||||
if (mouse && winraw_mouse_button_pressed(wr,
|
||||
mouse, port, binds[port]
|
||||
[id].mbutton))
|
||||
return 1;
|
||||
return button_is_pressed(
|
||||
joypad, joypad_info, binds[port],
|
||||
id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -862,12 +868,27 @@ static int16_t winraw_input_state(
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT:
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: /* deprecated */
|
||||
{
|
||||
unsigned new_id = winraw_retro_id_to_rarch(id);
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad,
|
||||
unsigned new_id = winraw_retro_id_to_rarch(id);
|
||||
const uint64_t bind_joykey = input_config_binds[port][new_id].joykey;
|
||||
const uint64_t bind_joyaxis = input_config_binds[port][new_id].joyaxis;
|
||||
const uint64_t autobind_joykey = input_autoconf_binds[port][new_id].joykey;
|
||||
const uint64_t autobind_joyaxis= input_autoconf_binds[port][new_id].joyaxis;
|
||||
uint16_t port = joypad_info->joy_idx;
|
||||
float axis_threshold = joypad_info->axis_threshold;
|
||||
const uint64_t joykey = (bind_joykey != NO_BTN)
|
||||
? bind_joykey : autobind_joykey;
|
||||
const uint32_t joyaxis = (bind_joyaxis != AXIS_NONE)
|
||||
? bind_joyaxis : autobind_joyaxis;
|
||||
return winraw_input_lightgun_state(
|
||||
wr, mouse, joypad,
|
||||
joypad_info,
|
||||
binds,
|
||||
keyboard_mapping_blocked,
|
||||
port, device, idx, new_id);
|
||||
port,
|
||||
new_id,
|
||||
axis_threshold,
|
||||
joykey,
|
||||
joyaxis);
|
||||
}
|
||||
/*deprecated*/
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_X:
|
||||
|
@ -389,7 +389,17 @@ static int16_t x_input_state(
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT:
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: /* deprecated */
|
||||
{
|
||||
unsigned new_id = x_retro_id_to_rarch(id);
|
||||
unsigned new_id = x_retro_id_to_rarch(id);
|
||||
const uint64_t bind_joykey = input_config_binds[port][new_id].joykey;
|
||||
const uint64_t bind_joyaxis = input_config_binds[port][new_id].joyaxis;
|
||||
const uint64_t autobind_joykey = input_autoconf_binds[port][new_id].joykey;
|
||||
const uint64_t autobind_joyaxis= input_autoconf_binds[port][new_id].joyaxis;
|
||||
uint16_t port = joypad_info->joy_idx;
|
||||
float axis_threshold = joypad_info->axis_threshold;
|
||||
const uint64_t joykey = (bind_joykey != NO_BTN)
|
||||
? bind_joykey : autobind_joykey;
|
||||
const uint32_t joyaxis = (bind_joyaxis != AXIS_NONE)
|
||||
? bind_joyaxis : autobind_joyaxis;
|
||||
if (!keyboard_mapping_blocked)
|
||||
if ((binds[port][new_id].key < RETROK_LAST)
|
||||
&& x_keyboard_pressed(x11, binds[port]
|
||||
@ -397,9 +407,12 @@ static int16_t x_input_state(
|
||||
return 1;
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port],
|
||||
new_id))
|
||||
if ((uint16_t)joykey != NO_BTN && joypad->button(
|
||||
port, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (joyaxis != AXIS_NONE &&
|
||||
((float)abs(joypad->axis(port, joyaxis))
|
||||
/ 0x8000) > axis_threshold)
|
||||
return 1;
|
||||
else if (settings->uints.input_mouse_index[port] == 0)
|
||||
{
|
||||
|
@ -594,12 +594,6 @@ bool menu_input_dialog_start(menu_input_ctx_line_t *line);
|
||||
|
||||
void menu_input_dialog_end(void);
|
||||
|
||||
int16_t button_is_pressed(
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned id);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
91
retroarch.c
91
retroarch.c
@ -479,15 +479,32 @@ static int16_t input_state_wrap(
|
||||
* states together */
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (button_is_pressed(
|
||||
joypad,
|
||||
joypad_info, binds[port], id))
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t bind_joykey = binds[port][id].joykey;
|
||||
const uint64_t bind_joyaxis = binds[port][id].joyaxis;
|
||||
const uint64_t autobind_joykey = joypad_info->auto_binds[id].joykey;
|
||||
const uint64_t autobind_joyaxis= joypad_info->auto_binds[id].joyaxis;
|
||||
uint16_t port = joypad_info->joy_idx;
|
||||
float axis_threshold = joypad_info->axis_threshold;
|
||||
const uint64_t joykey = (bind_joykey != NO_BTN)
|
||||
? bind_joykey : autobind_joykey;
|
||||
const uint32_t joyaxis = (bind_joyaxis != AXIS_NONE)
|
||||
? bind_joyaxis : autobind_joyaxis;
|
||||
|
||||
if ((uint16_t)joykey != NO_BTN && joypad->button(
|
||||
port, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (joyaxis != AXIS_NONE &&
|
||||
((float)abs(joypad->axis(port, joyaxis))
|
||||
/ 0x8000) > axis_threshold)
|
||||
return 1;
|
||||
#ifdef HAVE_MFI
|
||||
else if (sec_joypad &&
|
||||
button_is_pressed(
|
||||
sec_joypad,
|
||||
joypad_info, binds[port], id))
|
||||
if ((uint16_t)joykey != NO_BTN && sec_joypad->button(
|
||||
port, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (joyaxis != AXIS_NONE &&
|
||||
((float)abs(sec_joypad->axis(port, joyaxis))
|
||||
/ 0x8000) > axis_threshold)
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
@ -25025,17 +25042,29 @@ bool input_key_pressed(int key, bool keyboard_pressed)
|
||||
)
|
||||
{
|
||||
rarch_joypad_info_t joypad_info;
|
||||
struct rarch_state
|
||||
*p_rarch = &rarch_st;
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
const input_device_driver_t
|
||||
*joypad = (const input_device_driver_t*)p_rarch->joypad;
|
||||
joypad_info.joy_idx = 0;
|
||||
joypad_info.auto_binds = input_autoconf_binds[0];
|
||||
joypad_info.axis_threshold = p_rarch->input_driver_axis_threshold;
|
||||
return button_is_pressed(
|
||||
joypad, &joypad_info,
|
||||
input_config_binds[0],
|
||||
key);
|
||||
*joypad = (const input_device_driver_t*)
|
||||
p_rarch->joypad;
|
||||
const uint64_t bind_joykey = input_config_binds[0][key].joykey;
|
||||
const uint64_t bind_joyaxis = input_config_binds[0][key].joyaxis;
|
||||
const uint64_t autobind_joykey = input_autoconf_binds[0][key].joykey;
|
||||
const uint64_t autobind_joyaxis= input_autoconf_binds[0][key].joyaxis;
|
||||
uint16_t port = 0;
|
||||
float axis_threshold = p_rarch->input_driver_axis_threshold;
|
||||
const uint64_t joykey = (bind_joykey != NO_BTN)
|
||||
? bind_joykey : autobind_joykey;
|
||||
const uint32_t joyaxis = (bind_joyaxis != AXIS_NONE)
|
||||
? bind_joyaxis : autobind_joyaxis;
|
||||
|
||||
if ((uint16_t)joykey != NO_BTN && joypad->button(
|
||||
port, (uint16_t)joykey))
|
||||
return true;
|
||||
if (joyaxis != AXIS_NONE &&
|
||||
((float)abs(joypad->axis(port, joyaxis))
|
||||
/ 0x8000) > axis_threshold)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -25046,34 +25075,6 @@ bool input_mouse_grabbed(void)
|
||||
return p_rarch->input_driver_grab_mouse_state;
|
||||
}
|
||||
|
||||
int16_t button_is_pressed(
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned id)
|
||||
{
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t bind_joykey = binds[id].joykey;
|
||||
const uint64_t bind_joyaxis = binds[id].joyaxis;
|
||||
const uint64_t autobind_joykey = joypad_info->auto_binds[id].joykey;
|
||||
const uint64_t autobind_joyaxis= joypad_info->auto_binds[id].joyaxis;
|
||||
uint16_t port = joypad_info->joy_idx;
|
||||
float axis_threshold = joypad_info->axis_threshold;
|
||||
const uint64_t joykey = (bind_joykey != NO_BTN)
|
||||
? bind_joykey : autobind_joykey;
|
||||
const uint32_t joyaxis = (bind_joyaxis != AXIS_NONE)
|
||||
? bind_joyaxis : autobind_joyaxis;
|
||||
|
||||
if ((uint16_t)joykey != NO_BTN && joypad->button(
|
||||
port, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (joyaxis != AXIS_NONE &&
|
||||
((float)abs(joypad->axis(port, joyaxis))
|
||||
/ 0x8000) > axis_threshold)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* input_joypad_analog:
|
||||
* @drv : Input device driver handle.
|
||||
|
Loading…
x
Reference in New Issue
Block a user