Create Home.md
parent
ad49086be5
commit
163754f363
49
docs/Home.md
49
docs/Home.md
|
@ -132,52 +132,3 @@ case MACRO_RAISED:
|
||||||
|
|
||||||
Enable the backlight from the Makefile.
|
Enable the backlight from the Makefile.
|
||||||
|
|
||||||
# Custom Quantum functions
|
|
||||||
|
|
||||||
All of these functions are available in the `*_kb()` or `*_user()` variety. `kb` ones should only be used in the `<keyboard>/<keyboard>.c` file, and `user` ones should only be used in the `keymap.c`. The keyboard ones call the user ones - it's necessary to keep these calls to allow the keymap functions to work correctly.
|
|
||||||
|
|
||||||
## `void matrix_init_*(void)`
|
|
||||||
|
|
||||||
This function gets called when the matrix is initiated, and can contain start-up code for your keyboard/keymap.
|
|
||||||
|
|
||||||
## `void matrix_scan_*(void)`
|
|
||||||
|
|
||||||
This function gets called at every matrix scan, which is basically as often as the MCU can handle. Be careful what you put here, as it will get run a lot.
|
|
||||||
|
|
||||||
## `bool process_record_*(uint16_t keycode, keyrecord_t *record)`
|
|
||||||
|
|
||||||
This function gets called on every keypress/release, and is where you can define custom functionality. The return value is whether or not QMK should continue processing the keycode - returning `false` stops the execution.
|
|
||||||
|
|
||||||
The `keycode` variable is whatever is defined in your keymap, eg `MO(1)`, `KC_L`, etc. and can be switch-cased to execute code whenever a particular code is pressed.
|
|
||||||
|
|
||||||
The `record` variable contains infomation about the actual press:
|
|
||||||
|
|
||||||
```
|
|
||||||
keyrecord_t record {
|
|
||||||
keyevent_t event {
|
|
||||||
keypos_t key {
|
|
||||||
uint8_t col
|
|
||||||
uint8_t row
|
|
||||||
}
|
|
||||||
bool pressed
|
|
||||||
uint16_t time
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
The conditional `if (record->event.pressed)` can tell if the key is being pressed or released, and you can execute code based on that.
|
|
||||||
|
|
||||||
## `void led_set_*(uint8_t usb_led)`
|
|
||||||
|
|
||||||
This gets called whenever there is a state change on your host LEDs \(eg caps lock, scroll lock, etc\). The LEDs are defined as:
|
|
||||||
|
|
||||||
```
|
|
||||||
#define USB_LED_NUM_LOCK 0
|
|
||||||
#define USB_LED_CAPS_LOCK 1
|
|
||||||
#define USB_LED_SCROLL_LOCK 2
|
|
||||||
#define USB_LED_COMPOSE 3
|
|
||||||
#define USB_LED_KANA 4
|
|
||||||
```
|
|
||||||
|
|
||||||
and can be tested against the `usb_led` with a conditional like `if (usb_led & (1<<USB_LED_CAPS_LOCK))` - if this is true, you can turn your LED on, otherwise turn it off.
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue