Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Improve error messages when layout key matrix row/col is OOB #21640

Merged
merged 1 commit into from
Jul 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
CLI: Improve error messages when layout key matrix row/col is OOB
  • Loading branch information
fauxpark committed Jul 30, 2023
commit c54c6e30a6651be42dc4b148b9c2a4fb28c6c684
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