Add fallback

This commit is contained in:
twinaphex 2016-03-06 01:31:46 +01:00
parent 5e99d163de
commit 15c9e0ae7e
2 changed files with 12 additions and 7 deletions

View File

@ -26,12 +26,14 @@ static uint8_t udev_key_state[UDEV_MAX_KEYS];
#ifdef HAVE_XKBCOMMON
void free_xkb(void);
void handle_xkb(int code, int value);
int handle_xkb(int code, int value);
#endif
void udev_handle_keyboard(void *data,
const struct input_event *event, udev_input_device_t *dev)
{
bool key_handled = false;
switch (event->type)
{
case EV_KEY:
@ -41,12 +43,13 @@ void udev_handle_keyboard(void *data,
BIT_CLEAR(udev_key_state, event->code);
#ifdef HAVE_XKBCOMMON
handle_xkb(event->code, event->value);
#else
if (handle_xkb(event->code, event->value) == 0)
return;
#endif
input_keyboard_event(event->value,
input_keymaps_translate_keysym_to_rk(event->code),
0, 0, RETRO_DEVICE_KEYBOARD);
#endif
break;
default:

View File

@ -124,7 +124,7 @@ error:
/* FIXME: Don't handle composed and dead-keys properly.
* Waiting for support in libxkbcommon ... */
void handle_xkb(int code, int value)
int handle_xkb(int code, int value)
{
unsigned i;
const xkb_keysym_t *syms = NULL;
@ -134,7 +134,7 @@ void handle_xkb(int code, int value)
int xk_code = code + 8;
if (!xkb_state)
return;
return -1;
if (value == 2) /* Repeat, release first explicitly. */
xkb_state_update_key(xkb_state, xk_code, XKB_KEY_UP);
@ -143,7 +143,7 @@ void handle_xkb(int code, int value)
num_syms = xkb_state_key_get_syms(xkb_state, xk_code, &syms);
if (!syms)
return;
return -1;
xkb_state_update_key(xkb_state, xk_code, value ? XKB_KEY_DOWN : XKB_KEY_UP);
@ -165,4 +165,6 @@ void handle_xkb(int code, int value)
for (i = 1; i < num_syms; i++)
input_keyboard_event(value, RETROK_UNKNOWN,
xkb_keysym_to_utf32(syms[i]), mod, RETRO_DEVICE_KEYBOARD);
return 0;
}