aboutsummaryrefslogtreecommitdiff
path: root/lib/python/qmk/info.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/qmk/info.py')
-rw-r--r--lib/python/qmk/info.py30
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py
index 815b851474..71bb6e9454 100644
--- a/lib/python/qmk/info.py
+++ b/lib/python/qmk/info.py
@@ -107,6 +107,15 @@ def _validate_layouts(keyboard, info_data): # noqa C901
if col >= col_num:
_log_error(info_data, f'{layout_name}: Matrix column for key {index} ({key_name}) is {col} but must be less than {col_num}')
+ # Reject duplicate matrix locations
+ for layout_name, layout_data in layouts.items():
+ seen = set()
+ for index, key_data in enumerate(layout_data['layout']):
+ key = f"{key_data['matrix']}"
+ if key in seen:
+ _log_error(info_data, f'{layout_name}: Matrix location for key {index} is not unique {key_data}')
+ seen.add(key)
+
# Warn if physical positions are offset (at least one key should be at x=0, and at least one key at y=0)
for layout_name, layout_data in layouts.items():
offset_x = min([_get_key_left_position(k) for k in layout_data['layout']])
@@ -375,6 +384,12 @@ def _extract_encoders(info_data, config_c):
info_data['encoder']['rotary'] = encoders
+ # TODO: some logic still assumes ENCODER_ENABLED would partially create encoder dict
+ if info_data.get('features', {}).get('encoder', False):
+ if 'encoder' not in info_data:
+ info_data['encoder'] = {}
+ info_data['encoder']['enabled'] = True
+
def _extract_split_encoders(info_data, config_c):
"""Populate data about split encoder pins
@@ -868,7 +883,17 @@ def unknown_processor_rules(info_data, rules):
def merge_info_jsons(keyboard, info_data):
"""Return a merged copy of all the info.json files for a keyboard.
"""
- for info_file in find_info_json(keyboard):
+ config_files = find_info_json(keyboard)
+
+ # keyboard.json can only exist at the deepest part of the tree
+ keyboard_json_count = 0
+ for index, info_file in enumerate(config_files):
+ if Path(info_file).name == 'keyboard.json':
+ keyboard_json_count += 1
+ if index != 0 or keyboard_json_count > 1:
+ _log_error(info_data, f'Invalid keyboard.json location detected: {info_file}.')
+
+ for info_file in config_files:
# Load and validate the JSON data
new_info_data = json_load(info_file)
@@ -926,7 +951,7 @@ def find_info_json(keyboard):
base_path = Path('keyboards')
keyboard_path = base_path / keyboard
keyboard_parent = keyboard_path.parent
- info_jsons = [keyboard_path / 'info.json']
+ info_jsons = [keyboard_path / 'info.json', keyboard_path / 'keyboard.json']
# Add DEFAULT_FOLDER before parents, if present
rules = rules_mk(keyboard)
@@ -938,6 +963,7 @@ def find_info_json(keyboard):
if keyboard_parent == base_path:
break
info_jsons.append(keyboard_parent / 'info.json')
+ info_jsons.append(keyboard_parent / 'keyboard.json')
keyboard_parent = keyboard_parent.parent
# Return a list of the info.json files that actually exist