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

default_keyboard.h generation tweaks #24715

Merged
merged 1 commit into from
Dec 15, 2024
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
19 changes: 12 additions & 7 deletions lib/python/qmk/cli/generate/keyboard_h.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ def _generate_layouts(keyboard, kb_info_json):
row_num = kb_info_json['matrix_size']['rows']

lines = []
lines.append('')
lines.append('// Layout content')
lines.append('')
lines.append('#define XXX KC_NO')

for layout_name, layout_data in kb_info_json['layouts'].items():
if layout_data['c_macro']:
continue
Expand All @@ -31,7 +36,7 @@ def _generate_layouts(keyboard, kb_info_json):
continue

layout_keys = []
layout_matrix = [['KC_NO'] * col_num for _ in range(row_num)]
layout_matrix = [['XXX'] * col_num for _ in range(row_num)]

for key_data in layout_data['layout']:
row, col = key_data['matrix']
Expand All @@ -46,7 +51,7 @@ def _generate_layouts(keyboard, kb_info_json):
lines.append('')
lines.append(f'#define {layout_name}({", ".join(layout_keys)}) {{ \\')

rows = ', \\\n'.join(['\t {' + ', '.join(row) + '}' for row in layout_matrix])
rows = ', \\\n'.join([' { ' + ', '.join(row) + ' }' for row in layout_matrix])
rows += ' \\'
lines.append(rows)
lines.append('}')
Expand All @@ -67,6 +72,9 @@ def _generate_keycodes(kb_info_json):
return []

lines = []
lines.append('')
lines.append('// Keycode content')
lines.append('')
lines.append('enum keyboard_keycodes {')

for index, item in enumerate(kb_info_json.get('keycodes')):
Expand Down Expand Up @@ -103,17 +111,14 @@ def generate_keyboard_h(cli):
valid_config = dd_layouts or keyboard_h

# Build the layouts.h file.
keyboard_h_lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, '#pragma once', '#include "quantum.h"']
keyboard_h_lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, '#pragma once', '', '#include "quantum.h"']

keyboard_h_lines.append('')
keyboard_h_lines.append('// Layout content')
if dd_layouts:
keyboard_h_lines.extend(dd_layouts)

if keyboard_h:
keyboard_h_lines.append(f'#include "{Path(keyboard_h).name}"')

keyboard_h_lines.append('')
keyboard_h_lines.append('// Keycode content')
if dd_keycodes:
keyboard_h_lines.extend(dd_keycodes)

Expand Down
Loading