aboutsummaryrefslogtreecommitdiff
path: root/users/drashna/readme/handlers.md
diff options
context:
space:
mode:
Diffstat (limited to 'users/drashna/readme/handlers.md')
-rw-r--r--users/drashna/readme/handlers.md97
1 files changed, 97 insertions, 0 deletions
diff --git a/users/drashna/readme/handlers.md b/users/drashna/readme/handlers.md
new file mode 100644
index 000000000..4abaf5147
--- /dev/null
+++ b/users/drashna/readme/handlers.md
@@ -0,0 +1,97 @@
1# Custom Userspace Function handlers
2
3Specifically QMK works by using customized handlers for everything. This allows for multiple levels of customization.
4
5`matrix_scan` calls `matrix_scan_quantum`, which calls `matrix_scan_kb`, which calls `matrix_scan_user`.
6`process_record` calls a bunch of stuff, but eventually calls `process_record_kb` which calls `process_record_user`
7The same goes for `matrix_init`, `layer_state_set`, `led_set`, and a few other functions.
8
9All (most) `_user` functions are handled here, in the userspace instead. To allow keyboard specific configuration, I've created `_keymap` functions that can be called by the keymap.c files instead.
10
11This allows for keyboard specific configuration while maintaining the ability to customize the board.
12
13My [Ergodox EZ Keymap](https://github.com/qmk/qmk_firmware/blob/master/layouts/community/ergodox/drashna/keymap.c) is a good example of this, as it uses the LEDs as modifier indicators.
14
15But for a list:
16
17```c
18__attribute__ ((weak))
19void matrix_init_keymap(void) {}
20
21void matrix_init_user(void) {
22 matrix_init_keymap();
23}
24
25__attribute__((weak))
26void keyboard_post_init_keymap(void){ }
27
28void keyboard_post_init_user(void){
29 keyboard_post_init_keymap();
30}
31
32__attribute__ ((weak))
33void matrix_scan_keymap(void) {}
34
35void matrix_scan_user(void) {
36 matrix_scan_keymap();
37}
38
39
40__attribute__ ((weak))
41bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
42 return true;
43}
44
45bool process_record_user(uint16_t keycode, keyrecord_t *record) {
46 return process_record_keymap(keycode, record);
47}
48
49
50__attribute__ ((weak))
51layer_state_t layer_state_set_keymap (layer_state_t state) {
52 return state;
53}
54
55layer_state_t layer_state_set_user (layer_state_t state) {
56 return layer_state_set_keymap (state);
57}
58
59
60__attribute__ ((weak))
61void led_set_keymap(uint8_t usb_led) {}
62
63void led_set_user(uint8_t usb_led) {
64 led_set_keymap(usb_led);
65}
66
67
68__attribute__ ((weak))
69void suspend_power_down_keymap(void) {}
70
71void suspend_power_down_user(void) {
72 suspend_power_down_keymap();
73}
74
75
76__attribute__ ((weak))
77void suspend_wakeup_init_keymap(void) {}
78
79void suspend_wakeup_init_user(void) {
80 suspend_wakeup_init_keymap();
81}
82
83
84__attribute__ ((weak))
85void shutdown_keymap(void) {}
86
87void shutdown_user (void) {
88 shutdown_keymap();
89}
90
91__attribute__ ((weak))
92void eeconfig_init_keymap(void) {}
93
94void eeconfig_init_user(void) {
95 eeconfig_init_keymap();
96}
97```