From af1ac6b1bd873986fe808dfd68420bc5f48dd43d Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Wed, 13 Mar 2024 23:04:49 +0000 Subject: [PATCH] Reject duplicate matrix locations in LAYOUT macros (#23273) --- lib/python/qmk/info.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 00da4936e16..99ac254e27c 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']])