add support for remote control devices and other ID_INPUT_KEY devices

* the remote control presents itself as ID_INPUT_KEY, not
ID_INPUT_KEYBOARD.  However, ID_INPUT_KEYBOARD is a subset of
ID_INPUT_KEY.

* the remote control lacks the backspace and enter keys, which are hard
coded in RetroArch. It has "back" and "ok" instead, so map those to
RETROK_BACKSPACE and RETROK_ENTER as well.

Remote controls also have no ESC key, but that one is customizable
and I used the Power key of the remote (which already has a mapping
to RETROK_POWER).

The functionality provided is really the bare minimum, but it is enough
to teach a kid "press the power button here to watch TV"; compared to
pressing L1+R1+START+SELECT and navigating to the RetroArch's "quit"
menu item, that hopefully has more chances of success.
This commit is contained in:
Paolo Bonzini 2017-06-19 12:34:01 +02:00
parent f850e64037
commit d5cdbca322
2 changed files with 8 additions and 3 deletions

View File

@ -392,7 +392,7 @@ static void udev_input_handle_hotplug(udev_input_t *udev)
{
device_handle_cb cb;
enum udev_input_dev_type dev_type = UDEV_INPUT_KEYBOARD;
const char *val_keyboard = NULL;
const char *val_key = NULL;
const char *val_mouse = NULL;
const char *val_touchpad = NULL;
const char *action = NULL;
@ -403,14 +403,15 @@ static void udev_input_handle_hotplug(udev_input_t *udev)
if (!dev)
return;
val_keyboard = udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD");
val_key = udev_device_get_property_value(dev, "ID_INPUT_KEY");
val_mouse = udev_device_get_property_value(dev, "ID_INPUT_MOUSE");
val_touchpad = udev_device_get_property_value(dev, "ID_INPUT_TOUCHPAD");
action = udev_device_get_action(dev);
devnode = udev_device_get_devnode(dev);
if (val_keyboard && string_is_equal_fast(val_keyboard, "1", 1) && devnode)
if (val_key && string_is_equal_fast(val_key, "1", 1) && devnode)
{
/* EV_KEY device, can be a keyboard or a remote control device. */
dev_type = UDEV_INPUT_KEYBOARD;
cb = udev_handle_keyboard;
}

View File

@ -1092,6 +1092,10 @@ const struct rarch_key_map rarch_key_map_linux[] = {
{ KEY_VOLUMEDOWN, RETROK_VOLUMEDOWN },
{ KEY_VOLUMEUP, RETROK_VOLUMEUP },
/* Extra keys for remote controls. */
{ KEY_OK, RETROK_RETURN },
{ KEY_BACK, RETROK_BACKSPACE },
{ 0, RETROK_UNKNOWN },
};
#endif