diff options
author | Yan-Fa Li <yanfali@gmail.com> | 2018-10-01 19:50:14 -0700 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2018-10-01 22:55:51 -0400 |
commit | 713ec91147aa56849f9e2ff93ee98ef1eb6eebc0 (patch) | |
tree | 61a20dce510eb3e97c4b4799b76512a2e8fd51c6 | |
parent | 1512a6bfd48fb75619a1f77394d41bdca7ea28b1 (diff) | |
download | qmk_firmware-713ec91147aa56849f9e2ff93ee98ef1eb6eebc0.tar.gz |
Add C hint to inline code
-rw-r--r-- | docs/custom_quantum_functions.md | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/docs/custom_quantum_functions.md b/docs/custom_quantum_functions.md index f8b84cd6b..b077e4b78 100644 --- a/docs/custom_quantum_functions.md +++ b/docs/custom_quantum_functions.md @@ -27,7 +27,7 @@ The first step to creating your own custom keycode(s) is to enumerate them. This Here is an example of enumerating 2 keycodes. After adding this block to your `keymap.c` you will be able to use `FOO` and `BAR` inside your keymap. -``` +```c enum my_keycodes { FOO = SAFE_RANGE, BAR @@ -44,7 +44,7 @@ These function are called every time a key is pressed or released. This example does two things. It defines the behavior for a custom keycode called `FOO`, and it supplements our Enter key by playing a tone whenever it is pressed. -``` +```c bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case FOO: @@ -75,16 +75,16 @@ The `keycode` argument is whatever is defined in your keymap, eg `MO(1)`, `KC_L` The `record` argument contains information about the actual press: -``` +```c keyrecord_t record { -+-keyevent_t event { -| +-keypos_t key { -| | +-uint8_t col -| | +-uint8_t row -| | } -| +-bool pressed -| +-uint16_t time -| } + keyevent_t event { + keypos_t key { + uint8_t col + uint8_t row + } + bool pressed + uint16_t time + } } ``` @@ -100,7 +100,7 @@ This allows you to control the 5 LED's defined as part of the USB Keyboard spec. ### Example `led_set_user()` Implementation -``` +```c void led_set_user(uint8_t usb_led) { if (usb_led & (1<<USB_LED_NUM_LOCK)) { PORTB |= (1<<0); @@ -138,14 +138,14 @@ void led_set_user(uint8_t usb_led) { # Matrix Initialization Code -Before a keyboard can be used the hardware must be initialized. QMK handles initialization of the keyboard matrix itself, but if you have other hardware like LED's or i²c controllers you will need to set up that hardware before it can be used. +Before a keyboard can be used the hardware must be initialized. QMK handles initialization of the keyboard matrix itself, but if you have other hardware like LED's or i²c controllers you will need to set up that hardware before it can be used. ### Example `matrix_init_user()` Implementation This example, at the keyboard level, sets up B1, B2, and B3 as LED pins. -``` +```c void matrix_init_user(void) { // Call the keymap level matrix init. @@ -181,16 +181,16 @@ You should use this function if you need custom matrix scanning code. It can als # Keyboard Idling/Wake Code -If the board supports it, it can be "idled", by stopping a number of functions. A good example of this is RGB lights or backlights. This can save on power consumption, or may be better behavior for your keyboard. +If the board supports it, it can be "idled", by stopping a number of functions. A good example of this is RGB lights or backlights. This can save on power consumption, or may be better behavior for your keyboard. -This is controlled by two functions: `suspend_power_down_*` and `suspend_wakeup_init_*`, which are called when the system is board is idled and when it wakes up, respectively. +This is controlled by two functions: `suspend_power_down_*` and `suspend_wakeup_init_*`, which are called when the system is board is idled and when it wakes up, respectively. ### Example suspend_power_down_user() and suspend_wakeup_init_user() Implementation This example, at the keyboard level, sets up B1, B2, and B3 as LED pins. -``` +```c void suspend_power_down_user(void) { rgb_matrix_set_suspend_state(true); @@ -210,13 +210,13 @@ void suspend_wakeup_init_user(void) # Layer Change Code -This runs code every time that the layers get changed. This can be useful for layer indication, or custom layer handling. +This runs code every time that the layers get changed. This can be useful for layer indication, or custom layer handling. ### Example `layer_state_set_*` Implementation This example shows how to set the [RGB Underglow](feature_rgblight.md) lights based on the layer, using the Planck as an example -``` +```c uint32_t layer_state_set_user(uint32_t state) { switch (biton32(state)) { case _RAISE: |