aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorskullY <skullydazed@gmail.com>2020-04-05 19:51:38 -0700
committerskullydazed <skullydazed@users.noreply.github.com>2020-04-07 01:34:21 -0700
commitb4ef72423ea2b2d314e4373f82bdc955b8d6ec10 (patch)
tree3215b83dfc6c6f9f9db85f730b86a7e61355058b /lib
parentf4b67cde8ae24fdaac70071f793f5c8d0010d959 (diff)
downloadqmk_firmware-b4ef72423ea2b2d314e4373f82bdc955b8d6ec10.tar.gz
qmk_firmware-b4ef72423ea2b2d314e4373f82bdc955b8d6ec10.zip
Correctly handle json keymaps with ANY()
Diffstat (limited to 'lib')
-rw-r--r--lib/python/qmk/keymap.py14
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
11 11
12/* THIS FILE WAS GENERATED! 12/* THIS FILE WAS GENERATED!
13 * 13 *
14 * This file was generated by qmk-compile-json. You may or may not want to 14 * This file was generated by qmk json2c. You may or may not want to
15 * edit it directly. 15 * edit it directly.
16 */ 16 */
17 17
@@ -39,6 +39,15 @@ def template(keyboard):
39 return DEFAULT_KEYMAP_C 39 return DEFAULT_KEYMAP_C
40 40
41 41
42def _strip_any(keycode):
43 """Remove ANY() from a keycode.
44 """
45 if keycode.startswith('ANY(') and keycode.endswith(')'):
46 keycode = keycode[4:-1]
47
48 return keycode
49
50
42def generate(keyboard, layout, layers): 51def generate(keyboard, layout, layers):
43 """Returns a keymap.c for the specified keyboard, layout, and layers. 52 """Returns a keymap.c for the specified keyboard, layout, and layers.
44 53
@@ -53,9 +62,12 @@ def generate(keyboard, layout, layers):
53 An array of arrays describing the keymap. Each item in the inner array should be a string that is a valid QMK keycode. 62 An array of arrays describing the keymap. Each item in the inner array should be a string that is a valid QMK keycode.
54 """ 63 """
55 layer_txt = [] 64 layer_txt = []
65
56 for layer_num, layer in enumerate(layers): 66 for layer_num, layer in enumerate(layers):
57 if layer_num != 0: 67 if layer_num != 0:
58 layer_txt[-1] = layer_txt[-1] + ',' 68 layer_txt[-1] = layer_txt[-1] + ','
69
70 layer = map(_strip_any, layer)
59 layer_keys = ', '.join(layer) 71 layer_keys = ', '.join(layer)
60 layer_txt.append('\t[%s] = %s(%s)' % (layer_num, layout, layer_keys)) 72 layer_txt.append('\t[%s] = %s(%s)' % (layer_num, layout, layer_keys))
61 73