Keycode alias support.

This commit is contained in:
Nick Brassel 2025-02-07 23:51:53 +11:00
commit 519bd5ac45
No known key found for this signature in database
4 changed files with 12 additions and 2 deletions

View file

@ -47,6 +47,8 @@ def _render_keycodes(module_jsons):
first = False
else:
lines.append(f' {key},')
for alias in keycode.get('aliases', []):
lines.append(f' {alias} = {key},')
lines.append('')
lines.append(' LAST_COMMUNITY_MODULE_KEY')
lines.append('};')

View file

@ -256,5 +256,10 @@ class CommunityModuleJSONEncoder(QMKJSONEncoder):
return '03features'
if key == 'keycodes':
return '04keycodes'
elif self.indentation_level == 3: # keycodes
if key == 'key':
return '00key'
if key == 'aliases':
return '01aliases'
return key

View file

@ -22,7 +22,7 @@ bool process_record_hello_world(uint16_t keycode, keyrecord_t *record) {
}
switch (keycode) {
case CM_HELLO:
case COMMUNITY_MODULE_HELLO:
if (record->event.pressed) {
SEND_STRING("Hello there.");
break;

View file

@ -5,6 +5,9 @@
"deferred_exec": true
},
"keycodes": [
{ "key": "CM_HELLO" }
{
"key": "COMMUNITY_MODULE_HELLO",
"aliases": ["CM_HELO"]
}
]
}