Check for multiple matrix positions assigned to same key (#20039)

master
Ryan 2023-03-24 13:46:42 +11:00 committed by GitHub
parent 67dae1222f
commit d6ce42ae5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -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) 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: 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) 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: else:
key['matrix'] = matrix_locations[key['label']] key['matrix'] = matrix_locations[key['label']][0]
parsed_layouts[macro_name] = { parsed_layouts[macro_name] = {
'layout': parsed_layout, 'layout': parsed_layout,
@ -186,7 +188,9 @@ def _parse_matrix_locations(matrix, file, macro_name):
row = row.replace('{', '').replace('}', '') row = row.replace('{', '').replace('}', '')
for col_num, identifier in enumerate(row.split(',')): for col_num, identifier in enumerate(row.split(',')):
if identifier != 'KC_NO': 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 return matrix_locations