aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRyan <[email protected]>2024-12-16 06:06:05 +1100
committerGitHub <[email protected]>2024-12-15 19:06:05 +0000
commit0f3993b9a3cd3a50b2c9e5d920d6bdb40a9d78be (patch)
tree6e76fd2ea8938f74d2e1e60ed45b8f88531383dc /lib
parent8e6bfbfdc27b6ecb38f884b011ebca3ef95e33fc (diff)
downloadqmk_firmware-0f3993b9a3cd3a50b2c9e5d920d6bdb40a9d78be.tar.gz
qmk_firmware-0f3993b9a3cd3a50b2c9e5d920d6bdb40a9d78be.zip
default_keyboard.h generation tweaks (#24715)
Diffstat (limited to 'lib')
-rwxr-xr-xlib/python/qmk/cli/generate/keyboard_h.py19
1 files 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 5863a0983a..cb9528d96b 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)