Merge pull request #1434 from HiassofT/le8-ir-keytable

backport of #1433 properly fix streamzap issues, allow user rc_maps.cfg override
This commit is contained in:
Christian Hewitt 2017-03-17 09:18:36 +04:00 committed by GitHub
commit 7e1bf53b40
4 changed files with 134 additions and 10 deletions

View File

@ -0,0 +1,20 @@
# Keymaps table
#
# This table creates an association between a keycode file and a kernel
# driver. It can be used to automatically override a keycode definition.
#
#
# Format:
# driver - name of the driver provided via uevent - use * for any driver
# table - RC keymap table, provided via uevent - use * for any table
# file - file name. If directory is not specified, it is first looked up
# in /storage/.config/rc_keymaps, then /usr/lib/udev/rc_keymaps
#
# For example:
#
# driver table file
#
# gpio-rc-recv rc-streamzap streamzap
# gpio-rc-recv * justboom
# * rc-rc6-mce rc6_mce_new
# * * hauppauge_new

View File

@ -0,0 +1,35 @@
From 996fdbf54f4b6c479dc7dd6ab4ca7933730aba93 Mon Sep 17 00:00:00 2001
From: Matthias Reichl <hias@horus.com>
Date: Sun, 12 Mar 2017 12:22:14 +0100
Subject: [PATCH] ir-keytable: allow map rules override via
/storage/.config/rc_maps.cfg
Signed-off-by: Matthias Reichl <hias@horus.com>
---
utils/keytable/70-infrared.rules | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/utils/keytable/70-infrared.rules b/utils/keytable/70-infrared.rules
index afffd95..eef3234 100644
--- a/utils/keytable/70-infrared.rules
+++ b/utils/keytable/70-infrared.rules
@@ -1,4 +1,14 @@
# Automatically load the proper keymaps after the Remote Controller device
-# creation. The keycode tables rules should be at /etc/rc_maps.cfg
+# creation.
+#
+# User-defined rules can be stored in /storage/.config/rc_maps.cfg. If that
+# file doesn't exist the default rules from /etc/rc_maps.cfg are used.
-ACTION=="add", SUBSYSTEM=="rc", RUN+="/usr/bin/ir-keytable -a /etc/rc_maps.cfg -s $name"
+ACTION=="add", SUBSYSTEM=="rc", IMPORT{program}="/usr/bin/sh -c '\
+ if [ -r /storage/.config/rc_maps.cfg ] ; then \
+ echo rc_maps_cfg=/storage/.config/rc_maps.cfg ; \
+ else \
+ echo rc_maps_cfg=/etc/rc_maps.cfg ; \
+ fi'"
+
+ENV{rc_maps_cfg}=="?*", RUN+="/usr/bin/ir-keytable -a $env{rc_maps_cfg} -s $name"
--
2.1.4

View File

@ -0,0 +1,79 @@
From 52a487063684299c20a27ba8b1028aeaaa08ddc6 Mon Sep 17 00:00:00 2001
From: Matthias Reichl <hias@horus.com>
Date: Sun, 12 Mar 2017 12:53:50 +0100
Subject: [PATCH] ir-keytable: be more permissive on protocol name
Allowed the protocol to be specified with or without underscores or
dashes. This also solves the problem of not being able to load
the streamzap keymap.
./ir-keytable -w rc_keymaps/streamzap
Protocol RC5_SZ invalid
Reported-by: Matthias Reichl <hias@horus.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Matthias Reichl <hias@horus.com>
---
utils/keytable/keytable.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/utils/keytable/keytable.c b/utils/keytable/keytable.c
index a6ecc9e..f61a1d5 100644
--- a/utils/keytable/keytable.c
+++ b/utils/keytable/keytable.c
@@ -120,9 +120,7 @@ const struct protocol_map_entry protocol_map[] = {
{ "other", NULL, SYSFS_OTHER },
{ "lirc", NULL, SYSFS_LIRC },
{ "rc-5", "/rc5_decoder", SYSFS_RC5 },
- { "rc5", NULL, SYSFS_RC5 },
{ "rc-5x", NULL, SYSFS_INVALID },
- { "rc5x", NULL, SYSFS_INVALID },
{ "rc-5-sz", NULL, SYSFS_RC5_SZ },
{ "jvc", "/jvc_decoder", SYSFS_JVC },
{ "sony", "/sony_decoder",SYSFS_SONY },
@@ -134,7 +132,6 @@ const struct protocol_map_entry protocol_map[] = {
{ "mce_kbd", NULL, SYSFS_MCE_KBD },
{ "mce-kbd", NULL, SYSFS_MCE_KBD },
{ "rc-6", "/rc6_decoder", SYSFS_RC6 },
- { "rc6", NULL, SYSFS_RC6 },
{ "rc-6-0", NULL, SYSFS_INVALID },
{ "rc-6-6a-20", NULL, SYSFS_INVALID },
{ "rc-6-6a-24", NULL, SYSFS_INVALID },
@@ -145,6 +142,25 @@ const struct protocol_map_entry protocol_map[] = {
{ NULL, NULL, SYSFS_INVALID },
};
+static bool str_like(const char *a, const char *b)
+{
+ while (*a && *b) {
+ if (*a == '-' || *a == '_') {
+ a++;
+ continue;
+ }
+ if (*b == '-' || *b == '_') {
+ b++;
+ continue;
+ }
+ if (tolower(*a) != tolower(*b))
+ return false;
+ a++; b++;
+ }
+
+ return !*a && !*b;
+}
+
static enum sysfs_protocols parse_sysfs_protocol(const char *name, bool all_allowed)
{
const struct protocol_map_entry *pme;
@@ -156,7 +172,7 @@ static enum sysfs_protocols parse_sysfs_protocol(const char *name, bool all_allo
return ~0;
for (pme = protocol_map; pme->name; pme++) {
- if (!strcasecmp(name, pme->name))
+ if (str_like(name, pme->name))
return pme->sysfs_protocol;
}
--
2.1.4

View File

@ -1,10 +0,0 @@
diff --git a/utils/keytable/rc_keymaps/streamzap b/utils/keytable/rc_keymaps/streamzap
index 3512cd8..1619459 100644
--- a/utils/keytable/rc_keymaps/streamzap
+++ b/utils/keytable/rc_keymaps/streamzap
@@ -1,4 +1,4 @@
-# table streamzap, type: RC5_SZ
+# table streamzap, type: rc-5-sz
0x28c0 KEY_NUMERIC_0
0x28c1 KEY_NUMERIC_1
0x28c2 KEY_NUMERIC_2