mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 12:40:23 +00:00
Further input driver standardization
This commit is contained in:
parent
6e621a98d9
commit
4a91b11806
@ -1435,10 +1435,10 @@ static int16_t android_input_state(void *data,
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (
|
||||
android_keyboard_port_input_pressed(binds[port], i)
|
||||
|| button_is_pressed(
|
||||
button_is_pressed(
|
||||
android->joypad, joypad_info, binds[port],
|
||||
port, i)
|
||||
|| android_keyboard_port_input_pressed(binds[port], i)
|
||||
)
|
||||
ret |= (1 << i);
|
||||
}
|
||||
@ -1447,10 +1447,11 @@ static int16_t android_input_state(void *data,
|
||||
else
|
||||
{
|
||||
if (
|
||||
android_keyboard_port_input_pressed(binds[port], id)
|
||||
|| button_is_pressed(
|
||||
button_is_pressed(
|
||||
android->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
port, id)
|
||||
|| android_keyboard_port_input_pressed(binds[port], id)
|
||||
)
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
@ -306,36 +306,36 @@ static int16_t cocoa_input_state(void *data,
|
||||
int16_t ret = 0;
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (apple_key_state[rarch_keysym_lut[binds[port][i].key]])
|
||||
ret |= (1 << i);
|
||||
else if (button_is_pressed(
|
||||
if (button_is_pressed(
|
||||
apple->joypad,
|
||||
joypad_info, binds[port], port, i))
|
||||
ret |= (1 << i);
|
||||
ret |= (1 << i);
|
||||
#ifdef HAVE_MFI
|
||||
else if (button_is_pressed(
|
||||
apple->sec_joypad,
|
||||
joypad_info, binds[port], port, i))
|
||||
ret |= (1 << i);
|
||||
#endif
|
||||
else if (apple_key_state[rarch_keysym_lut[binds[port][i].key]])
|
||||
ret |= (1 << i);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
if (button_is_pressed(
|
||||
apple->joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
#ifdef HAVE_MFI
|
||||
else if (button_is_pressed(
|
||||
apple->sec_joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
#endif
|
||||
else if (id < RARCH_BIND_LIST_END)
|
||||
if (apple_key_state[rarch_keysym_lut[binds[port][id].key]])
|
||||
return 1;
|
||||
if (button_is_pressed(
|
||||
apple->joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
#ifdef HAVE_MFI
|
||||
if (button_is_pressed(
|
||||
apple->sec_joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -74,11 +74,9 @@ static int16_t ctr_input_state(void *data,
|
||||
else
|
||||
{
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
{
|
||||
if (binds[port][id].valid)
|
||||
return button_is_pressed(
|
||||
ctr->joypad, joypad_info, binds[port], port, id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -563,16 +563,16 @@ static int16_t dinput_input_state(void *data,
|
||||
{
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (
|
||||
if (button_is_pressed(
|
||||
di->joypad,
|
||||
joypad_info, binds[port], port, i))
|
||||
ret |= (1 << i);
|
||||
else if (
|
||||
settings->uints.input_mouse_index[port] == 0
|
||||
&& dinput_mouse_button_pressed(
|
||||
di, port, binds[port][i].mbutton)
|
||||
)
|
||||
ret |= (1 << i);
|
||||
else if (button_is_pressed(
|
||||
di->joypad,
|
||||
joypad_info, binds[port], port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -580,20 +580,21 @@ static int16_t dinput_input_state(void *data,
|
||||
{
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if ((binds[port][i].key < RETROK_LAST) &&
|
||||
di->state[rarch_keysym_lut[(enum retro_key)binds[port][i].key]] & 0x80)
|
||||
ret |= (1 << i);
|
||||
else if (binds[port][i].valid)
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (
|
||||
if (button_is_pressed(
|
||||
di->joypad, joypad_info,
|
||||
binds[port], port, i))
|
||||
ret |= (1 << i);
|
||||
else if ((binds[port][i].key < RETROK_LAST) &&
|
||||
di->state[rarch_keysym_lut
|
||||
[(enum retro_key)binds[port][i].key]] & 0x80)
|
||||
ret |= (1 << i);
|
||||
else if (
|
||||
settings->uints.input_mouse_index[port] == 0
|
||||
&& dinput_mouse_button_pressed(
|
||||
di, port, binds[port][i].mbutton)
|
||||
)
|
||||
ret |= (1 << i);
|
||||
else if (button_is_pressed(
|
||||
di->joypad, joypad_info,
|
||||
binds[port], port, i))
|
||||
)
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
@ -604,23 +605,25 @@ static int16_t dinput_input_state(void *data,
|
||||
{
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
{
|
||||
if (binds[port][id].key < RETROK_LAST)
|
||||
{
|
||||
if (di->state[rarch_keysym_lut[(enum retro_key)binds[port][id].key]] & 0x80)
|
||||
if ((id == RARCH_GAME_FOCUS_TOGGLE) || !input_dinput.keyboard_mapping_blocked)
|
||||
return 1;
|
||||
}
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (
|
||||
if (button_is_pressed(
|
||||
di->joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
else if (binds[port][id].key < RETROK_LAST
|
||||
&& (di->state[rarch_keysym_lut
|
||||
[(enum retro_key)binds[port][id].key]] & 0x80)
|
||||
&& ( (id == RARCH_GAME_FOCUS_TOGGLE)
|
||||
|| !input_dinput.keyboard_mapping_blocked)
|
||||
)
|
||||
return 1;
|
||||
else if (
|
||||
settings->uints.input_mouse_index[port] == 0
|
||||
&& dinput_mouse_button_pressed(
|
||||
di, port, binds[port][id].mbutton)
|
||||
)
|
||||
)
|
||||
return 1;
|
||||
return button_is_pressed(
|
||||
di->joypad,
|
||||
joypad_info, binds[port], port, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -723,23 +726,25 @@ static int16_t dinput_input_state(void *data,
|
||||
new_id = RARCH_LIGHTGUN_START;
|
||||
break;
|
||||
}
|
||||
if (binds[port][new_id].key < RETROK_LAST)
|
||||
{
|
||||
if (!input_dinput.keyboard_mapping_blocked)
|
||||
if (di->state[rarch_keysym_lut[(enum retro_key)binds[port][new_id].key]] & 0x80)
|
||||
return 1;
|
||||
}
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
if (
|
||||
if (button_is_pressed(di->joypad,
|
||||
joypad_info,
|
||||
binds[port], port, new_id))
|
||||
return 1;
|
||||
else if (
|
||||
binds[port][new_id].key < RETROK_LAST
|
||||
&& !input_dinput.keyboard_mapping_blocked
|
||||
&& di->state[rarch_keysym_lut
|
||||
[(enum retro_key)binds[port][new_id].key]] & 0x80
|
||||
)
|
||||
return 1;
|
||||
else if (
|
||||
settings->uints.input_mouse_index[port] == 0
|
||||
&& dinput_mouse_button_pressed(
|
||||
di, port, binds[port][new_id].mbutton)
|
||||
)
|
||||
)
|
||||
return 1;
|
||||
return button_is_pressed(di->joypad,
|
||||
joypad_info,
|
||||
binds[port], port, new_id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -89,22 +89,32 @@ static int16_t dos_input_state(void *data,
|
||||
int16_t ret = 0;
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (
|
||||
dos_keyboard_port_input_pressed(binds[port], i)
|
||||
|| button_is_pressed(dos->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(
|
||||
dos->joypad, joypad_info, binds[port],
|
||||
port, i)
|
||||
|| dos_keyboard_port_input_pressed(binds[port], i)
|
||||
)
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (
|
||||
dos_keyboard_port_input_pressed(binds[port], id)
|
||||
|| button_is_pressed(dos->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(
|
||||
dos->joypad, joypad_info, binds[port],
|
||||
port, id)
|
||||
|| dos_keyboard_port_input_pressed(binds[port], id)
|
||||
)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
|
@ -154,20 +154,25 @@ static int16_t gx_input_state(void *data,
|
||||
int16_t ret = 0;
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(gx->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(
|
||||
gx->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (
|
||||
button_is_pressed(gx->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
if (binds[port][id].valid)
|
||||
if (
|
||||
button_is_pressed(gx->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -122,32 +122,19 @@ static int16_t linuxraw_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 ((binds[port]->valid &&
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(
|
||||
linuxraw->joypad, joypad_info, binds[port],
|
||||
port, i)
|
||||
)
|
||||
ret |= (1 << i);
|
||||
else if (
|
||||
linuxraw->state[rarch_keysym_lut[
|
||||
(enum retro_key)binds[port][i].key]]
|
||||
))
|
||||
{
|
||||
ret |= (1 << i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((uint16_t)joykey != NO_BTN && linuxraw->joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
{
|
||||
ret |= (1 << i);
|
||||
continue;
|
||||
}
|
||||
if (((float)abs(linuxraw->joypad->axis(
|
||||
joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
{
|
||||
ret |= (1 << i);
|
||||
continue;
|
||||
)
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,20 +142,22 @@ static int16_t linuxraw_input_state(void *data,
|
||||
}
|
||||
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 (((id < RARCH_BIND_LIST_END) && binds[port]->valid &&
|
||||
linuxraw->state[rarch_keysym_lut[(enum retro_key)binds[port][id].key]]
|
||||
))
|
||||
return 1;
|
||||
|
||||
if ((uint16_t)joykey != NO_BTN && linuxraw->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (((float)abs(linuxraw->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return 1;
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
{
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(
|
||||
linuxraw->joypad, joypad_info, binds[port],
|
||||
port, id)
|
||||
)
|
||||
return 1;
|
||||
else if ((linuxraw->state[rarch_keysym_lut
|
||||
[(enum retro_key)binds[port][id].key]]
|
||||
))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -58,18 +58,24 @@ static int16_t ps2_input_state(void *data,
|
||||
int16_t ret = 0;
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (button_is_pressed(ps2->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (button_is_pressed(ps2->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (button_is_pressed(ps2->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (button_is_pressed(ps2->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -113,19 +113,25 @@ static int16_t ps3_input_state(void *data,
|
||||
int16_t ret = 0;
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(ps3->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(ps3->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (button_is_pressed(ps3->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (button_is_pressed(ps3->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -62,20 +62,26 @@ static int16_t ps4_input_state(void *data,
|
||||
int16_t ret = 0;
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(ps4->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(ps4->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (
|
||||
button_is_pressed(ps4->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(ps4->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -223,25 +223,31 @@ static int16_t ps3_input_state(void *data,
|
||||
int16_t ret = 0;
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (
|
||||
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))
|
||||
ret |= (1 << i);
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (
|
||||
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))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (
|
||||
button_is_pressed(ps3->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
else if (psl1ght_keyboard_port_input_pressed(
|
||||
ps3, binds[port][id].key))
|
||||
return 1;
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(ps3->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
else if (psl1ght_keyboard_port_input_pressed(
|
||||
ps3, binds[port][id].key))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -305,20 +305,26 @@ static int16_t psp_input_state(void *data,
|
||||
int16_t ret = 0;
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(psp->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(psp->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (
|
||||
button_is_pressed(psp->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(psp->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -752,26 +752,20 @@ static int16_t qnx_is_pressed(
|
||||
{
|
||||
const struct retro_keybind *bind = &binds[id];
|
||||
int key = bind->key;
|
||||
if (id >= RARCH_BIND_LIST_END)
|
||||
return 0;
|
||||
/* 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 (qnx_keyboard_pressed(qnx, key))
|
||||
if ((id == RARCH_GAME_FOCUS_TOGGLE) || !input_qnx.keyboard_mapping_blocked)
|
||||
return 1;
|
||||
if (binds && binds[id].valid)
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@ -823,21 +817,29 @@ static int16_t qnx_input_state(void *data,
|
||||
int16_t ret = 0;
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (qnx_is_pressed(
|
||||
qnx, qnx->joypad,
|
||||
joypad_info, binds[port], port, i))
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
ret |= (1 << i);
|
||||
continue;
|
||||
if (qnx_is_pressed(
|
||||
qnx, qnx->joypad,
|
||||
joypad_info, binds[port], port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
if (qnx_is_pressed(qnx, qnx->joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
{
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
{
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (qnx_is_pressed(qnx, qnx->joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
|
@ -475,33 +475,25 @@ static int16_t rwebinput_is_pressed(
|
||||
const struct retro_keybind *binds,
|
||||
unsigned port, unsigned id)
|
||||
{
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
{
|
||||
const struct retro_keybind *bind = &binds[id];
|
||||
int key = bind->key;
|
||||
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;
|
||||
int key = bind->key;
|
||||
|
||||
if ((key < RETROK_LAST) && rwebinput_key_pressed(rwebinput, key))
|
||||
if ((id == RARCH_GAME_FOCUS_TOGGLE) || !input_rwebinput.keyboard_mapping_blocked)
|
||||
return 1;
|
||||
|
||||
if (bind->valid)
|
||||
{
|
||||
/* 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 (port == 0 && !!rwebinput_mouse_state(&rwebinput->mouse,
|
||||
bind->mbutton, false))
|
||||
return 1;
|
||||
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;
|
||||
}
|
||||
}
|
||||
if ((key < RETROK_LAST) && rwebinput_key_pressed(rwebinput, key))
|
||||
if ((id == RARCH_GAME_FOCUS_TOGGLE) || !input_rwebinput.keyboard_mapping_blocked)
|
||||
return 1;
|
||||
if (port == 0 && !!rwebinput_mouse_state(&rwebinput->mouse,
|
||||
bind->mbutton, false))
|
||||
return 1;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -515,12 +507,18 @@ static int16_t rwebinput_analog_pressed(rwebinput_input_t *rwebinput,
|
||||
|
||||
input_conv_analog_id_to_bind_id(idx, id, id_minus, id_plus);
|
||||
|
||||
if (rwebinput_is_pressed(rwebinput,
|
||||
rwebinput->joypad, joypad_info, binds, idx, id_minus))
|
||||
pressed_minus = -0x7fff;
|
||||
if (rwebinput_is_pressed(rwebinput,
|
||||
rwebinput->joypad, joypad_info, binds, idx, id_plus))
|
||||
pressed_plus = 0x7fff;
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
{
|
||||
if (binds[id].valid)
|
||||
{
|
||||
if (rwebinput_is_pressed(rwebinput,
|
||||
rwebinput->joypad, joypad_info, binds, idx, id_minus))
|
||||
pressed_minus = -0x7fff;
|
||||
if (rwebinput_is_pressed(rwebinput,
|
||||
rwebinput->joypad, joypad_info, binds, idx, id_plus))
|
||||
pressed_plus = 0x7fff;
|
||||
}
|
||||
}
|
||||
|
||||
return pressed_plus + pressed_minus;
|
||||
}
|
||||
@ -541,12 +539,12 @@ static int16_t rwebinput_input_state(void *data,
|
||||
int16_t ret = 0;
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (rwebinput_is_pressed(
|
||||
rwebinput, rwebinput->joypad,
|
||||
joypad_info, binds[port], port, i))
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
ret |= (1 << i);
|
||||
continue;
|
||||
if (rwebinput_is_pressed(
|
||||
rwebinput, rwebinput->joypad,
|
||||
joypad_info, binds[port], port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -555,10 +553,15 @@ static int16_t rwebinput_input_state(void *data,
|
||||
else
|
||||
{
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
if (rwebinput_is_pressed(rwebinput, rwebinput->joypad,
|
||||
joypad_info, binds[port],
|
||||
port, id))
|
||||
return true;
|
||||
{
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (rwebinput_is_pressed(rwebinput, rwebinput->joypad,
|
||||
joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -89,29 +89,6 @@ static int16_t sdl_analog_pressed(sdl_input_t *sdl, const struct retro_keybind *
|
||||
return pressed_plus + pressed_minus;
|
||||
}
|
||||
|
||||
static int16_t sdl_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 ((binds[id].key < RETROK_LAST) && sdl_key_pressed(binds[id].key))
|
||||
return 1;
|
||||
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 sdl_mouse_device_state(sdl_input_t *sdl, unsigned id)
|
||||
{
|
||||
switch (id)
|
||||
@ -228,9 +205,14 @@ static int16_t sdl_input_state(void *data,
|
||||
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (sdl_is_pressed(
|
||||
sdl->joypad, joypad_info, binds[port], port, i))
|
||||
ret |= (1 << i);
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (button_is_pressed(
|
||||
sdl->joypad, joypad_info, binds[port], port, i))
|
||||
ret |= (1 << i);
|
||||
else if (sdl_key_pressed(binds[port][i].key))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -238,9 +220,16 @@ static int16_t sdl_input_state(void *data,
|
||||
else
|
||||
{
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
if (sdl_is_pressed(sdl->joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
{
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (button_is_pressed(sdl->joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
else if (sdl_key_pressed(binds[port][id].key))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -399,20 +399,26 @@ static int16_t switch_input_state(void *data,
|
||||
int16_t ret = 0;
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(sw->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(sw->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (
|
||||
button_is_pressed(sw->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(sw->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -1018,10 +1018,12 @@ static int16_t udev_input_state(void *data,
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (udev_is_pressed(
|
||||
udev, udev->joypad,
|
||||
joypad_info, binds[port], port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1032,12 +1034,8 @@ static int16_t udev_input_state(void *data,
|
||||
{
|
||||
if (udev_is_pressed(udev, udev->joypad,
|
||||
joypad_info, binds[port], port, i))
|
||||
{
|
||||
ret |= (1 << i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((binds[port][i].key < RETROK_LAST) &&
|
||||
else if ((binds[port][i].key < RETROK_LAST) &&
|
||||
udev_keyboard_pressed(udev, binds[port][i].key))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
@ -1050,14 +1048,19 @@ static int16_t udev_input_state(void *data,
|
||||
{
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
{
|
||||
if ( (binds[port][id].key < RETROK_LAST) &&
|
||||
udev_keyboard_pressed(udev, binds[port][id].key))
|
||||
if (( id == RARCH_GAME_FOCUS_TOGGLE)
|
||||
|| !input_udev.keyboard_mapping_blocked)
|
||||
return 1;
|
||||
if (binds[port][id].valid)
|
||||
return udev_is_pressed(udev, udev->joypad,
|
||||
joypad_info, binds[port], port, id);
|
||||
{
|
||||
if (udev_is_pressed(udev, udev->joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
else if (
|
||||
(binds[port][id].key < RETROK_LAST) &&
|
||||
udev_keyboard_pressed(udev, binds[port][id].key)
|
||||
&& (( id == RARCH_GAME_FOCUS_TOGGLE)
|
||||
|| !input_udev.keyboard_mapping_blocked)
|
||||
)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1222,17 +1225,25 @@ static int16_t udev_input_state(void *data,
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_X:
|
||||
{
|
||||
udev_input_mouse_t *mouse = udev_get_mouse(udev, port);
|
||||
return (mouse) ? udev_mouse_get_x(mouse) : 0;
|
||||
if (mouse)
|
||||
return udev_mouse_get_x(mouse);
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_Y:
|
||||
{
|
||||
udev_input_mouse_t *mouse = udev_get_mouse(udev, port);
|
||||
return (mouse) ? udev_mouse_get_y(mouse) : 0;
|
||||
if (mouse)
|
||||
return udev_mouse_get_y(mouse);
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_PAUSE:
|
||||
return udev_is_pressed(udev, udev->joypad,
|
||||
joypad_info,
|
||||
binds[port], port, RARCH_LIGHTGUN_START);
|
||||
if (binds[port][RARCH_LIGHTGUN_START].valid)
|
||||
{
|
||||
return udev_is_pressed(udev, udev->joypad,
|
||||
joypad_info,
|
||||
binds[port], port, RARCH_LIGHTGUN_START);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -190,11 +190,11 @@ static int16_t uwp_input_state(void *data,
|
||||
int16_t ret = 0;
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (uwp_pressed_joypad(
|
||||
uwp, joypad_info, binds[port], port, i))
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
ret |= (1 << i);
|
||||
continue;
|
||||
if (uwp_pressed_joypad(
|
||||
uwp, joypad_info, binds[port], port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,8 +203,14 @@ static int16_t uwp_input_state(void *data,
|
||||
else
|
||||
{
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
if (uwp_pressed_joypad(uwp, joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
{
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (uwp_pressed_joypad(uwp, joypad_info,
|
||||
binds[port], port, id))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -635,13 +635,13 @@ static int16_t winraw_input_state(void *d,
|
||||
{
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (mouse && winraw_mouse_button_pressed(wr,
|
||||
mouse, port, binds[port][i].mbutton))
|
||||
ret |= (1 << i);
|
||||
else if (button_is_pressed(
|
||||
if (button_is_pressed(
|
||||
wr->joypad,
|
||||
joypad_info, binds[port], port, i))
|
||||
ret |= (1 << i);
|
||||
else if (mouse && winraw_mouse_button_pressed(wr,
|
||||
mouse, port, binds[port][i].mbutton))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -649,18 +649,18 @@ static int16_t winraw_input_state(void *d,
|
||||
{
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if ((binds[port][i].key < RETROK_LAST) &&
|
||||
winraw_keyboard_pressed(wr, binds[port][i].key))
|
||||
ret |= (1 << i);
|
||||
else if (binds[port][i].valid)
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (mouse && winraw_mouse_button_pressed(wr,
|
||||
mouse, port, binds[port][i].mbutton))
|
||||
ret |= (1 << i);
|
||||
else if (button_is_pressed(
|
||||
if (button_is_pressed(
|
||||
wr->joypad,
|
||||
joypad_info, binds[port], port, i))
|
||||
ret |= (1 << i);
|
||||
else if ((binds[port][i].key < RETROK_LAST) &&
|
||||
winraw_keyboard_pressed(wr, binds[port][i].key))
|
||||
ret |= (1 << i);
|
||||
else if (mouse && winraw_mouse_button_pressed(wr,
|
||||
mouse, port, binds[port][i].mbutton))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -671,19 +671,22 @@ static int16_t winraw_input_state(void *d,
|
||||
{
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
{
|
||||
if ((binds[port][id].key < RETROK_LAST)
|
||||
&& winraw_keyboard_pressed(wr, binds[port][id].key))
|
||||
if (( id == RARCH_GAME_FOCUS_TOGGLE)
|
||||
|| !input_winraw.keyboard_mapping_blocked)
|
||||
return 1;
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (mouse && winraw_mouse_button_pressed(wr,
|
||||
if (button_is_pressed(
|
||||
wr->joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
else if (
|
||||
(binds[port][id].key < RETROK_LAST)
|
||||
&& winraw_keyboard_pressed(wr, binds[port][id].key)
|
||||
&& (( id == RARCH_GAME_FOCUS_TOGGLE)
|
||||
|| !input_winraw.keyboard_mapping_blocked)
|
||||
)
|
||||
return 1;
|
||||
else if (mouse && winraw_mouse_button_pressed(wr,
|
||||
mouse, port, binds[port][id].mbutton))
|
||||
return 1;
|
||||
return button_is_pressed(
|
||||
wr->joypad,
|
||||
joypad_info, binds[port], port, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -333,12 +333,8 @@ static int16_t x_input_state(void *data,
|
||||
{
|
||||
if (x_is_pressed(x11, x11->joypad,
|
||||
joypad_info, binds[port], port, i))
|
||||
{
|
||||
ret |= (1 << i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((binds[port][i].key < RETROK_LAST) &&
|
||||
else if ((binds[port][i].key < RETROK_LAST) &&
|
||||
x_keyboard_pressed(x11, binds[port][i].key))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
@ -351,14 +347,19 @@ static int16_t x_input_state(void *data,
|
||||
{
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
{
|
||||
if ((binds[port][id].key < RETROK_LAST) &&
|
||||
x_keyboard_pressed(x11, binds[port][id].key) )
|
||||
if (( id == RARCH_GAME_FOCUS_TOGGLE)
|
||||
|| !input_x.keyboard_mapping_blocked)
|
||||
return 1;
|
||||
if (binds[port][id].valid)
|
||||
return x_is_pressed(x11, x11->joypad,
|
||||
joypad_info, binds[port], port, id);
|
||||
{
|
||||
if (x_is_pressed(x11, x11->joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
else if (
|
||||
((binds[port][id].key < RETROK_LAST) &&
|
||||
x_keyboard_pressed(x11, binds[port][id].key))
|
||||
&& (( id == RARCH_GAME_FOCUS_TOGGLE)
|
||||
|| !input_x.keyboard_mapping_blocked)
|
||||
)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -69,20 +69,26 @@ static int16_t xdk_input_state(void *data,
|
||||
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(xdk->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(xdk->joypad, joypad_info, binds[port],
|
||||
port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (
|
||||
button_is_pressed(xdk->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(xdk->joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -81,15 +81,23 @@ static int16_t xenon360_input_state(void *data,
|
||||
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (state[port] & binds[port][i].joykey)
|
||||
ret |= (1 << i);
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (state[port] & binds[port][i].joykey)
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
if (state[port] & binds[port][id].joykey)
|
||||
return 1;
|
||||
{
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (state[port] & binds[port][id].joykey)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user