From 1d5dbefef0551cd8eb2b5470e47c89e40fe3c8e9 Mon Sep 17 00:00:00 2001 From: fauxpark Date: Sun, 15 Dec 2024 23:14:04 +1100 Subject: [PATCH] default_keyboard.h generation tweaks --- lib/python/qmk/cli/generate/keyboard_h.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/python/qmk/cli/generate/keyboard_h.py b/lib/python/qmk/cli/generate/keyboard_h.py index 5863a0983ad3..cb9528d96bbc 100755 --- a/lib/python/qmk/cli/generate/keyboard_h.py +++ b/lib/python/qmk/cli/generate/keyboard_h.py @@ -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 @@ -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'] @@ -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('}') @@ -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')): @@ -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)