Add C hint to inline code

This commit is contained in:
Yan-Fa Li 2018-10-01 19:50:14 -07:00 committed by Jack Humbert
parent 1512a6bfd4
commit 713ec91147

View file

@ -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&#xb2;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&#xb2;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: