mirror of
https://github.com/libretro/RetroArch
synced 2025-04-16 17:43:02 +00:00
(udev) Cleanups
This commit is contained in:
parent
a7ab21ac15
commit
d1d8386343
@ -940,19 +940,11 @@ static int16_t udev_is_pressed(
|
|||||||
unsigned port, unsigned id)
|
unsigned port, unsigned id)
|
||||||
{
|
{
|
||||||
const struct retro_keybind *bind = &binds[id];
|
const struct retro_keybind *bind = &binds[id];
|
||||||
|
|
||||||
if ( (bind->key < RETROK_LAST) && udev_keyboard_pressed(udev, bind->key) )
|
|
||||||
if ((id == RARCH_GAME_FOCUS_TOGGLE) || !input_udev.keyboard_mapping_blocked)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (binds && binds[id].valid)
|
|
||||||
{
|
|
||||||
/* Auto-binds are per joypad, not per user. */
|
/* Auto-binds are per joypad, not per user. */
|
||||||
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
||||||
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
||||||
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
||||||
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||||
|
|
||||||
if (udev_mouse_button_pressed(udev, port, bind->mbutton))
|
if (udev_mouse_button_pressed(udev, port, bind->mbutton))
|
||||||
return 1;
|
return 1;
|
||||||
if ((uint16_t)joykey != NO_BTN && joypad->button(
|
if ((uint16_t)joykey != NO_BTN && joypad->button(
|
||||||
@ -961,8 +953,6 @@ static int16_t udev_is_pressed(
|
|||||||
if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis))
|
if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||||
/ 0x8000) > joypad_info->axis_threshold)
|
/ 0x8000) > joypad_info->axis_threshold)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1023,22 +1013,48 @@ static int16_t udev_input_state(void *data,
|
|||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int16_t ret = 0;
|
int16_t ret = 0;
|
||||||
|
if (input_udev.keyboard_mapping_blocked)
|
||||||
|
{
|
||||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||||
{
|
{
|
||||||
|
if (binds[port][i].valid)
|
||||||
if (udev_is_pressed(
|
if (udev_is_pressed(
|
||||||
udev, udev->joypad,
|
udev, udev->joypad,
|
||||||
joypad_info, binds[port], port, i))
|
joypad_info, binds[port], port, i))
|
||||||
ret |= (1 << i);
|
ret |= (1 << i);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||||
|
{
|
||||||
|
if ( (binds[port][i].key < RETROK_LAST) &&
|
||||||
|
udev_keyboard_pressed(udev, binds[port][i].key) )
|
||||||
|
return 1;
|
||||||
|
if (binds[port][i].valid)
|
||||||
|
if (udev_is_pressed(
|
||||||
|
udev, udev->joypad,
|
||||||
|
joypad_info, binds[port], port, i))
|
||||||
|
ret |= (1 << i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (id < RARCH_BIND_LIST_END)
|
if (id < RARCH_BIND_LIST_END)
|
||||||
|
{
|
||||||
|
if ( (binds[port][i].key < RETROK_LAST) &&
|
||||||
|
udev_keyboard_pressed(udev, binds[port][i].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,
|
return udev_is_pressed(udev, udev->joypad,
|
||||||
joypad_info, binds[port], port, id);
|
joypad_info, binds[port], port, id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case RETRO_DEVICE_ANALOG:
|
case RETRO_DEVICE_ANALOG:
|
||||||
{
|
{
|
||||||
@ -1076,49 +1092,126 @@ static int16_t udev_input_state(void *data,
|
|||||||
|
|
||||||
/*buttons*/
|
/*buttons*/
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER:
|
case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER:
|
||||||
|
if (!input_udev.keyboard_mapping_blocked)
|
||||||
|
if ((binds[port][RARCH_LIGHTGUN_TRIGGER].key < RETROK_LAST)
|
||||||
|
&& udev_keyboard_pressed(udev, binds[port]
|
||||||
|
[RARCH_LIGHTGUN_TRIGGER].key) )
|
||||||
|
return 1;
|
||||||
|
if (binds[port][RARCH_LIGHTGUN_TRIGGER].valid)
|
||||||
return udev_is_pressed(udev, udev->joypad,
|
return udev_is_pressed(udev, udev->joypad,
|
||||||
joypad_info,
|
joypad_info, binds[port],
|
||||||
binds[port], port, RARCH_LIGHTGUN_TRIGGER);
|
port, RARCH_LIGHTGUN_TRIGGER);
|
||||||
|
break;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_RELOAD:
|
case RETRO_DEVICE_ID_LIGHTGUN_RELOAD:
|
||||||
|
if (!input_udev.keyboard_mapping_blocked)
|
||||||
|
if ((binds[port][RARCH_LIGHTGUN_RELOAD].key < RETROK_LAST)
|
||||||
|
&& x_keyboard_pressed(udev, binds[port]
|
||||||
|
[RARCH_LIGHTGUN_RELOAD].key) )
|
||||||
|
return 1;
|
||||||
|
if (binds[port][RARCH_LIGHTGUN_RELOAD].valid)
|
||||||
return udev_is_pressed(udev, udev->joypad,
|
return udev_is_pressed(udev, udev->joypad,
|
||||||
joypad_info,
|
joypad_info, binds[port],
|
||||||
binds[port], port, RARCH_LIGHTGUN_RELOAD);
|
port, RARCH_LIGHTGUN_RELOAD);
|
||||||
|
break;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_AUX_A:
|
case RETRO_DEVICE_ID_LIGHTGUN_AUX_A:
|
||||||
|
if (!input_udev.keyboard_mapping_blocked)
|
||||||
|
if ((binds[port][RARCH_LIGHTGUN_AUX_A].key < RETROK_LAST)
|
||||||
|
&& udev_keyboard_pressed(udev, binds[port]
|
||||||
|
[RARCH_LIGHTGUN_AUX_A].key) )
|
||||||
|
return 1;
|
||||||
|
if (binds[port][RARCH_LIGHTGUN_AUX_A].valid)
|
||||||
return udev_is_pressed(udev, udev->joypad,
|
return udev_is_pressed(udev, udev->joypad,
|
||||||
joypad_info,
|
joypad_info, binds[port],
|
||||||
binds[port], port, RARCH_LIGHTGUN_AUX_A);
|
port, RARCH_LIGHTGUN_AUX_A);
|
||||||
|
break;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_AUX_B:
|
case RETRO_DEVICE_ID_LIGHTGUN_AUX_B:
|
||||||
|
if (!input_udev.keyboard_mapping_blocked)
|
||||||
|
if ((binds[port][RARCH_LIGHTGUN_AUX_B].key < RETROK_LAST)
|
||||||
|
&& udev_keyboard_pressed(udev, binds[port]
|
||||||
|
[RARCH_LIGHTGUN_AUX_B].key) )
|
||||||
|
return 1;
|
||||||
|
if (binds[port][RARCH_LIGHTGUN_AUX_B].valid)
|
||||||
return udev_is_pressed(udev, udev->joypad,
|
return udev_is_pressed(udev, udev->joypad,
|
||||||
joypad_info,
|
joypad_info, binds[port],
|
||||||
binds[port], port, RARCH_LIGHTGUN_AUX_B);
|
port, RARCH_LIGHTGUN_AUX_B);
|
||||||
|
break;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_AUX_C:
|
case RETRO_DEVICE_ID_LIGHTGUN_AUX_C:
|
||||||
|
if (!input_udev.keyboard_mapping_blocked)
|
||||||
|
if ((binds[port][RARCH_LIGHTGUN_AUX_C].key < RETROK_LAST)
|
||||||
|
&& udev_keyboard_pressed(udev, binds[port]
|
||||||
|
[RARCH_LIGHTGUN_AUX_C].key) )
|
||||||
|
return 1;
|
||||||
|
if (binds[port][RARCH_LIGHTGUN_AUX_C].valid)
|
||||||
return udev_is_pressed(udev, udev->joypad,
|
return udev_is_pressed(udev, udev->joypad,
|
||||||
joypad_info,
|
joypad_info, binds[port],
|
||||||
binds[port], port, RARCH_LIGHTGUN_AUX_C);
|
port, RARCH_LIGHTGUN_AUX_C);
|
||||||
|
break;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_START:
|
case RETRO_DEVICE_ID_LIGHTGUN_START:
|
||||||
|
if (!input_udev.keyboard_mapping_blocked)
|
||||||
|
if ((binds[port][RARCH_LIGHTGUN_START].key < RETROK_LAST)
|
||||||
|
&& udev_keyboard_pressed(udev, binds[port]
|
||||||
|
[RARCH_LIGHTGUN_START].key) )
|
||||||
|
return 1;
|
||||||
|
if (binds[port][RARCH_LIGHTGUN_START].valid)
|
||||||
return udev_is_pressed(udev, udev->joypad,
|
return udev_is_pressed(udev, udev->joypad,
|
||||||
joypad_info,
|
joypad_info, binds[port],
|
||||||
binds[port], port, RARCH_LIGHTGUN_START);
|
port, RARCH_LIGHTGUN_START);
|
||||||
|
break;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_SELECT:
|
case RETRO_DEVICE_ID_LIGHTGUN_SELECT:
|
||||||
|
if (!input_udev.keyboard_mapping_blocked)
|
||||||
|
if ((binds[port][RARCH_LIGHTGUN_SELECT].key < RETROK_LAST)
|
||||||
|
&& udev_keyboard_pressed(udev, binds[port]
|
||||||
|
[RARCH_LIGHTGUN_SELECT].key) )
|
||||||
|
return 1;
|
||||||
|
if (binds[port][RARCH_LIGHTGUN_SELECT].valid)
|
||||||
return udev_is_pressed(udev, udev->joypad,
|
return udev_is_pressed(udev, udev->joypad,
|
||||||
joypad_info,
|
joypad_info, binds[port],
|
||||||
binds[port], port, RARCH_LIGHTGUN_SELECT);
|
port, RARCH_LIGHTGUN_SELECT);
|
||||||
|
break;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP:
|
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP:
|
||||||
|
if (!input_udev.keyboard_mapping_blocked)
|
||||||
|
if ((binds[port][RARCH_LIGHTGUN_DPAD_UP].key < RETROK_LAST)
|
||||||
|
&& udev_keyboard_pressed(udev, binds[port]
|
||||||
|
[RARCH_LIGHTGUN_DPAD_UP].key) )
|
||||||
|
return 1;
|
||||||
|
if (binds[port][RARCH_LIGHTGUN_DPAD_UP].valid)
|
||||||
return udev_is_pressed(udev, udev->joypad,
|
return udev_is_pressed(udev, udev->joypad,
|
||||||
joypad_info,
|
joypad_info, binds[port],
|
||||||
binds[port], port, RARCH_LIGHTGUN_DPAD_UP);
|
port, RARCH_LIGHTGUN_DPAD_UP);
|
||||||
|
break;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN:
|
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN:
|
||||||
|
if (!input_udev.keyboard_mapping_blocked)
|
||||||
|
if ((binds[port][RARCH_LIGHTGUN_DPAD_DOWN].key < RETROK_LAST)
|
||||||
|
&& udev_keyboard_pressed(udev, binds[port]
|
||||||
|
[RARCH_LIGHTGUN_DPAD_DOWN].key) )
|
||||||
|
return 1;
|
||||||
|
if (binds[port][RARCH_LIGHTGUN_DPAD_DOWN].valid)
|
||||||
return udev_is_pressed(udev, udev->joypad,
|
return udev_is_pressed(udev, udev->joypad,
|
||||||
joypad_info,
|
joypad_info, binds[port],
|
||||||
binds[port], port, RARCH_LIGHTGUN_DPAD_DOWN);
|
port, RARCH_LIGHTGUN_DPAD_DOWN);
|
||||||
|
break;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT:
|
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT:
|
||||||
|
if (!input_udev.keyboard_mapping_blocked)
|
||||||
|
if ((binds[port][RARCH_LIGHTGUN_DPAD_LEFT].key < RETROK_LAST)
|
||||||
|
&& udev_keyboard_pressed(udev, binds[port]
|
||||||
|
[RARCH_LIGHTGUN_DPAD_LEFT].key) )
|
||||||
|
return 1;
|
||||||
|
if (binds[port][RARCH_LIGHTGUN_DPAD_LEFT].valid)
|
||||||
return udev_is_pressed(udev, udev->joypad,
|
return udev_is_pressed(udev, udev->joypad,
|
||||||
joypad_info,
|
joypad_info, binds[port],
|
||||||
binds[port], port, RARCH_LIGHTGUN_DPAD_LEFT);
|
port, RARCH_LIGHTGUN_DPAD_LEFT);
|
||||||
|
break;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT:
|
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT:
|
||||||
|
if (!input_udev.keyboard_mapping_blocked)
|
||||||
|
if ((binds[port][RARCH_LIGHTGUN_DPAD_RIGHT].key < RETROK_LAST)
|
||||||
|
&& udev_keyboard_pressed(udev, binds[port]
|
||||||
|
[RARCH_LIGHTGUN_DPAD_RIGHT].key) )
|
||||||
|
return 1;
|
||||||
|
if (binds[port][RARCH_LIGHTGUN_DPAD_RIGHT].valid)
|
||||||
return udev_is_pressed(udev, udev->joypad,
|
return udev_is_pressed(udev, udev->joypad,
|
||||||
joypad_info,
|
joypad_info, binds[port],
|
||||||
binds[port], port, RARCH_LIGHTGUN_DPAD_RIGHT);
|
port, RARCH_LIGHTGUN_DPAD_RIGHT);
|
||||||
|
break;
|
||||||
|
|
||||||
/*deprecated*/
|
/*deprecated*/
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_X:
|
case RETRO_DEVICE_ID_LIGHTGUN_X:
|
||||||
|
@ -331,7 +331,7 @@ static int16_t x_input_state(void *data,
|
|||||||
{
|
{
|
||||||
if ((binds[port][i].key < RETROK_LAST) &&
|
if ((binds[port][i].key < RETROK_LAST) &&
|
||||||
x_keyboard_pressed(x11, binds[port][i].key) )
|
x_keyboard_pressed(x11, binds[port][i].key) )
|
||||||
return true;
|
return 1;
|
||||||
if (binds[port][i].valid)
|
if (binds[port][i].valid)
|
||||||
if (x_is_pressed(
|
if (x_is_pressed(
|
||||||
x11, x11->joypad,
|
x11, x11->joypad,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user