1
0
Fork 0

Generate switch statement helpers for keycode ranges (#20059)

This commit is contained in:
Joel Challis 2023-11-01 02:11:42 +00:00 committed by GitHub
parent fbbb221a31
commit b31426252e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 5 deletions

View file

@ -94,6 +94,14 @@ def _generate_helpers(lines, keycodes):
hi = keycodes["keycodes"][f'0x{codes[1]:04X}']['key']
lines.append(f'#define IS_{ _translate_group(group).upper() }_KEYCODE(code) ((code) >= {lo} && (code) <= {hi})')
lines.append('')
lines.append('// Switch statement Helpers')
for group, codes in temp.items():
lo = keycodes["keycodes"][f'0x{codes[0]:04X}']['key']
hi = keycodes["keycodes"][f'0x{codes[1]:04X}']['key']
name = f'{ _translate_group(group).upper() }_KEYCODE_RANGE'
lines.append(f'#define { name.ljust(35) } {lo} ... {hi}')
def _generate_aliases(lines, keycodes):
# Work around ChibiOS ch.h include guard