Insert input_joypad_pressed into drivers themselves

This commit is contained in:
twinaphex 2019-06-23 18:20:48 +02:00
parent 7a2fa44c4b
commit 9c73d3305d
23 changed files with 453 additions and 109 deletions

View File

@ -1363,6 +1363,10 @@ static void android_input_poll_memcpy(android_input_t *android)
static bool android_input_key_pressed(android_input_t *android, int key)
{
rarch_joypad_info_t joypad_info;
const uint16_t joykey = (input_config_binds[0][key].joykey != NO_BTN)
? input_config_binds[0][key].joykey : joypad_info.auto_binds[key].joykey;
const uint32_t joyaxis = (input_config_binds[0][key].joyaxis != AXIS_NONE)
? input_config_binds[0][key].joyaxis : joypad_info.auto_binds[key].joyaxis;
if((key < RARCH_BIND_LIST_END)
&& android_keyboard_port_input_pressed(input_config_binds[0],
@ -1373,10 +1377,10 @@ static bool android_input_key_pressed(android_input_t *android, int key)
joypad_info.auto_binds = input_autoconf_binds[0];
joypad_info.axis_threshold = *(input_driver_get_float(INPUT_ACTION_AXIS_THRESHOLD));
if (input_joypad_pressed(android->joypad, joypad_info,
0, input_config_binds[0], key))
if (joykey != NO_BTN && android->joypad->button(joypad_info.joy_idx, joykey))
return true;
else if (((float)abs(android->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
return true;
return false;
}
@ -1469,8 +1473,18 @@ static int16_t android_input_state(void *data,
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
bool res = input_joypad_pressed(android->joypad, joypad_info,
port, binds[port], i);
bool res = false;
/* Auto-binds are per joypad, not per user. */
const uint16_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 (joykey != NO_BTN && android->joypad->button(
joypad_info.joy_idx, joykey))
res = true;
else if (((float)abs(android->joypad->axis(
joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
res = true;
if (!res)
res = android_keyboard_port_input_pressed(binds[port], i);
if (res)
@ -1479,10 +1493,19 @@ static int16_t android_input_state(void *data,
}
else
{
ret = input_joypad_pressed(android->joypad, joypad_info,
port, binds[port], id);
/* Auto-binds are per joypad, not per user. */
const uint16_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 (joykey != NO_BTN && android->joypad->button(
joypad_info.joy_idx, joykey))
res = true;
else if (((float)abs(android->joypad->axis(
joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
res = true;
if (!ret && (id < RARCH_BIND_LIST_END))
ret = android_keyboard_port_input_pressed(binds[port],id);
ret = android_keyboard_port_input_pressed(binds[port], id);
}
return ret;
case RETRO_DEVICE_ANALOG:

View File

@ -305,12 +305,27 @@ static int16_t cocoa_input_state(void *data,
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
/* Auto-binds are per joypad, not per user. */
const uint16_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;
bool res = apple_key_state[rarch_keysym_lut[binds[port][i].key]];
if (!res)
res = input_joypad_pressed(apple->joypad, joypad_info, port, binds[port], i);
{
if (joykey != NO_BTN && apple->joypad->button(joypad_info.joy_idx, joykey))
res = true;
else if (((float)abs(apple->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
res = true;
}
#ifdef HAVE_MFI
if (!res)
res = input_joypad_pressed(apple->sec_joypad, joypad_info, port, binds[port], i);
{
if (joykey != NO_BTN && apple->sec_joypad->button(joypad_info.joy_idx, joykey))
res = true;
else if (((float)abs(apple->sec_joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
res = true;
}
#endif
if (res)
ret |= (1 << i);
@ -318,13 +333,29 @@ static int16_t cocoa_input_state(void *data,
}
else
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (id < RARCH_BIND_LIST_END)
ret = apple_key_state[rarch_keysym_lut[binds[port][id].key]];
if (!ret)
ret = input_joypad_pressed(apple->joypad, joypad_info, port, binds[port], id);
{
if (joykey != NO_BTN && apple->joypad->button(
joypad_info.joy_idx, joykey))
ret = 1;
else if (((float)abs(apple->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
ret = 1;
}
#ifdef HAVE_MFI
if (!ret)
ret = input_joypad_pressed(apple->sec_joypad, joypad_info, port, binds[port], id);
{
if (joykey != NO_BTN && apple->sec_joypad->button(joypad_info.joy_idx, joykey))
ret = 1;
else if (((float)abs(apple->sec_joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
ret = 1;
}
#endif
}
return ret;

View File

@ -66,14 +66,36 @@ static int16_t ctr_input_state(void *data,
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(ctr->joypad,
joypad_info, port, binds[port], i))
/* Auto-binds are per joypad, not per user. */
const uint16_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;
bool res = false;
if (joykey != NO_BTN &&
ctr->joypad->button(joypad_info.joy_idx, joykey))
res = true;
else if (((float)abs(ctr->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
res = true;
if (res)
ret |= (1 << i);
}
}
else
ret = input_joypad_pressed(ctr->joypad,
joypad_info, port, binds[port], id);
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (joykey != NO_BTN && ctr->joypad->button(joypad_info.joy_idx, joykey))
ret = 1;
else if (((float)abs(ctr->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
ret = 1;
}
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])

View File

@ -325,10 +325,19 @@ static bool dinput_is_pressed(struct dinput_input *di,
if (binds && binds[id].valid)
{
if (dinput_mouse_button_pressed(di, port, binds[id].mbutton))
return true;
if (input_joypad_pressed(di->joypad, joypad_info, port, binds, id))
return true;
/* Auto-binds are per joypad, not per user. */
const uint16_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 (dinput_mouse_button_pressed(di, port, binds[id].mbutton))
return true;
if (joykey != NO_BTN
&& di->joypad->button(joypad_info.joy_idx, joykey))
return true;
if (((float)abs(di->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
return true;
}
return false;

View File

@ -87,8 +87,17 @@ static int16_t dos_input_state(void *data,
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
bool res = input_joypad_pressed(ctr->joypad,
joypad_info, port, binds[port], i);
/* Auto-binds are per joypad, not per user. */
const uint16_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;
bool res = false;
if (joykey != NO_BTN && dos->joypad->button(joypad_info.joy_idx, joykey))
res = true;
else if (((float)abs(dos->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
res = true;
if (!res)
res = dos_keyboard_port_input_pressed(binds[port], i);
if (res)
@ -96,9 +105,21 @@ static int16_t dos_input_state(void *data,
}
}
else
ret = input_joypad_pressed(
dos->joypad, joypad_info, port, binds[port], id) ||
dos_keyboard_port_input_pressed(binds[port], id);
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (joykey != NO_BTN && dos->joypad->button(joypad_info.joy_idx, joykey))
ret = 1;
else if (((float)abs(dos->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
ret = 1;
if (!ret)
ret = dos_keyboard_port_input_pressed(binds[port], id);
}
return ret;
case RETRO_DEVICE_KEYBOARD:
return dos_keyboard_port_input_pressed(binds[port], id);

View File

@ -47,6 +47,7 @@ static int16_t gx_input_state(void *data,
unsigned idx, unsigned id)
{
gx_input_t *gx = (gx_input_t*)data;
int16_t ret = 0;
if (port >= MAX_PADS || !gx)
return 0;
@ -57,18 +58,38 @@ static int16_t gx_input_state(void *data,
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
unsigned i;
int16_t ret = 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(gx->joypad, joypad_info,
port, binds[port], i))
/* Auto-binds are per joypad, not per user. */
const uint16_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;
bool res = false;
if (joykey != NO_BTN && gx->joypad->button(joypad_info.joy_idx, joykey))
res = true;
else if (((float)abs(gx->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
res = true;
if (res)
ret |= (1 << i);
}
return ret;
}
return input_joypad_pressed(gx->joypad,
joypad_info, port, binds[port], id);
else
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (joykey != NO_BTN && gx->joypad->button(joypad_info.joy_idx, joykey))
ret = 1;
else if (((float)abs(gx->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
ret = 1;
}
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])
return input_joypad_analog(gx->joypad,

View File

@ -116,9 +116,21 @@ static int16_t linuxraw_input_state(void *data,
linuxraw->state[rarch_keysym_lut[
(enum retro_key)binds[port][i].key]]
);
if (!res)
res = input_joypad_pressed(linuxraw->joypad,
joypad_info, port, binds[port], i);
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (joykey != NO_BTN && linuxraw->joypad->button(joypad_info.joy_idx, joykey))
res = true;
else if (((float)abs(linuxraw->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
res = true;
}
if (res)
ret |= (1 << i);
}
@ -128,9 +140,19 @@ static int16_t linuxraw_input_state(void *data,
ret = ((id < RARCH_BIND_LIST_END) && binds[port]->valid &&
linuxraw->state[rarch_keysym_lut[(enum retro_key)binds[port][id].key]]
);
if (!ret)
ret = input_joypad_pressed(linuxraw->joypad,
joypad_info, port, binds[port], id);
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (joykey != NO_BTN && linuxraw->joypad->button(joypad_info.joy_idx, joykey))
ret = 1;
else if (((float)abs(linuxraw->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
ret = 1;
}
}
return ret;
case RETRO_DEVICE_ANALOG:

View File

@ -59,13 +59,35 @@ static int16_t ps2_input_state(void *data,
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(
ps2->joypad, joypad_info, port, binds[port], i))
/* Auto-binds are per joypad, not per user. */
const uint16_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;
bool res = false;
if (joykey != NO_BTN && ps2->joypad->button(joypad_info.joy_idx, joykey))
res = true;
else if (((float)abs(ps2->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
res = true;
if (res)
ret |= (1 << i);
}
}
else
ret = input_joypad_pressed(ps2->joypad, joypad_info, port, binds[port], id);
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (joykey != NO_BTN && ps2->joypad->button(joypad_info.joy_idx, joykey))
ret = 1;
else if (((float)abs(ps2->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
ret = 1;
}
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])

View File

@ -121,13 +121,35 @@ static int16_t ps3_input_state(void *data,
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(
ps3->joypad, joypad_info, port, binds[port], i))
/* Auto-binds are per joypad, not per user. */
const uint16_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;
bool res = false;
if (joykey != NO_BTN && ps3->joypad->button(joypad_info.joy_idx, joykey))
res = true;
else if (((float)abs(ps3->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
res = true;
if (res)
ret |= (1 << i);
}
}
else
ret = input_joypad_pressed(ps3->joypad, joypad_info, port, binds[port], id);
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (joykey != NO_BTN && ps3->joypad->button(joypad_info.joy_idx, joykey))
ret = 1;
else if (((float)abs(ps3->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
ret = 1;
}
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])

View File

@ -63,13 +63,35 @@ static int16_t ps4_input_state(void *data,
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(
ps4->joypad, joypad_info, port, binds[port], i))
/* Auto-binds are per joypad, not per user. */
const uint16_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;
bool res = false;
if (joykey != NO_BTN && ps4->joypad->button(joypad_info.joy_idx, joykey))
res = true;
else if (((float)abs(ps4->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
res = true;
if (res)
ret |= (1 << i);
}
}
else
ret = input_joypad_pressed(ps4->joypad, joypad_info, port, binds[port], id);
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (joykey != NO_BTN && ps4->joypad->button(joypad_info.joy_idx, joykey))
ret = 1;
else if (((float)abs(ps4->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
ret = 1;
}
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])

View File

@ -318,13 +318,35 @@ static int16_t psp_input_state(void *data,
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(
psp->joypad, joypad_info, port, binds[port], i))
/* Auto-binds are per joypad, not per user. */
const uint16_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;
bool res = false;
if (joykey != NO_BTN && psp->joypad->button(joypad_info.joy_idx, joykey))
res = true;
else if (((float)abs(psp->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
res = true;
if (res)
ret |= (1 << i);
}
}
else
ret = input_joypad_pressed(psp->joypad, joypad_info, port, binds[port], id);
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (joykey != NO_BTN && psp->joypad->button(joypad_info.joy_idx, joykey))
ret = 1;
else if (((float)abs(psp->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
ret = 1;
}
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])

View File

@ -743,8 +743,20 @@ static bool qnx_is_pressed(qnx_input_t *qnx,
if (qnx_keyboard_pressed(qnx, key))
if ((id == RARCH_GAME_FOCUS_TOGGLE) || !qnx->blocked)
return true;
if (binds && binds[id].valid && input_joypad_pressed(qnx->joypad, joypad_info, port, binds, id))
return true;
if (binds && binds[id].valid)
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (joykey != NO_BTN && qnx->joypad->button(joypad_info.joy_idx, joykey))
return true;
if (((float)abs(qnx->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
return true;
}
return false;
}

View File

@ -486,11 +486,18 @@ static bool rwebinput_is_pressed(rwebinput_input_t *rwebinput,
if (bind->valid)
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (port == 0 && !!rwebinput_mouse_state(&rwebinput->mouse,
bind->mbutton, false))
bind->mbutton, false))
return true;
if (input_joypad_pressed(rwebinput->joypad, joypad_info, port, binds,
id))
if (joykey != NO_BTN && rwebinput->joypad->button(joypad_info.joy_idx, joykey))
return true;
if (((float)abs(rwebinput->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
return true;
}
}

View File

@ -61,12 +61,12 @@ static void *sdl_input_init(const char *joypad_driver)
static bool sdl_key_pressed(int key)
{
int num_keys;
unsigned sym = rarch_keysym_lut[(enum retro_key)key];
#ifdef HAVE_SDL2
const uint8_t *keymap = SDL_GetKeyboardState(&num_keys);
sym = SDL_GetScancodeFromKey(sym);
unsigned sym = SDL_GetScancodeFromKey(rarch_keysym_lut[(enum retro_key)key]);
#else
const uint8_t *keymap = SDL_GetKeyState(&num_keys);
unsigned sym = rarch_keysym_lut[(enum retro_key)key];
#endif
if (sym >= (unsigned)num_keys)
@ -97,17 +97,30 @@ static int16_t sdl_joypad_device_state(sdl_input_t *sdl,
const struct retro_keybind *binds,
unsigned port, unsigned id, enum input_device_type *device)
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 ((binds[id].key < RETROK_LAST) && sdl_key_pressed(binds[id].key))
{
*device = INPUT_DEVICE_TYPE_KEYBOARD;
return 1;
}
if (input_joypad_pressed(sdl->joypad, joypad_info, 0, binds, id))
if (joykey != NO_BTN && sdl->joypad->button(joypad_info.joy_idx, joykey))
{
*device = INPUT_DEVICE_TYPE_JOYPAD;
return 1;
}
if (((float)abs(sdl->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
{
*device = INPUT_DEVICE_TYPE_JOYPAD;
return 1;
}
return 0;
}

View File

@ -271,15 +271,29 @@ static int16_t switch_input_state(void *data,
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(
sw->joypad, joypad_info, port, binds[port], i))
/* Auto-binds are per joypad, not per user. */
const uint16_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 (joykey != NO_BTN && sw->joypad->button(joypad_info.joy_idx, joykey))
ret |= (1 << i);
else if (((float)abs(sw->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
ret |= (1 << 1);
}
}
else
{
ret = input_joypad_pressed(sw->joypad,
joypad_info, port, binds[port], id);
/* Auto-binds are per joypad, not per user. */
const uint16_t joykey = (binds[port][id].joykey != NO_BTN)
? binds[port][id].joykey : joypad_info.auto_binds[i].joykey;
const uint32_t joyaxis = (binds[port][id].joyaxis != AXIS_NONE)
? binds[port][id].joyaxis : joypad_info.auto_binds[id].joyaxis;
if (joykey != NO_BTN && sw->joypad->button(joypad_info.joy_idx, joykey))
ret = 1;
else if (((float)abs(sw->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
ret = 1;
}
return ret;
case RETRO_DEVICE_ANALOG:

View File

@ -902,9 +902,17 @@ static bool udev_is_pressed(udev_input_t *udev,
if (binds && binds[id].valid)
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (udev_mouse_button_pressed(udev, port, bind->mbutton))
return true;
if (input_joypad_pressed(udev->joypad, joypad_info, port, binds, id))
if (joykey != NO_BTN && udev->joypad->button(joypad_info.joy_idx, joykey))
return true;
if (((float)abs(udev->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
return true;
}

View File

@ -138,9 +138,17 @@ static bool uwp_pressed_joypad(uwp_input_t *uwp,
/* Then, process the joypad bindings */
if (binds && binds[id].valid)
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (uwp_mouse_state(port, bind->mbutton, false))
return true;
if (input_joypad_pressed(uwp->joypad, joypad_info, port, binds, id))
if (joykey != NO_BTN && uwp->joypad->button(joypad_info.joy_idx, joykey))
return true;
if (((float)abs(uwp->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
return true;
}

View File

@ -299,7 +299,17 @@ static int16_t input_wl_state(void *data,
{
bool res = BIT_GET(wl->key_state, rarch_keysym_lut[binds[port][i].key]) ;
if (!res && binds[port])
res = input_joypad_pressed(wl->joypad, joypad_info, port, binds[port], i);
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (joykey != NO_BTN && wl->joypad->button(joypad_info.joy_idx, joykey))
res = true;
else if (((float)abs(wl->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
res = true;
}
if (res)
ret |= (1 << i);
}
@ -309,7 +319,17 @@ static int16_t input_wl_state(void *data,
if (id < RARCH_BIND_LIST_END)
ret = BIT_GET(wl->key_state, rarch_keysym_lut[binds[port][id].key]);
if (!ret && binds[port])
ret = input_joypad_pressed(wl->joypad, joypad_info, port, binds[port], id);
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (joykey != NO_BTN && wl->joypad->button(joypad_info.joy_idx, joykey))
ret = 1;
else if (((float)abs(drv->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
ret = 1;
}
}
return ret;
case RETRO_DEVICE_ANALOG:

View File

@ -147,15 +147,34 @@ static int16_t wiiu_input_state(void *data,
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(
wiiu->joypad, joypad_info, port, binds[port], i))
/* Auto-binds are per joypad, not per user. */
const uint16_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;
bool res = false;
if (joykey != NO_BTN && wiiu->joypad->button(joypad_info.joy_idx, joykey))
res = true;
else if (((float)abs(wiiu->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
res = true;
if (res)
ret |= (1 << i);
}
}
else
{
ret = input_joypad_pressed(wiiu->joypad,
joypad_info, port, binds[port], id);
/* Auto-binds are per joypad, not per user. */
const uint16_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 (joykey != NO_BTN && wiiu->joypad->button(joypad_info.joy_idx, joykey))
ret = 1;
else if (((float)abs(wiiu->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
ret = 1;
}
return ret;
case RETRO_DEVICE_KEYBOARD:

View File

@ -405,10 +405,18 @@ static bool winraw_is_pressed(winraw_input_t *wr,
return true;
if (binds && binds[id].valid)
{
if (winraw_mouse_button_pressed(wr, port, bind->mbutton))
return true;
if (input_joypad_pressed(wr->joypad, joypad_info, port, binds, id))
return true;
/* Auto-binds are per joypad, not per user. */
const uint16_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 (winraw_mouse_button_pressed(wr, port, bind->mbutton))
return true;
if (joykey != NO_BTN &&
wr->joypad->button(joypad_info.joy_idx, joykey))
return true;
if (((float)abs(wr->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
return true;
}
return false;

View File

@ -138,9 +138,18 @@ static bool x_is_pressed(x11_input_t *x11,
if (binds && binds[id].valid)
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (x_mouse_button_pressed(x11, port, bind->mbutton))
return true;
if (input_joypad_pressed(x11->joypad, joypad_info, port, binds, id))
if (joykey != NO_BTN
&& x11->joypad->button(joypad_info.joy_idx, joykey))
return true;
if (((float)abs(x11->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
return true;
}

View File

@ -69,13 +69,35 @@ static int16_t xdk_input_state(void *data,
unsigned i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (input_joypad_pressed(
xdk->joypad, joypad_info, port, binds[port], i))
/* Auto-binds are per joypad, not per user. */
const uint16_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;
bool res = false;
if (joykey != NO_BTN && xdk->joypad->button(joypad_info.joy_idx, joykey))
res = true;
else if (((float)abs(xdk->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
res = true;
if (res)
ret |= (1 << i);
}
}
else
ret = input_joypad_pressed(xdk->joypad, joypad_info, port, binds[port], id);
{
/* Auto-binds are per joypad, not per user. */
const uint16_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 (joykey != NO_BTN && xdk->joypad->button(joypad_info.joy_idx, joykey))
ret = 1;
else if (((float)abs(xdk->joypad->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold)
ret = 1;
}
return ret;
case RETRO_DEVICE_ANALOG:
if (binds[port])

View File

@ -446,39 +446,6 @@ const input_device_driver_t *input_joypad_init_driver(
break; \
}
/**
* input_joypad_pressed:
* @drv : Input device driver handle.
* @port : User number.
* @binds : Binds of user.
* @key : Identifier of key.
*
* Checks if key (@key) was being pressed by user
* with number @port with provided keybinds (@binds).
*
* Returns: true (1) if key was pressed, otherwise
* false (0).
**/
static INLINE bool input_joypad_pressed(
const input_device_driver_t *drv,
rarch_joypad_info_t joypad_info,
unsigned port,
const struct retro_keybind *binds,
unsigned key)
{
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[key].joykey != NO_BTN)
? binds[key].joykey : joypad_info.auto_binds[key].joykey;
const uint32_t joyaxis = (binds[key].joyaxis != AXIS_NONE)
? binds[key].joyaxis : joypad_info.auto_binds[key].joyaxis;
if ((uint16_t)joykey != NO_BTN && drv->button(joypad_info.joy_idx, (uint16_t)joykey))
return true;
return ((float)abs(drv->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold;
}
/**
* input_joypad_analog:
* @drv : Input device driver handle.