Skip to content

Programmable Button

Programmable Buttons are keys that have no predefined meaning. This means they can be processed on the host side by custom software without the operating system trying to interpret them.

The keycodes are emitted according to the HID Telephony Device page (0x0B), Programmable Button usage (0x09). On Linux (> 5.14) they are handled automatically and translated to KEY_MACRO# keycodes (up to KEY_MACRO30).

TIP

Currently there is no known support in Windows or macOS. It may be possible to write a custom HID driver to receive these usages, but this is out of the scope of the QMK documentation.

Usage

Add the following to your rules.mk:

make
PROGRAMMABLE_BUTTON_ENABLE = yes

Keycodes

KeyAliasesDescription
QK_PROGRAMMABLE_BUTTON_1PB_1Programmable button 1
QK_PROGRAMMABLE_BUTTON_2PB_2Programmable button 2
QK_PROGRAMMABLE_BUTTON_3PB_3Programmable button 3
QK_PROGRAMMABLE_BUTTON_4PB_4Programmable button 4
QK_PROGRAMMABLE_BUTTON_5PB_5Programmable button 5
QK_PROGRAMMABLE_BUTTON_6PB_6Programmable button 6
QK_PROGRAMMABLE_BUTTON_7PB_7Programmable button 7
QK_PROGRAMMABLE_BUTTON_8PB_8Programmable button 8
QK_PROGRAMMABLE_BUTTON_9PB_9Programmable button 9
QK_PROGRAMMABLE_BUTTON_10PB_10Programmable button 10
QK_PROGRAMMABLE_BUTTON_11PB_11Programmable button 11
QK_PROGRAMMABLE_BUTTON_12PB_12Programmable button 12
QK_PROGRAMMABLE_BUTTON_13PB_13Programmable button 13
QK_PROGRAMMABLE_BUTTON_14PB_14Programmable button 14
QK_PROGRAMMABLE_BUTTON_15PB_15Programmable button 15
QK_PROGRAMMABLE_BUTTON_16PB_16Programmable button 16
QK_PROGRAMMABLE_BUTTON_17PB_17Programmable button 17
QK_PROGRAMMABLE_BUTTON_18PB_18Programmable button 18
QK_PROGRAMMABLE_BUTTON_19PB_19Programmable button 19
QK_PROGRAMMABLE_BUTTON_20PB_20Programmable button 20
QK_PROGRAMMABLE_BUTTON_21PB_21Programmable button 21
QK_PROGRAMMABLE_BUTTON_22PB_22Programmable button 22
QK_PROGRAMMABLE_BUTTON_23PB_23Programmable button 23
QK_PROGRAMMABLE_BUTTON_24PB_24Programmable button 24
QK_PROGRAMMABLE_BUTTON_25PB_25Programmable button 25
QK_PROGRAMMABLE_BUTTON_26PB_26Programmable button 26
QK_PROGRAMMABLE_BUTTON_27PB_27Programmable button 27
QK_PROGRAMMABLE_BUTTON_28PB_28Programmable button 28
QK_PROGRAMMABLE_BUTTON_29PB_29Programmable button 29
QK_PROGRAMMABLE_BUTTON_30PB_30Programmable button 30
QK_PROGRAMMABLE_BUTTON_31PB_31Programmable button 31
QK_PROGRAMMABLE_BUTTON_32PB_32Programmable button 32

API

void programmable_button_clear(void)

Clear the programmable button report.


void programmable_button_add(uint8_t index)

Set the state of a button.

Arguments

  • uint8_t index
    The index of the button to press, from 0 to 31.

void programmable_button_remove(uint8_t index)

Reset the state of a button.

Arguments

  • uint8_t index
    The index of the button to release, from 0 to 31.

void programmable_button_register(uint8_t index)

Set the state of a button, and flush the report.

Arguments

  • uint8_t index
    The index of the button to press, from 0 to 31.

void programmable_button_unregister(uint8_t index)

Reset the state of a button, and flush the report.

Arguments

  • uint8_t index
    The index of the button to release, from 0 to 31.

bool programmable_button_is_on(uint8_t index)

Get the state of a button.

Arguments

  • uint8_t index
    The index of the button to check, from 0 to 31.

Return Value

true if the button is pressed.


void programmable_button_flush(void)

Send the programmable button report to the host.


uint32_t programmable_button_get_report(void)

Get the programmable button report.

Return Value

The bitmask of programmable button states.


void programmable_button_set_report(uint32_t report)

Set the programmable button report.

Arguments

  • uint32_t report
    A bitmask of programmable button states.