summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/python/qmk/cli/generate/config_h.py7
-rw-r--r--lib/python/qmk/info.py56
2 files changed, 51 insertions, 12 deletions
diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py
index 20c9595ed7..893892c479 100755
--- a/lib/python/qmk/cli/generate/config_h.py
+++ b/lib/python/qmk/cli/generate/config_h.py
@@ -94,7 +94,12 @@ def generate_config_items(kb_info_json, config_h_lines):
except KeyError:
continue
- if key_type.startswith('array'):
+ if key_type.startswith('array.array'):
+ config_h_lines.append('')
+ config_h_lines.append(f'#ifndef {config_key}')
+ config_h_lines.append(f'# define {config_key} {{ {", ".join(["{" + ",".join(list(map(str, x))) + "}" for x in config_value])} }}')
+ config_h_lines.append(f'#endif // {config_key}')
+ elif key_type.startswith('array'):
config_h_lines.append('')
config_h_lines.append(f'#ifndef {config_key}')
config_h_lines.append(f'# define {config_key} {{ {", ".join(map(str, config_value))} }}')
diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py
index c5a7d33848..49d1054519 100644
--- a/lib/python/qmk/info.py
+++ b/lib/python/qmk/info.py
@@ -168,28 +168,46 @@ def _extract_pins(pins):
return [_pin_name(pin) for pin in pins.split(',')]
-def _extract_direct_matrix(direct_pins):
- """
+def _extract_2d_array(raw):
+ """Return a 2d array of strings
"""
- direct_pin_array = []
+ out_array = []
- while direct_pins[-1] != '}':
- direct_pins = direct_pins[:-1]
+ while raw[-1] != '}':
+ raw = raw[:-1]
- for row in direct_pins.split('},{'):
+ for row in raw.split('},{'):
if row.startswith('{'):
row = row[1:]
if row.endswith('}'):
row = row[:-1]
- direct_pin_array.append([])
+ out_array.append([])
+
+ for val in row.split(','):
+ out_array[-1].append(val)
+
+ return out_array
+
+
+def _extract_2d_int_array(raw):
+ """Return a 2d array of ints
+ """
+ ret = _extract_2d_array(raw)
+
+ return [list(map(int, x)) for x in ret]
- for pin in row.split(','):
- if pin == 'NO_PIN':
- pin = None
- direct_pin_array[-1].append(pin)
+def _extract_direct_matrix(direct_pins):
+ """extract direct_matrix
+ """
+ direct_pin_array = _extract_2d_array(direct_pins)
+
+ for i in range(len(direct_pin_array)):
+ for j in range(len(direct_pin_array[i])):
+ if direct_pin_array[i][j] == 'NO_PIN':
+ direct_pin_array[i][j] = None
return direct_pin_array
@@ -207,6 +225,21 @@ def _extract_audio(info_data, config_c):
info_data['audio'] = {'pins': audio_pins}
+def _extract_secure_unlock(info_data, config_c):
+ """Populate data about the secure unlock sequence
+ """
+ unlock = config_c.get('SECURE_UNLOCK_SEQUENCE', '').replace(' ', '')[1:-1]
+ if unlock:
+ unlock_array = _extract_2d_int_array(unlock)
+ if 'secure' not in info_data:
+ info_data['secure'] = {}
+
+ if 'unlock_sequence' in info_data['secure']:
+ _log_warning(info_data, 'Secure unlock sequence is specified in both config.h (SECURE_UNLOCK_SEQUENCE) and info.json (secure.unlock_sequence) (Value: %s), the config.h value wins.' % info_data['secure']['unlock_sequence'])
+
+ info_data['secure']['unlock_sequence'] = unlock_array
+
+
def _extract_split_main(info_data, config_c):
"""Populate data about the split configuration
"""
@@ -466,6 +499,7 @@ def _extract_config_h(info_data, config_c):
# Pull data that easily can't be mapped in json
_extract_matrix_info(info_data, config_c)
_extract_audio(info_data, config_c)
+ _extract_secure_unlock(info_data, config_c)
_extract_split_main(info_data, config_c)
_extract_split_transport(info_data, config_c)
_extract_split_right_pins(info_data, config_c)