diff options
author | skullY <skullydazed@gmail.com> | 2020-04-05 19:51:38 -0700 |
---|---|---|
committer | skullydazed <skullydazed@users.noreply.github.com> | 2020-04-07 01:34:21 -0700 |
commit | b4ef72423ea2b2d314e4373f82bdc955b8d6ec10 (patch) | |
tree | 3215b83dfc6c6f9f9db85f730b86a7e61355058b /lib | |
parent | f4b67cde8ae24fdaac70071f793f5c8d0010d959 (diff) | |
download | qmk_firmware-b4ef72423ea2b2d314e4373f82bdc955b8d6ec10.tar.gz |
Correctly handle json keymaps with ANY()
Diffstat (limited to 'lib')
-rw-r--r-- | lib/python/qmk/keymap.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/python/qmk/keymap.py b/lib/python/qmk/keymap.py index b91ba89be..4aa87de20 100644 --- a/lib/python/qmk/keymap.py +++ b/lib/python/qmk/keymap.py @@ -11,7 +11,7 @@ DEFAULT_KEYMAP_C = """#include QMK_KEYBOARD_H /* THIS FILE WAS GENERATED! * - * This file was generated by qmk-compile-json. You may or may not want to + * This file was generated by qmk json2c. You may or may not want to * edit it directly. */ @@ -39,6 +39,15 @@ def template(keyboard): return DEFAULT_KEYMAP_C +def _strip_any(keycode): + """Remove ANY() from a keycode. + """ + if keycode.startswith('ANY(') and keycode.endswith(')'): + keycode = keycode[4:-1] + + return keycode + + def generate(keyboard, layout, layers): """Returns a keymap.c for the specified keyboard, layout, and layers. @@ -53,9 +62,12 @@ def generate(keyboard, layout, layers): An array of arrays describing the keymap. Each item in the inner array should be a string that is a valid QMK keycode. """ layer_txt = [] + for layer_num, layer in enumerate(layers): if layer_num != 0: layer_txt[-1] = layer_txt[-1] + ',' + + layer = map(_strip_any, layer) layer_keys = ', '.join(layer) layer_txt.append('\t[%s] = %s(%s)' % (layer_num, layout, layer_keys)) |