aboutsummaryrefslogtreecommitdiff
path: root/docs/custom_quantum_functions.md
diff options
context:
space:
mode:
authorYan-Fa Li <yanfali@gmail.com>2018-10-01 19:50:14 -0700
committerJack Humbert <jack.humb@gmail.com>2018-10-01 22:55:51 -0400
commit713ec91147aa56849f9e2ff93ee98ef1eb6eebc0 (patch)
tree61a20dce510eb3e97c4b4799b76512a2e8fd51c6 /docs/custom_quantum_functions.md
parent1512a6bfd48fb75619a1f77394d41bdca7ea28b1 (diff)
downloadqmk_firmware-713ec91147aa56849f9e2ff93ee98ef1eb6eebc0.tar.gz
qmk_firmware-713ec91147aa56849f9e2ff93ee98ef1eb6eebc0.zip
Add C hint to inline code
Diffstat (limited to 'docs/custom_quantum_functions.md')
-rw-r--r--docs/custom_quantum_functions.md38
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
27 27
28Here 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. 28Here 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.
29 29
30``` 30```c
31enum my_keycodes { 31enum my_keycodes {
32 FOO = SAFE_RANGE, 32 FOO = SAFE_RANGE,
33 BAR 33 BAR
@@ -44,7 +44,7 @@ These function are called every time a key is pressed or released.
44 44
45This 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. 45This 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.
46 46
47``` 47```c
48bool process_record_user(uint16_t keycode, keyrecord_t *record) { 48bool process_record_user(uint16_t keycode, keyrecord_t *record) {
49 switch (keycode) { 49 switch (keycode) {
50 case FOO: 50 case FOO:
@@ -75,16 +75,16 @@ The `keycode` argument is whatever is defined in your keymap, eg `MO(1)`, `KC_L`
75 75
76The `record` argument contains information about the actual press: 76The `record` argument contains information about the actual press:
77 77
78``` 78```c
79keyrecord_t record { 79keyrecord_t record {
80+-keyevent_t event { 80 keyevent_t event {
81| +-keypos_t key { 81 keypos_t key {
82| | +-uint8_t col 82 uint8_t col
83| | +-uint8_t row 83 uint8_t row
84| | } 84 }
85| +-bool pressed 85 bool pressed
86| +-uint16_t time 86 uint16_t time
87| } 87 }
88} 88}
89``` 89```
90 90
@@ -100,7 +100,7 @@ This allows you to control the 5 LED's defined as part of the USB Keyboard spec.
100 100
101### Example `led_set_user()` Implementation 101### Example `led_set_user()` Implementation
102 102
103``` 103```c
104void led_set_user(uint8_t usb_led) { 104void led_set_user(uint8_t usb_led) {
105 if (usb_led & (1<<USB_LED_NUM_LOCK)) { 105 if (usb_led & (1<<USB_LED_NUM_LOCK)) {
106 PORTB |= (1<<0); 106 PORTB |= (1<<0);
@@ -138,14 +138,14 @@ void led_set_user(uint8_t usb_led) {
138 138
139# Matrix Initialization Code 139# Matrix Initialization Code
140 140
141Before 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&#xb2;c controllers you will need to set up that hardware before it can be used. 141Before 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&#xb2;c controllers you will need to set up that hardware before it can be used.
142 142
143 143
144### Example `matrix_init_user()` Implementation 144### Example `matrix_init_user()` Implementation
145 145
146This example, at the keyboard level, sets up B1, B2, and B3 as LED pins. 146This example, at the keyboard level, sets up B1, B2, and B3 as LED pins.
147 147
148``` 148```c
149void matrix_init_user(void) { 149void matrix_init_user(void) {
150 // Call the keymap level matrix init. 150 // Call the keymap level matrix init.
151 151
@@ -181,16 +181,16 @@ You should use this function if you need custom matrix scanning code. It can als
181 181
182# Keyboard Idling/Wake Code 182# Keyboard Idling/Wake Code
183 183
184If 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. 184If 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.
185 185
186This 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. 186This 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.
187 187
188 188
189### Example suspend_power_down_user() and suspend_wakeup_init_user() Implementation 189### Example suspend_power_down_user() and suspend_wakeup_init_user() Implementation
190 190
191This example, at the keyboard level, sets up B1, B2, and B3 as LED pins. 191This example, at the keyboard level, sets up B1, B2, and B3 as LED pins.
192 192
193``` 193```c
194void suspend_power_down_user(void) 194void suspend_power_down_user(void)
195{ 195{
196 rgb_matrix_set_suspend_state(true); 196 rgb_matrix_set_suspend_state(true);
@@ -210,13 +210,13 @@ void suspend_wakeup_init_user(void)
210 210
211# Layer Change Code 211# Layer Change Code
212 212
213This runs code every time that the layers get changed. This can be useful for layer indication, or custom layer handling. 213This runs code every time that the layers get changed. This can be useful for layer indication, or custom layer handling.
214 214
215### Example `layer_state_set_*` Implementation 215### Example `layer_state_set_*` Implementation
216 216
217This example shows how to set the [RGB Underglow](feature_rgblight.md) lights based on the layer, using the Planck as an example 217This example shows how to set the [RGB Underglow](feature_rgblight.md) lights based on the layer, using the Planck as an example
218 218
219``` 219```c
220uint32_t layer_state_set_user(uint32_t state) { 220uint32_t layer_state_set_user(uint32_t state) {
221 switch (biton32(state)) { 221 switch (biton32(state)) {
222 case _RAISE: 222 case _RAISE: