Skip to contentSkip to conversation

keytable: provide configuration for empty keymap

PATCH New Sean Young 1 participant 1 message Sep 26, 2022 Media (V4L/DVB)

lore
Share & tools
lore

Sean Young

author
#0 lore raw

PATCH 1/1 keytable: provide configuration for empty keymap

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

---
 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
utils/keytable/keytable.c +10 -13
index 248493a9..6cd1244f 100644
@@ -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++;
utils/keytable/rc_keymaps_userspace/empty.toml new file +2 -0
new file mode 100644
index 00000000..0c0b5e69
@@ -0,0 +1,2 @@
+[[protocols]]
+protocol = "none"
Signature · 1 line
2.37.3