This commit is contained in:
twinaphex 2020-06-12 00:16:31 +02:00
parent e40d381f6b
commit ecfdc867f8
9 changed files with 254 additions and 245 deletions

View File

@ -69,6 +69,28 @@ 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,
@ -89,47 +111,21 @@ static int16_t dos_input_state(void *data,
int16_t ret = 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][i].joykey != NO_BTN)
? binds[port][i].joykey : joypad_info->auto_binds[i].joykey;
const uint32_t joyaxis = (binds[port][i].joyaxis != AXIS_NONE)
? binds[port][i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if ((uint16_t)joykey != NO_BTN && dos->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
{
if (
dos_keyboard_port_input_pressed(binds[port], i)
|| dos_is_pressed(dos->joypad, joypad_info, binds[port],
port, i))
ret |= (1 << i);
continue;
}
if (((float)abs(dos->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
{
ret |= (1 << i);
continue;
}
if (dos_keyboard_port_input_pressed(binds[port], i))
{
ret |= (1 << i);
continue;
}
}
return ret;
}
else
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][id].joykey != NO_BTN)
? binds[port][id].joykey : joypad_info->auto_binds[id].joykey;
const uint32_t joyaxis = (binds[port][id].joyaxis != AXIS_NONE)
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
if ((uint16_t)joykey != NO_BTN && dos->joypad->button(
joypad_info->joy_idx, (uint16_t)joykey))
return 1;
if (((float)abs(dos->joypad->axis(
joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
return 1;
if (dos_keyboard_port_input_pressed(binds[port], id))
if (
dos_keyboard_port_input_pressed(binds[port], id)
|| dos_is_pressed(dos->joypad, joypad_info, binds[port],
port, id))
return 1;
}
break;

View File

@ -134,6 +134,28 @@ 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,
@ -154,40 +176,19 @@ static int16_t gx_input_state(void *data,
int16_t ret = 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][i].joykey != NO_BTN)
? binds[port][i].joykey : joypad_info->auto_binds[i].joykey;
const uint32_t joyaxis = (binds[port][i].joyaxis != AXIS_NONE)
? binds[port][i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if ((uint16_t)joykey != NO_BTN && gx->joypad->button(
joypad_info->joy_idx, (uint16_t)joykey))
{
if (
gx_is_pressed(gx->joypad, joypad_info, binds[port],
port, i))
ret |= (1 << i);
continue;
}
if (((float)abs(gx->joypad->axis(
joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
{
ret |= (1 << i);
continue;
}
}
return ret;
}
else
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][id].joykey != NO_BTN)
? binds[port][id].joykey : joypad_info->auto_binds[id].joykey;
const uint32_t joyaxis = (binds[port][id].joyaxis != AXIS_NONE)
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
if ((uint16_t)joykey != NO_BTN && gx->joypad->button(
joypad_info->joy_idx, (uint16_t)joykey))
return 1;
if (((float)abs(gx->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
if (
gx_is_pressed(gx->joypad, joypad_info, binds[port],
port, id))
return 1;
}
break;

View File

@ -41,6 +41,28 @@ 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,
@ -58,41 +80,17 @@ static int16_t ps2_input_state(void *data,
int16_t ret = 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][i].joykey != NO_BTN)
? binds[port][i].joykey : joypad_info->auto_binds[i].joykey;
const uint32_t joyaxis = (binds[port][i].joyaxis != AXIS_NONE)
? binds[port][i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if ((uint16_t)joykey != NO_BTN && ps2->joypad->button(
joypad_info->joy_idx, (uint16_t)joykey))
{
if (ps2_is_pressed(ps2->joypad, joypad_info, binds[port],
port, i))
ret |= (1 << i);
continue;
}
if (((float)abs(ps2->joypad->axis(
joypad_info->joy_idx, joyaxis)) / 0x8000)
> joypad_info->axis_threshold)
{
ret |= (1 << i);
continue;
}
}
return ret;
}
else
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][id].joykey != NO_BTN)
? binds[port][id].joykey : joypad_info->auto_binds[id].joykey;
const uint32_t joyaxis = (binds[port][id].joyaxis != AXIS_NONE)
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
if ((uint16_t)joykey != NO_BTN && ps2->joypad->button(
joypad_info->joy_idx, (uint16_t)joykey))
return 1;
if (((float)abs(ps2->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
if (ps2_is_pressed(ps2->joypad, joypad_info, binds[port],
port, id))
return 1;
}
break;

View File

@ -91,9 +91,30 @@ static int16_t ps3_mouse_device_state(ps3_input_t *ps3,
return 0;
}
#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,
@ -114,47 +135,25 @@ static int16_t ps3_input_state(void *data,
int16_t ret = 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][i].joykey != NO_BTN)
? binds[port][i].joykey : joypad_info->auto_binds[i].joykey;
const uint32_t joyaxis = (binds[port][i].joyaxis != AXIS_NONE)
? binds[port][i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if ((uint16_t)joykey != NO_BTN && ps3->joypad->button(
joypad_info->joy_idx, (uint16_t)joykey))
{
if (
ps3_is_pressed(ps3->joypad, joypad_info, binds[port],
port, i))
ret |= (1 << i);
continue;
}
else if (((float)abs(ps3->joypad->axis(
joypad_info->joy_idx, joyaxis)) / 0x8000)
> joypad_info->axis_threshold)
{
ret |= (1 << i);
continue;
}
}
return ret;
}
else
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][id].joykey != NO_BTN)
? binds[port][id].joykey : joypad_info->auto_binds[id].joykey;
const uint32_t joyaxis = (binds[port][id].joyaxis != AXIS_NONE)
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
if ((uint16_t)joykey != NO_BTN && ps3->joypad->button(
joypad_info->joy_idx, (uint16_t)joykey))
return 1;
if (((float)abs(ps3->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
if (ps3_is_pressed(ps3->joypad, joypad_info, binds[port],
port, id))
return 1;
}
break;
case RETRO_DEVICE_ANALOG:
if (binds[port])
return input_joypad_analog(ps3->joypad, joypad_info, port, idx, id, binds[port]);
return input_joypad_analog(
ps3->joypad, joypad_info, port, idx, id, binds[port]);
break;
#if 0
case RETRO_DEVICE_SENSOR_ACCELEROMETER:

View File

@ -45,6 +45,28 @@ 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,
@ -62,39 +84,19 @@ static int16_t ps4_input_state(void *data,
int16_t ret = 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][i].joykey != NO_BTN)
? binds[port][i].joykey : joypad_info->auto_binds[i].joykey;
const uint32_t joyaxis = (binds[port][i].joyaxis != AXIS_NONE)
? binds[port][i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if ((uint16_t)joykey != NO_BTN && ps4->joypad->button(
joypad_info->joy_idx, (uint16_t)joykey))
{
if (
ps4_is_pressed(ps4->joypad, joypad_info, binds[port],
port, i))
ret |= (1 << i);
continue;
}
if (((float)abs(ps4->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
{
ret |= (1 << i);
continue;
}
}
return ret;
}
else
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][id].joykey != NO_BTN)
? binds[port][id].joykey : joypad_info->auto_binds[id].joykey;
const uint32_t joyaxis = (binds[port][id].joyaxis != AXIS_NONE)
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
if ((uint16_t)joykey != NO_BTN && ps4->joypad->button(
joypad_info->joy_idx, (uint16_t)joykey))
return 1;
if (((float)abs(ps4->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
if (
ps4_is_pressed(ps4->joypad, joypad_info, binds[port],
port, id))
return 1;
}
break;

View File

@ -203,6 +203,28 @@ 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,
@ -223,45 +245,24 @@ static int16_t ps3_input_state(void *data,
int16_t ret = 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][i].joykey != NO_BTN)
? binds[port][i].joykey : joypad_info->auto_binds[i].joykey;
const uint32_t joyaxis = (binds[port][i].joyaxis != AXIS_NONE)
? binds[port][i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if ((uint16_t)joykey != NO_BTN && ps3->joypad->button(
joypad_info->joy_idx, (uint16_t)joykey))
{
if (
psl1ght_is_pressed(ps3->joypad, joypad_info, binds[port],
port, i))
ret |= (1 << i);
continue;
}
else if (((float)abs(ps3->joypad->axis(
joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
{
ret |= (1 << i);
continue;
}
else if (psl1ght_keyboard_port_input_pressed(ps3, binds[port][i].key))
ret |= (1 << i);
}
return ret;
}
else
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][id].joykey != NO_BTN)
? binds[port][id].joykey : joypad_info->auto_binds[id].joykey;
const uint32_t joyaxis = (binds[port][id].joyaxis != AXIS_NONE)
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
if ((uint16_t)joykey != NO_BTN && ps3->joypad->button(
joypad_info->joy_idx, (uint16_t)joykey))
if (
psl1ght_is_pressed(ps3->joypad, joypad_info, binds[port],
port, id))
return 1;
if (((float)abs(ps3->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
return 1;
if (psl1ght_keyboard_port_input_pressed(ps3, binds[port][id].key))
else if (psl1ght_keyboard_port_input_pressed(
ps3, binds[port][id].key))
return 1;
}
break;

View File

@ -283,6 +283,27 @@ 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,
@ -306,37 +327,19 @@ static int16_t psp_input_state(void *data,
int16_t ret = 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][i].joykey != NO_BTN)
? binds[port][i].joykey : joypad_info->auto_binds[i].joykey;
const uint32_t joyaxis = (binds[port][i].joyaxis != AXIS_NONE)
? binds[port][i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if ((uint16_t)joykey != NO_BTN && psp->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
{
if (
psp_is_pressed(psp->joypad, joypad_info, binds[port],
port, i))
ret |= (1 << i);
continue;
}
if (((float)abs(psp->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
{
ret |= (1 << i);
continue;
}
}
return ret;
}
else
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][id].joykey != NO_BTN)
? binds[port][id].joykey : joypad_info->auto_binds[id].joykey;
const uint32_t joyaxis = (binds[port][id].joyaxis != AXIS_NONE)
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
if ((uint16_t)joykey != NO_BTN && psp->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
return 1;
if (((float)abs(psp->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
if (
psp_is_pressed(psp->joypad, joypad_info, binds[port],
port, id))
return 1;
}
break;

View File

@ -379,6 +379,28 @@ 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,
@ -399,36 +421,19 @@ static int16_t switch_input_state(void *data,
int16_t ret = 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][i].joykey != NO_BTN)
? binds[port][i].joykey : joypad_info->auto_binds[i].joykey;
const uint32_t joyaxis = (binds[port][i].joyaxis != AXIS_NONE)
? binds[port][i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if ((uint16_t)joykey != NO_BTN && sw->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
{
if (
switch_is_pressed(sw->joypad, joypad_info, binds[port],
port, i))
ret |= (1 << i);
continue;
}
if (((float)abs(sw->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
{
ret |= (1 << i);
continue;
}
}
return ret;
}
else
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][id].joykey != NO_BTN)
? binds[port][id].joykey : joypad_info->auto_binds[id].joykey;
const uint32_t joyaxis = (binds[port][id].joyaxis != AXIS_NONE)
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
if ((uint16_t)joykey != NO_BTN && sw->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
return 1;
if (((float)abs(sw->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
if (
switch_is_pressed(sw->joypad, joypad_info, binds[port],
port, id))
return 1;
}
break;

View File

@ -48,6 +48,28 @@ 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,
@ -69,37 +91,19 @@ static int16_t xdk_input_state(void *data,
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][i].joykey != NO_BTN)
? binds[port][i].joykey : joypad_info->auto_binds[i].joykey;
const uint32_t joyaxis = (binds[port][i].joyaxis != AXIS_NONE)
? binds[port][i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if ((uint16_t)joykey != NO_BTN && xdk->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
{
if (
xdk_is_pressed(xdk->joypad, joypad_info, binds[port],
port, i))
ret |= (1 << i);
continue;
}
if (((float)abs(xdk->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
{
ret |= (1 << i);
continue;
}
}
return ret;
}
else
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][id].joykey != NO_BTN)
? binds[port][id].joykey : joypad_info->auto_binds[id].joykey;
const uint32_t joyaxis = (binds[port][id].joyaxis != AXIS_NONE)
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
if ((uint16_t)joykey != NO_BTN && xdk->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
return 1;
if (((float)abs(xdk->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
if (
xdk_is_pressed(xdk->joypad, joypad_info, binds[port],
port, id))
return 1;
}
break;