Skip to content
jb-qmkPublic

About

QMK Community Module for runtime keyboard help, printing registered shortcuts and firmware state directly into the active application.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Help

Let your keyboard document itself.

A QMK Community Module that turns your keyboard into its own reference manual and diagnostic tool.

Have you ever forgotten a shortcut in your own keymap? Which keys control RGB animations? How do you start recording a macro? What is the current tapping term?

Instead of looking through your source code or maintaining a separate cheat sheet, ask your keyboard.

Open a text editor, press a dedicated Help key, and the keyboard types the answer.

Key features

  • On-demand shortcut reference — recall your custom shortcuts without opening the keymap source.
  • Runtime state reporting — inspect active layers, RGB settings, firmware version, battery level and other runtime values.
  • Extensible registry — register your own shortcuts and state getters from your keymap, userspace or other Community Modules.
  • Ready-made getters — a collection of getters covering common QMK features and settings.
  • Interruptible output — pause typing by holding a key, or cancel the report with Escape.
  • No host-side dependencies — no drivers, companion applications, console connection or additional display required.

Example output

Press HELP_KEYS to get your shortcut reference:

# Keyboard shortcuts
# RightAlt: PrtSc   Keyboard bootloader
# Fn: ScrLk, Pause  Macros: record
# Fn: Q, A          RGB animations

Press HELP_STATE to inspect the current keyboard state:

# Keyboard state
# Uptime:        1386 s
# Active layer:  0
# RGB animation: SOLID_COLOR
# USB state:     configured
# Bluetooth:     connected

These are your reports, tailored to your keyboard. You decide what to include. The module provides the registry, output engine and ready-made getters without registering any entries automatically.

Open a text editor first. The reports are typed as ordinary keyboard input, including Enter at the end of each line. Avoid triggering them in terminals, chat applications or other places where Enter executes a command or submits a message.

Installation

Requires QMK with Community Modules (API 1.0.0 or newer).

git submodule add https://github.com/jb-qmk/help.git modules/jbanaszczyk/help

Place this directory at modules/jbanaszczyk/help in qmk_firmware or in your userspace, then add the module to keyboard.json, info.json or keymap.json:

{
  "modules": [
    "jbanaszczyk/help"
  ]
}

Keycodes

Keycode Alias Action
HELP_KEYS HLP_KEY List registered shortcuts
HELP_STATE HLP_ST List registered state values

Output starts after all keys and modifiers are released and pauses while any are held. Escape cancels the report and is passed through normally. Pressing either Help key again also cancels. Other keys are not intercepted.

Registration

Register records once during initialization. QMK generates the keyboard_post_init_help_user() hook for this module; only one definition is allowed per build. Any other init hook, in userspace or in another module, works as well.

#ifdef COMMUNITY_MODULE_HELP_ENABLE
#    include "help.h"

static const char *layer_name(void) {
    return help_get_active_layer() == 0 ? "BASE" : "FN";
}

void keyboard_post_init_help_user(void) {
    help_register_key("Fn: Q, A", "RGB animations");
    help_register_key("Fn: PrtSc", "Keyboard bootloader");

    help_register_bool("Caps Lock", help_get_caps_lock);
    help_register_long("Active layer", NULL, help_get_active_layer);
    help_register_ulong("Layer mask", "0x%08lx", help_get_layer_mask);
    help_register_ulong("Uptime", "%lu s", help_get_uptime);
    help_register_string("Layer name", layer_name);
}
#endif

Shortcuts are best registered in keymap.c, next to the bindings they describe. Records are printed in registration order, with columns aligned to the longest shortcut or state name.

Function Value
help_register_key(shortcut, description) Two string literals, stored in PROGMEM
help_register_bool(name, getter) true / false
help_register_long(name, format, getter) long, format defaults to %ld
help_register_ulong(name, format, getter) unsigned long, format defaults to %lu
help_register_string(name, getter) const char *, printed as-is, NULL as ?

Details:

  • Every function returns false if the registry is full, the record is invalid or a report is in progress. There is no unregister API.
  • Records are copied, strings are not: state names and formats must be persistent, RAM-readable strings.
  • A custom format must take exactly one argument of the registered type, e.g. "%lu ms" or "0x%08lx".
  • Getters are called once per line, when that line is about to be typed.
  • help_register_key() is a macro wrapping its arguments in PSTR(). To pass existing PROGMEM pointers, call help_register_key_() with a help_key_record_t.

String getters

A string getter must return a null-terminated, RAM-readable string that stays valid and unchanged until its line has been typed. The value is not copied, so never return a pointer to a stack or temporary buffer.

Do not return PROGMEM pointers: the string is read directly, not through pgm_read_byte(). On AVR this means every string literal returned by a getter lives in RAM, so watch the RAM budget there. On ARM this does not matter.

Output

  • Output is typed with QMK's Send String, so it is ASCII only and follows the Send String layout. Other characters are typed as ?.
  • An active Caps Lock is compensated for.
  • Every line ends with a real Enter. Use a text editor.
  • Suspend and wakeup cancel a running report. Call help_cancel() from your own reset code if you need the same.

Configuration

Option Default Meaning
HELP_MAX_KEYS 32 Capacity of the shortcut registry
HELP_MAX_STATES 32 Capacity of the state registry
HELP_CHAR_INTERVAL_MS 5 Minimum time between two characters
HELP_TAP_DELAY_MS 5 Key press duration of a single character
HELP_LINE_PREFIX "# " Prefix of every line
HELP_VALUE_BUFFER_SIZE 32 Buffer for a formatted numeric value

Ready-made getters

All in help.h, named help_get_*. Feature-specific ones exist only when the feature is enabled.

Group Getters
Firmware firmware_version, build_date, keyboard_name, keymap_name, uptime
Layers active_layer, default_layer, layer_mask, default_layer_mask
Host caps_lock, num_lock, scroll_lock, host_led_mask, usb_state, usb_protocol, host_os
Keymap keymap_config, gui_disabled, nkro_enabled, nkro_active
Debug debug_enabled, debug_matrix, debug_keyboard, debug_mouse, debug_mask, matrix_scan_rate
RGB rgb_enabled, rgb_mode, rgb_mode_name, rgb_hue, rgb_saturation, rgb_brightness, rgb_speed, rgb_flags, rgb_suspended, rgb_active
Features caps_word_active, autocorrect_enabled, auto_shift_enabled, auto_shift_timeout, combo_enabled, key_override_enabled, oneshot_enabled, swap_hands, tapping_term, battery_percent, wpm

rgb_mode_name needs #define RGB_MATRIX_MODE_NAME_ENABLE; host_os needs OS_DETECTION_ENABLE = yes; matrix_scan_rate needs DEBUG_MATRIX_SCAN_RATE; tapping_term needs DYNAMIC_TAPPING_TERM_ENABLE = yes.

License

Boost Software License 1.0 (BSL-1.0).

About

QMK Community Module for runtime keyboard help, printing registered shortcuts and firmware state directly into the active application.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages