diff mbox series

keytable: provide configuration for empty keymap

Message ID 20220926162934.16329-1-sean@mess.org (mailing list archive)
State New, archived
Headers show
Series keytable: provide configuration for empty keymap | expand

Commit Message

Sean Young Sept. 26, 2022, 4:29 p.m. UTC
The lirc documentation contains some drastic measures for disabling
in-kernel decoding. Provide a simpler method of disabling kernel
decoding: simply set /etc/rc_maps.cfg to:

*	* 	empty.toml

Signed-off-by: Sean Young <sean@mess.org>
---
 utils/keytable/keytable.c                     | 23 ++++++++-----------
 .../keytable/rc_keymaps_userspace/empty.toml  |  2 ++
 2 files changed, 12 insertions(+), 13 deletions(-)
 create mode 100644 utils/keytable/rc_keymaps_userspace/empty.toml
diff mbox series

Patch

diff --git a/utils/keytable/keytable.c b/utils/keytable/keytable.c
index 248493a9..6cd1244f 100644
--- a/utils/keytable/keytable.c
+++ b/utils/keytable/keytable.c
@@ -382,14 +382,16 @@  static int add_keymap(struct keymap *map, const char *fname)
 
 		protocol = parse_sysfs_protocol(map->protocol, false);
 		if (protocol == SYSFS_INVALID) {
-			struct bpf_protocol *b;
-
-			b = malloc(sizeof(*b));
-			b->name = strdup(map->protocol);
-			b->param = map->param;
-			/* steal param */
-			map->param = NULL;
-			add_bpf_protocol(b);
+			if (strcmp(map->protocol, "none")) {
+				struct bpf_protocol *b;
+
+				b = malloc(sizeof(*b));
+				b->name = strdup(map->protocol);
+				b->param = map->param;
+				/* steal param */
+				map->param = NULL;
+				add_bpf_protocol(b);
+			}
 		} else {
 			ch_proto |= protocol;
 		}
@@ -2105,11 +2107,6 @@  int main(int argc, char *argv[])
 			}
 			add_keymap(map, fname);
 			free_keymap(map);
-			if (!keytable) {
-				fprintf(stderr, _("Empty keymap %s\n"), fname);
-				free(fname);
-				return -1;
-			}
 			free(fname);
 			clear = 1;
 			matches++;
diff --git a/utils/keytable/rc_keymaps_userspace/empty.toml b/utils/keytable/rc_keymaps_userspace/empty.toml
new file mode 100644
index 00000000..0c0b5e69
--- /dev/null
+++ b/utils/keytable/rc_keymaps_userspace/empty.toml
@@ -0,0 +1,2 @@ 
+[[protocols]]
+protocol = "none"