[Core] get_keycode_string(): function to format keycodes as strings, for more readable debug logging. #24787
+706
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds
get_keycode_string()
as described in https://getreuer.info/posts/keyboards/keycode-string/index.html as a utility function in core.Description
It's much nicer to read keycodes as names like "
LT(2,KC_D)
" than numerical codes like "0x4207
." This PR adds a functionget_keycode_string()
for that purpose, based on my userspace implementation linked above.How to use it
Add in
rules.mk
:KEYCODE_STRING_ENABLE = yes
Then use the
get_keycode_string(kc)
function to convert a given 16-bit keycode to a human-readable string. Example:Limitations
Many common QMK keycodes are recognized by
get_keycode_string()
, but not all. These include some common basic keycodes, layer switch keycodes, mod-taps, one-shot keycodes, tap dance keycodes, and Unicode keycodes. As a fallback, an unrecognized keycode is written as a hex number. Names for additional keycodes can also be added, see below.Keycodes are stringified according to the default KC_-prefixed keycodes, which is suboptimal when the computer is configured to a non-US-QWERTY layout.
Defining names for additional keycodes
Optionally,
keycode_string_names_user
orkeycode_string_names_kb
may be defined to add names for additional keycodes. For example, supposing keymap.c definesMYMACRO1
andMYMACRO2
as custom keycodes, the following adds their names:Types of Changes
Checklist