mirror of
https://github.com/qmk/qmk_firmware.git
synced 2026-09-29 13:30:33 +02:00
keycode_string(): Format keycodes as strings.
This adds the `keycode_string()` function described in https://getreuer.info/posts/keyboards/keycode-string/index.html as a core feature.
This commit is contained in:
@@ -77,6 +77,17 @@ KL: kc: 172, col: 2, row: 0, pressed: 1, time: 16303, int: 0, count: 0
|
||||
KL: kc: 172, col: 2, row: 0, pressed: 0, time: 16411, int: 0, count: 0
|
||||
```
|
||||
|
||||
### Which keycode is this keypress?
|
||||
|
||||
Keycodes are logged in the example above as numerical codes, which may be difficult to interpret. For more readable logging, add `KEYCODE_STRING_ENABLE = yes` in your `rules.mk` and use `keycode_string(kc)`. For example:
|
||||
|
||||
```c
|
||||
uprintf("kc: %s\n", keycode_string(keycode));
|
||||
```
|
||||
|
||||
This logs the keycode as a human-readable string like "`LT(2,KC_D)`" rather than a numerical code like "`0x4207`." See the [keycode_string](unit_testing#keycode-string) section of the Unit Testing page for more information.
|
||||
|
||||
|
||||
### How long did it take to scan for a keypress?
|
||||
|
||||
When testing performance issues, it can be useful to know the frequency at which the switch matrix is being scanned. To enable logging for this scenario, add the following code to your keymaps `config.h`
|
||||
|
||||
Reference in New Issue
Block a user