mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
(linuxraw_input.c) simplifications
This commit is contained in:
parent
3dede6d71a
commit
9e93bdbe27
@ -72,14 +72,6 @@ static void *linuxraw_input_init(const char *joypad_driver)
|
||||
return linuxraw;
|
||||
}
|
||||
|
||||
static bool linuxraw_is_pressed(linuxraw_input_t *linuxraw,
|
||||
const struct retro_keybind *binds, unsigned id)
|
||||
{
|
||||
const struct retro_keybind *bind = &binds[id];
|
||||
unsigned sym = rarch_keysym_lut[(enum retro_key)binds[id].key];
|
||||
return linuxraw->state[sym];
|
||||
}
|
||||
|
||||
static int16_t linuxraw_analog_pressed(linuxraw_input_t *linuxraw,
|
||||
const struct retro_keybind *binds, unsigned idx, unsigned id)
|
||||
{
|
||||
@ -90,10 +82,12 @@ static int16_t linuxraw_analog_pressed(linuxraw_input_t *linuxraw,
|
||||
input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus);
|
||||
|
||||
if ((id_minus < RARCH_BIND_LIST_END) && binds && binds->valid &&
|
||||
linuxraw_is_pressed(linuxraw, binds, id_minus))
|
||||
linuxraw->state[rarch_keysym_lut[(enum retro_key)binds[id_minus].key]]
|
||||
)
|
||||
pressed_minus = -0x7fff;
|
||||
if ((id_plus < RARCH_BIND_LIST_END) && binds && binds->valid &&
|
||||
linuxraw_is_pressed(linuxraw, binds, id_plus))
|
||||
linuxraw->state[rarch_keysym_lut[(enum retro_key)binds[id_plus].key]]
|
||||
)
|
||||
pressed_plus = 0x7fff;
|
||||
|
||||
return pressed_plus + pressed_minus;
|
||||
@ -109,21 +103,26 @@ static int16_t linuxraw_input_state(void *data,
|
||||
const struct retro_keybind **binds, unsigned port,
|
||||
unsigned device, unsigned idx, unsigned id)
|
||||
{
|
||||
int16_t ret = 0;
|
||||
linuxraw_input_t *linuxraw = (linuxraw_input_t*)data;
|
||||
|
||||
switch (device)
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
return ((id < RARCH_BIND_LIST_END) && binds[port]->valid &&
|
||||
linuxraw_is_pressed(linuxraw, binds[port], id)) ||
|
||||
input_joypad_pressed(linuxraw->joypad, joypad_info, port, binds[port], id);
|
||||
linuxraw->state[rarch_keysym_lut[(enum retro_key)binds[port][id].key]]
|
||||
)
|
||||
|| input_joypad_pressed(linuxraw->joypad,
|
||||
joypad_info, port, binds[port], id);
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
ret = linuxraw_analog_pressed(linuxraw, binds[port], idx, id);
|
||||
if (!ret && binds[port])
|
||||
ret = input_joypad_analog(linuxraw->joypad, joypad_info, port, idx, id, binds[port]);
|
||||
return ret;
|
||||
{
|
||||
int16_t ret = linuxraw_analog_pressed(linuxraw, binds[port], idx, id);
|
||||
if (!ret)
|
||||
ret = input_joypad_analog(linuxraw->joypad,
|
||||
joypad_info, port, idx, id, binds[port]);
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -163,12 +162,12 @@ static const input_device_driver_t *linuxraw_get_joypad_driver(void *data)
|
||||
static void linuxraw_input_poll(void *data)
|
||||
{
|
||||
uint8_t c;
|
||||
uint16_t t;
|
||||
linuxraw_input_t *linuxraw = (linuxraw_input_t*)data;
|
||||
|
||||
while (read(STDIN_FILENO, &c, 1) > 0)
|
||||
{
|
||||
bool pressed;
|
||||
uint16_t t;
|
||||
|
||||
if (c == KEY_C && (linuxraw->state[KEY_LEFTCTRL] || linuxraw->state[KEY_RIGHTCTRL]))
|
||||
kill(getpid(), SIGINT);
|
||||
|
Loading…
x
Reference in New Issue
Block a user