Skip to content

Commit

Permalink
Check for multiple matrix positions assigned to same key (qmk#20039)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored and rodrigob committed Apr 9, 2023
1 parent d8b4ee0 commit 15605de
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/python/qmk/c_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ def find_layouts(file):
cli.log.error('Invalid LAYOUT macro in %s: Empty parameter name in macro %s at pos %s.', file, macro_name, i)
elif key['label'] not in matrix_locations:
cli.log.error('Invalid LAYOUT macro in %s: Key %s in macro %s has no matrix position!', file, key['label'], macro_name)
elif len(matrix_locations.get(key['label'])) > 1:
cli.log.error('Invalid LAYOUT macro in %s: Key %s in macro %s has multiple matrix positions (%s)', file, key['label'], macro_name, ', '.join(str(x) for x in matrix_locations[key['label']]))
else:
key['matrix'] = matrix_locations[key['label']]
key['matrix'] = matrix_locations[key['label']][0]

parsed_layouts[macro_name] = {
'layout': parsed_layout,
Expand Down Expand Up @@ -186,7 +188,9 @@ def _parse_matrix_locations(matrix, file, macro_name):
row = row.replace('{', '').replace('}', '')
for col_num, identifier in enumerate(row.split(',')):
if identifier != 'KC_NO':
matrix_locations[identifier] = [row_num, col_num]
if identifier not in matrix_locations:
matrix_locations[identifier] = []
matrix_locations[identifier].append([row_num, col_num])

return matrix_locations

Expand Down

0 comments on commit 15605de

Please sign in to comment.