-
-
Notifications
You must be signed in to change notification settings - Fork 40.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Core] get_keycode_string(): function to format keycodes as strings, for more readable debug logging. #24787
Open
getreuer
wants to merge
7
commits into
qmk:develop
Choose a base branch
from
getreuer:core/keycode_string
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+714
−0
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This adds the `keycode_string()` function described in https://getreuer.info/posts/keyboards/keycode-string/index.html as a core feature.
drashna
reviewed
Jan 5, 2025
drashna
reviewed
Jan 5, 2025
* Rename keycode_string() -> get_keycode_string() for consistency with existing string utils like get_u8_str(). * Revise custom keycode names with separate _user and _kb tables.
Thanks for the quick review, @drashna! I've updated the PR according to your comments. |
getreuer
changed the title
[Core] keycode_string(): function to format keycodes as strings, for more readable debug logging.
[Core] get_keycode_string(): function to format keycodes as strings, for more readable debug logging.
Jan 6, 2025
fauxpark
requested changes
Jan 10, 2025
Co-authored-by: Ryan <[email protected]>
drashna
approved these changes
Jan 10, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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