Skip to contentSkip to conversation

lircd2toml: warn when scancode has duplicate definitions

PATCH New Sean Young 1 participant 1 message Dec 31, 2019 Media (V4L/DVB)

lore
Share & tools
lore

Sean Young

author
#0 lore raw

PATCH 1/1 lircd2toml: warn when scancode has duplicate definitions

In lircd.conf files, it is possible that the same scancode has multiple key definitions. In our rc keymap toml format, one scancode can only have one key definition.

Possibly we should allow alternate names for scancode for transmitting; however, as a first step, we should warn if there are multiple definitions for the same scancode.

---
 contrib/lircd2toml.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
contrib/lircd2toml.py +5 -1
index 54ea12fc..ba4b14ec 100755
@@ -131,7 +131,11 @@ class LircdParser:
             for s in a:
                 if s[0] == '#':
                     break
-                codes[int(s, 0)] = k
+                scancode = int(s, 0)
+                if scancode in codes:
+                    self.warning("scancode 0x{:x} has duplicate definition {} and {}".format(scancode, codes[scancode], k))
+
+                codes[scancode] = k
 
     def read_raw_codes(self):
         raw_codes = []
Signature · 1 line
2.24.1