mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
(x11_input.c) get rid of this inline function
This commit is contained in:
parent
c7b45aaf80
commit
deb804ab2f
@ -49,7 +49,6 @@ typedef struct x11_input
|
|||||||
bool grab_mouse;
|
bool grab_mouse;
|
||||||
} x11_input_t;
|
} x11_input_t;
|
||||||
|
|
||||||
|
|
||||||
static void *x_input_init(const char *joypad_driver)
|
static void *x_input_init(const char *joypad_driver)
|
||||||
{
|
{
|
||||||
x11_input_t *x11;
|
x11_input_t *x11;
|
||||||
@ -74,31 +73,35 @@ static void *x_input_init(const char *joypad_driver)
|
|||||||
return x11;
|
return x11;
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE bool x_key_pressed(x11_input_t *x11, int key)
|
|
||||||
{
|
|
||||||
unsigned sym = rarch_keysym_lut[(enum retro_key)key];
|
|
||||||
int keycode = XKeysymToKeycode(x11->display, sym);
|
|
||||||
|
|
||||||
return x11->state[keycode >> 3] & (1 << (keycode & 7));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int16_t x_pressed_analog(x11_input_t *x11,
|
static int16_t x_pressed_analog(x11_input_t *x11,
|
||||||
const struct retro_keybind *binds, unsigned idx, unsigned id)
|
const struct retro_keybind *binds, unsigned idx, unsigned id)
|
||||||
{
|
{
|
||||||
int16_t pressed_minus = 0, pressed_plus = 0;
|
int16_t pressed_minus = 0;
|
||||||
|
int16_t pressed_plus = 0;
|
||||||
unsigned id_minus = 0;
|
unsigned id_minus = 0;
|
||||||
unsigned id_plus = 0;
|
unsigned id_plus = 0;
|
||||||
int id_minus_key = 0;
|
int id_minus_key = 0;
|
||||||
int id_plus_key = 0;
|
int id_plus_key = 0;
|
||||||
|
unsigned sym = 0;
|
||||||
|
int keycode = 0;
|
||||||
|
|
||||||
input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus);
|
input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus);
|
||||||
|
|
||||||
id_minus_key = binds[id_minus].key;
|
id_minus_key = binds[id_minus].key;
|
||||||
id_plus_key = binds[id_plus].key;
|
id_plus_key = binds[id_plus].key;
|
||||||
|
|
||||||
if (binds && binds[id_minus].valid && (id_minus_key < RETROK_LAST) && x_key_pressed(x11, id_minus_key))
|
sym = rarch_keysym_lut[(enum retro_key)id_minus_key];
|
||||||
|
keycode = XKeysymToKeycode(x11->display, sym);
|
||||||
|
if (binds && binds[id_minus].valid
|
||||||
|
&& (id_minus_key < RETROK_LAST)
|
||||||
|
&& (x11->state[keycode >> 3] & (1 << (keycode & 7))))
|
||||||
pressed_minus = -0x7fff;
|
pressed_minus = -0x7fff;
|
||||||
if (binds && binds[id_plus].valid && (id_plus_key < RETROK_LAST) && x_key_pressed(x11, id_plus_key))
|
|
||||||
|
sym = rarch_keysym_lut[(enum retro_key)id_plus_key];
|
||||||
|
keycode = XKeysymToKeycode(x11->display, sym);
|
||||||
|
if (binds && binds[id_plus].valid
|
||||||
|
&& (id_plus_key < RETROK_LAST)
|
||||||
|
&& (x11->state[keycode >> 3] & (1 << (keycode & 7))))
|
||||||
pressed_plus = 0x7fff;
|
pressed_plus = 0x7fff;
|
||||||
|
|
||||||
return pressed_plus + pressed_minus;
|
return pressed_plus + pressed_minus;
|
||||||
@ -220,23 +223,34 @@ static int16_t x_input_state(void *data,
|
|||||||
unsigned device, unsigned idx, unsigned id)
|
unsigned device, unsigned idx, unsigned id)
|
||||||
{
|
{
|
||||||
int16_t ret = 0;
|
int16_t ret = 0;
|
||||||
int key = 0;
|
|
||||||
x11_input_t *x11 = (x11_input_t*)data;
|
x11_input_t *x11 = (x11_input_t*)data;
|
||||||
|
|
||||||
switch (device)
|
switch (device)
|
||||||
{
|
{
|
||||||
case RETRO_DEVICE_JOYPAD:
|
case RETRO_DEVICE_JOYPAD:
|
||||||
key = binds[port][id].key;
|
{
|
||||||
return ((key < RETROK_LAST) && x_key_pressed(x11, key)) ||
|
int key = binds[port][id].key;
|
||||||
input_joypad_pressed(x11->joypad, joypad_info, port, binds[port], id);
|
int keycode = XKeysymToKeycode(x11->display,
|
||||||
break;
|
rarch_keysym_lut[(enum retro_key)key]);
|
||||||
|
ret = x11->state[keycode >> 3] & (1 << (keycode & 7));
|
||||||
|
}
|
||||||
|
if (!ret)
|
||||||
|
return input_joypad_pressed(x11->joypad,
|
||||||
|
joypad_info, port, binds[port], id);
|
||||||
|
return ret;
|
||||||
case RETRO_DEVICE_KEYBOARD:
|
case RETRO_DEVICE_KEYBOARD:
|
||||||
return (id < RETROK_LAST) && x_key_pressed(x11, id);
|
if (id < RETROK_LAST)
|
||||||
|
{
|
||||||
|
int keycode = XKeysymToKeycode(x11->display,
|
||||||
|
rarch_keysym_lut[(enum retro_key)id]);
|
||||||
|
return x11->state[keycode >> 3] & (1 << (keycode & 7));
|
||||||
|
}
|
||||||
|
break;
|
||||||
case RETRO_DEVICE_ANALOG:
|
case RETRO_DEVICE_ANALOG:
|
||||||
if (binds[port])
|
if (binds[port])
|
||||||
ret = x_pressed_analog(x11, binds[port], idx, id);
|
ret = x_pressed_analog(x11, binds[port], idx, id);
|
||||||
if (!ret && binds[port])
|
if (!ret && binds[port])
|
||||||
ret = input_joypad_analog(x11->joypad, joypad_info,
|
return input_joypad_analog(x11->joypad, joypad_info,
|
||||||
port, idx,
|
port, idx,
|
||||||
id, binds[port]);
|
id, binds[port]);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user