mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
Simplify button_is_pressed
This commit is contained in:
parent
372f939cc9
commit
760fc6b3f7
21
retroarch.c
21
retroarch.c
@ -24999,16 +24999,23 @@ int16_t button_is_pressed(
|
|||||||
unsigned port, unsigned id)
|
unsigned port, unsigned id)
|
||||||
{
|
{
|
||||||
/* Auto-binds are per joypad, not per user. */
|
/* Auto-binds are per joypad, not per user. */
|
||||||
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
const uint64_t bind_joykey = binds[id].joykey;
|
||||||
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
const uint64_t bind_joyaxis = binds[id].joyaxis;
|
||||||
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
const uint64_t autobind_joykey = joypad_info->auto_binds[id].joykey;
|
||||||
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
const uint64_t autobind_joyaxis= joypad_info->auto_binds[id].joyaxis;
|
||||||
|
uint16_t joy_idx = 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(
|
if ((uint16_t)joykey != NO_BTN && joypad->button(
|
||||||
joypad_info->joy_idx, (uint16_t)joykey))
|
joy_idx, (uint16_t)joykey))
|
||||||
return 1;
|
return 1;
|
||||||
if (joyaxis != AXIS_NONE &&
|
if (joyaxis != AXIS_NONE &&
|
||||||
((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis))
|
((float)abs(joypad->axis(joy_idx, joyaxis))
|
||||||
/ 0x8000) > joypad_info->axis_threshold)
|
/ 0x8000) > axis_threshold)
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user