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

qmk info: add warning when layout is offset #20070

Merged
merged 1 commit into from
Mar 9, 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
10 changes: 10 additions & 0 deletions lib/python/qmk/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ def _validate(keyboard, info_data):
if len(layouts) == 0 or all(not layout.get('json_layout', False) for layout in layouts.values()):
_log_error(info_data, 'No LAYOUTs defined! Need at least one layout defined in info.json.')

# 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([k['x'] for k in layout_data['layout']])
if offset_x > 0:
_log_warning(info_data, f'Layout "{layout_name}" is offset on X axis by {offset_x}')

offset_y = min([k['y'] for k in layout_data['layout']])
if offset_y > 0:
_log_warning(info_data, f'Layout "{layout_name}" is offset on Y axis by {offset_y}')

# Providing only LAYOUT_all "because I define my layouts in a 3rd party tool"
if len(layouts) == 1 and 'LAYOUT_all' in layouts:
_log_warning(info_data, '"LAYOUT_all" should be "LAYOUT" unless additional layouts are provided.')
Expand Down