From f850e64037cc6ba703a8a58b59e86378743b164e Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 19 Jun 2017 13:22:34 +0200 Subject: [PATCH 1/2] add volume down and volume up keys --- input/input_keymaps.c | 5 +++++ libretro-common/include/libretro.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/input/input_keymaps.c b/input/input_keymaps.c index ddd900a45fae..313a98a9a855 100644 --- a/input/input_keymaps.c +++ b/input/input_keymaps.c @@ -189,6 +189,8 @@ const struct input_key_map input_config_key_map[] = { { "subtract", RETROK_KP_MINUS }, { "kp_plus", RETROK_KP_PLUS }, { "kp_minus", RETROK_KP_MINUS }, + { "volume-", RETROK_VOLUMEDOWN }, + { "volume+", RETROK_VOLUMEUP }, { "f1", RETROK_F1 }, { "f2", RETROK_F2 }, { "f3", RETROK_F3 }, @@ -1087,6 +1089,9 @@ const struct rarch_key_map rarch_key_map_linux[] = { { KEY_EURO, RETROK_EURO }, #endif { KEY_UNDO, RETROK_UNDO }, + { KEY_VOLUMEDOWN, RETROK_VOLUMEDOWN }, + { KEY_VOLUMEUP, RETROK_VOLUMEUP }, + { 0, RETROK_UNKNOWN }, }; #endif diff --git a/libretro-common/include/libretro.h b/libretro-common/include/libretro.h index b100865c5a2e..d486ef226560 100644 --- a/libretro-common/include/libretro.h +++ b/libretro-common/include/libretro.h @@ -422,6 +422,9 @@ enum retro_key RETROK_EURO = 321, RETROK_UNDO = 322, + RETROK_VOLUMEDOWN = 323, + RETROK_VOLUMEUP = 324, + RETROK_LAST, RETROK_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */ From d5cdbca3228599952fe5e44b6d84a6863e88f946 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 19 Jun 2017 12:34:01 +0200 Subject: [PATCH 2/2] 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. --- input/drivers/udev_input.c | 7 ++++--- input/input_keymaps.c | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index 01b62e0c78df..c49dd6d0d542 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -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; } diff --git a/input/input_keymaps.c b/input/input_keymaps.c index 313a98a9a855..75552cd51771 100644 --- a/input/input_keymaps.c +++ b/input/input_keymaps.c @@ -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