Skip to content

Commit

Permalink
CLI: Improve error messages when layout key matrix row/col is OOB (qm…
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored and jesperhellberg committed Sep 9, 2023
1 parent 4e4e5ee commit 7b1f5df
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/python/qmk/cli/generate/keyboard_h.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@ def _generate_layouts(keyboard, kb_info_json):
row, col = key_data['matrix']
identifier = f'k{ROW_LETTERS[row]}{COL_LETTERS[col]}'

try:
layout_matrix[row][col] = identifier
layout_keys.append(identifier)
except IndexError:
if row >= row_num or col >= col_num:
key_name = key_data.get('label', identifier)
cli.log.error(f'{keyboard}/{layout_name}: Matrix data out of bounds at index {index} ({key_name}): [{row}, {col}]')
if row >= row_num:
cli.log.error(f'{keyboard}/{layout_name}: Matrix row for key {index} ({key_name}) is {row} but must be less than {row_num}')

if col >= col_num:
cli.log.error(f'{keyboard}/{layout_name}: Matrix column for key {index} ({key_name}) is {col} but must be less than {col_num}')

return []

layout_matrix[row][col] = identifier
layout_keys.append(identifier)

lines.append('')
lines.append(f'#define {layout_name}({", ".join(layout_keys)}) {{ \\')

Expand Down

0 comments on commit 7b1f5df

Please sign in to comment.