mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
Cut down on code duplication
This commit is contained in:
parent
0b95a8838a
commit
eb78b608d3
@ -1418,28 +1418,6 @@ bool android_run_events(void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int16_t android_is_pressed(
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned port, unsigned id)
|
||||
{
|
||||
const struct retro_keybind *bind = &binds[id];
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
||||
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
||||
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
||||
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
if ((uint16_t)joykey != NO_BTN
|
||||
&& joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t android_input_state(void *data,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds, unsigned port, unsigned device,
|
||||
@ -1458,7 +1436,7 @@ static int16_t android_input_state(void *data,
|
||||
{
|
||||
if (
|
||||
android_keyboard_port_input_pressed(binds[port], i)
|
||||
|| android_is_pressed(
|
||||
|| button_is_pressed(
|
||||
android->joypad, joypad_info, binds[port],
|
||||
port, i)
|
||||
)
|
||||
@ -1470,7 +1448,7 @@ static int16_t android_input_state(void *data,
|
||||
{
|
||||
if (
|
||||
android_keyboard_port_input_pressed(binds[port], id)
|
||||
|| android_is_pressed(
|
||||
|| button_is_pressed(
|
||||
android->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
|
@ -290,26 +290,6 @@ static int16_t cocoa_pointer_state(cocoa_input_data_t *apple,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t cocoa_is_pressed(
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned port, unsigned id)
|
||||
{
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
||||
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
||||
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
||||
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
if ((uint16_t)joykey != NO_BTN && joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t cocoa_input_state(void *data,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds, unsigned port,
|
||||
@ -328,12 +308,12 @@ static int16_t cocoa_input_state(void *data,
|
||||
{
|
||||
if (apple_key_state[rarch_keysym_lut[binds[port][i].key]])
|
||||
ret |= (1 << i);
|
||||
else if (cocoa_is_pressed(
|
||||
else if (button_is_pressed(
|
||||
apple->joypad,
|
||||
joypad_info, binds[port], port, i))
|
||||
ret |= (1 << i);
|
||||
#ifdef HAVE_MFI
|
||||
else if (cocoa_is_pressed(
|
||||
else if (button_is_pressed(
|
||||
apple->sec_joypad,
|
||||
joypad_info, binds[port], port, i))
|
||||
ret |= (1 << i);
|
||||
@ -346,12 +326,12 @@ static int16_t cocoa_input_state(void *data,
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
if (apple_key_state[rarch_keysym_lut[binds[port][id].key]])
|
||||
return 1;
|
||||
if (cocoa_is_pressed(
|
||||
if (button_is_pressed(
|
||||
apple->joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
#ifdef HAVE_MFI
|
||||
if (cocoa_is_pressed(
|
||||
if (button_is_pressed(
|
||||
apple->sec_joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
|
@ -43,28 +43,6 @@ static void ctr_input_poll(void *data)
|
||||
ctr->joypad->poll();
|
||||
}
|
||||
|
||||
static int16_t ctr_is_pressed(
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned port, unsigned id)
|
||||
{
|
||||
const struct retro_keybind *bind = &binds[id];
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
||||
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
||||
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
||||
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
if ((uint16_t)joykey != NO_BTN &&
|
||||
joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t ctr_input_state(void *data,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
@ -86,7 +64,7 @@ static int16_t ctr_input_state(void *data,
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (binds[port][i].valid)
|
||||
if (ctr_is_pressed(
|
||||
if (button_is_pressed(
|
||||
ctr->joypad, joypad_info, binds[port], port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
@ -98,7 +76,7 @@ static int16_t ctr_input_state(void *data,
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
{
|
||||
if (binds[port][id].valid)
|
||||
return ctr_is_pressed(
|
||||
return button_is_pressed(
|
||||
ctr->joypad, joypad_info, binds[port], port, id);
|
||||
}
|
||||
}
|
||||
|
@ -69,28 +69,6 @@ static void dos_input_poll(void *data)
|
||||
dos->joypad->poll();
|
||||
}
|
||||
|
||||
static int16_t dos_is_pressed(
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned port, unsigned id)
|
||||
{
|
||||
const struct retro_keybind *bind = &binds[id];
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
||||
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
||||
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
||||
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
if ((uint16_t)joykey != NO_BTN
|
||||
&& joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t dos_input_state(void *data,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
@ -113,7 +91,7 @@ static int16_t dos_input_state(void *data,
|
||||
{
|
||||
if (
|
||||
dos_keyboard_port_input_pressed(binds[port], i)
|
||||
|| dos_is_pressed(dos->joypad, joypad_info, binds[port],
|
||||
|| button_is_pressed(dos->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
@ -124,7 +102,7 @@ static int16_t dos_input_state(void *data,
|
||||
{
|
||||
if (
|
||||
dos_keyboard_port_input_pressed(binds[port], id)
|
||||
|| dos_is_pressed(dos->joypad, joypad_info, binds[port],
|
||||
|| button_is_pressed(dos->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
}
|
||||
|
@ -134,28 +134,6 @@ static int16_t gx_mouse_state(gx_input_t *gx, unsigned id, uint16_t joy_idx)
|
||||
}
|
||||
#endif
|
||||
|
||||
static int16_t gx_is_pressed(
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned port, unsigned id)
|
||||
{
|
||||
const struct retro_keybind *bind = &binds[id];
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
||||
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
||||
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
||||
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
if ((uint16_t)joykey != NO_BTN
|
||||
&& joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t gx_input_state(void *data,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
@ -177,7 +155,7 @@ static int16_t gx_input_state(void *data,
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (
|
||||
gx_is_pressed(gx->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(gx->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
@ -187,7 +165,7 @@ static int16_t gx_input_state(void *data,
|
||||
else
|
||||
{
|
||||
if (
|
||||
gx_is_pressed(gx->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(gx->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
}
|
||||
|
@ -41,28 +41,6 @@ static void ps2_input_poll(void *data)
|
||||
ps2->joypad->poll();
|
||||
}
|
||||
|
||||
static int16_t ps2_is_pressed(
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned port, unsigned id)
|
||||
{
|
||||
const struct retro_keybind *bind = &binds[id];
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
||||
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
||||
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
||||
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
if ((uint16_t)joykey != NO_BTN
|
||||
&& joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t ps2_input_state(void *data,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
@ -80,7 +58,7 @@ static int16_t ps2_input_state(void *data,
|
||||
int16_t ret = 0;
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (ps2_is_pressed(ps2->joypad, joypad_info, binds[port],
|
||||
if (button_is_pressed(ps2->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
@ -89,7 +67,7 @@ static int16_t ps2_input_state(void *data,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ps2_is_pressed(ps2->joypad, joypad_info, binds[port],
|
||||
if (button_is_pressed(ps2->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
}
|
||||
|
@ -93,28 +93,6 @@ static int16_t ps3_mouse_device_state(ps3_input_t *ps3,
|
||||
}
|
||||
#endif
|
||||
|
||||
static int16_t ps3_is_pressed(
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned port, unsigned id)
|
||||
{
|
||||
const struct retro_keybind *bind = &binds[id];
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
||||
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
||||
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
||||
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
if ((uint16_t)joykey != NO_BTN
|
||||
&& joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t ps3_input_state(void *data,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
@ -136,7 +114,7 @@ static int16_t ps3_input_state(void *data,
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (
|
||||
ps3_is_pressed(ps3->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(ps3->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
@ -145,7 +123,7 @@ static int16_t ps3_input_state(void *data,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ps3_is_pressed(ps3->joypad, joypad_info, binds[port],
|
||||
if (button_is_pressed(ps3->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
}
|
||||
|
@ -45,28 +45,6 @@ static void ps4_input_poll(void *data)
|
||||
ps4->joypad->poll();
|
||||
}
|
||||
|
||||
static int16_t ps4_is_pressed(
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned port, unsigned id)
|
||||
{
|
||||
const struct retro_keybind *bind = &binds[id];
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
||||
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
||||
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
||||
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
if ((uint16_t)joykey != NO_BTN
|
||||
&& joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t ps4_input_state(void *data,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
@ -85,7 +63,7 @@ static int16_t ps4_input_state(void *data,
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (
|
||||
ps4_is_pressed(ps4->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(ps4->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
@ -95,7 +73,7 @@ static int16_t ps4_input_state(void *data,
|
||||
else
|
||||
{
|
||||
if (
|
||||
ps4_is_pressed(ps4->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(ps4->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
}
|
||||
|
@ -203,28 +203,6 @@ static bool psl1ght_keyboard_port_input_pressed(ps3_input_t *ps3, unsigned id)
|
||||
return false;
|
||||
}
|
||||
|
||||
static int16_t psl1ght_is_pressed(
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned port, unsigned id)
|
||||
{
|
||||
const struct retro_keybind *bind = &binds[id];
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
||||
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
||||
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
||||
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
if ((uint16_t)joykey != NO_BTN
|
||||
&& joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t ps3_input_state(void *data,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
@ -246,7 +224,7 @@ static int16_t ps3_input_state(void *data,
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (
|
||||
psl1ght_is_pressed(ps3->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(ps3->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
else if (psl1ght_keyboard_port_input_pressed(ps3, binds[port][i].key))
|
||||
@ -258,7 +236,7 @@ static int16_t ps3_input_state(void *data,
|
||||
else
|
||||
{
|
||||
if (
|
||||
psl1ght_is_pressed(ps3->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(ps3->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
else if (psl1ght_keyboard_port_input_pressed(
|
||||
|
@ -283,28 +283,6 @@ static int16_t psp_input_mouse_state(
|
||||
}
|
||||
#endif
|
||||
|
||||
static int16_t psp_is_pressed(
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned port, unsigned id)
|
||||
{
|
||||
const struct retro_keybind *bind = &binds[id];
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
||||
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
||||
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
||||
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
if ((uint16_t)joykey != NO_BTN
|
||||
&& joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t psp_input_state(void *data,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
@ -328,7 +306,7 @@ static int16_t psp_input_state(void *data,
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (
|
||||
psp_is_pressed(psp->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(psp->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
@ -338,7 +316,7 @@ static int16_t psp_input_state(void *data,
|
||||
else
|
||||
{
|
||||
if (
|
||||
psp_is_pressed(psp->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(psp->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
}
|
||||
|
@ -379,28 +379,6 @@ static int16_t switch_input_mouse_state(
|
||||
}
|
||||
#endif
|
||||
|
||||
static int16_t switch_is_pressed(
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned port, unsigned id)
|
||||
{
|
||||
const struct retro_keybind *bind = &binds[id];
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
||||
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
||||
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
||||
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
if ((uint16_t)joykey != NO_BTN
|
||||
&& joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t switch_input_state(void *data,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
@ -422,7 +400,7 @@ static int16_t switch_input_state(void *data,
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (
|
||||
switch_is_pressed(sw->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(sw->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
@ -432,7 +410,7 @@ static int16_t switch_input_state(void *data,
|
||||
else
|
||||
{
|
||||
if (
|
||||
switch_is_pressed(sw->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(sw->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
}
|
||||
|
@ -48,28 +48,6 @@ static void xdk_input_poll(void *data)
|
||||
xdk->joypad->poll();
|
||||
}
|
||||
|
||||
static int16_t xdk_is_pressed(
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned port, unsigned id)
|
||||
{
|
||||
const struct retro_keybind *bind = &binds[id];
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
||||
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
||||
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
||||
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
if ((uint16_t)joykey != NO_BTN
|
||||
&& joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t xdk_input_state(void *data,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
@ -92,7 +70,7 @@ static int16_t xdk_input_state(void *data,
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (
|
||||
xdk_is_pressed(xdk->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(xdk->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
@ -102,7 +80,7 @@ static int16_t xdk_input_state(void *data,
|
||||
else
|
||||
{
|
||||
if (
|
||||
xdk_is_pressed(xdk->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(xdk->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
}
|
||||
|
@ -633,6 +633,12 @@ 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 port, unsigned id);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
20
retroarch.c
20
retroarch.c
@ -24534,6 +24534,26 @@ bool input_joypad_set_rumble(const input_device_driver_t *drv,
|
||||
return drv->set_rumble(joy_idx, effect, strength);
|
||||
}
|
||||
|
||||
int16_t button_is_pressed(
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned port, unsigned id)
|
||||
{
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
||||
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
||||
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
||||
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
if ((uint16_t)joykey != NO_BTN && joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* input_joypad_analog:
|
||||
* @drv : Input device driver handle.
|
||||
|
Loading…
x
Reference in New Issue
Block a user