diff options
Diffstat (limited to 'users/drashna/readme/handlers.md')
-rw-r--r-- | users/drashna/readme/handlers.md | 97 |
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 | |||
3 | Specifically 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` | ||
7 | The same goes for `matrix_init`, `layer_state_set`, `led_set`, and a few other functions. | ||
8 | |||
9 | All (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 | |||
11 | This allows for keyboard specific configuration while maintaining the ability to customize the board. | ||
12 | |||
13 | My [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 | |||
15 | But for a list: | ||
16 | |||
17 | ```c | ||
18 | __attribute__ ((weak)) | ||
19 | void matrix_init_keymap(void) {} | ||
20 | |||
21 | void matrix_init_user(void) { | ||
22 | matrix_init_keymap(); | ||
23 | } | ||
24 | |||
25 | __attribute__((weak)) | ||
26 | void keyboard_post_init_keymap(void){ } | ||
27 | |||
28 | void keyboard_post_init_user(void){ | ||
29 | keyboard_post_init_keymap(); | ||
30 | } | ||
31 | |||
32 | __attribute__ ((weak)) | ||
33 | void matrix_scan_keymap(void) {} | ||
34 | |||
35 | void matrix_scan_user(void) { | ||
36 | matrix_scan_keymap(); | ||
37 | } | ||
38 | |||
39 | |||
40 | __attribute__ ((weak)) | ||
41 | bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { | ||
42 | return true; | ||
43 | } | ||
44 | |||
45 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
46 | return process_record_keymap(keycode, record); | ||
47 | } | ||
48 | |||
49 | |||
50 | __attribute__ ((weak)) | ||
51 | layer_state_t layer_state_set_keymap (layer_state_t state) { | ||
52 | return state; | ||
53 | } | ||
54 | |||
55 | layer_state_t layer_state_set_user (layer_state_t state) { | ||
56 | return layer_state_set_keymap (state); | ||
57 | } | ||
58 | |||
59 | |||
60 | __attribute__ ((weak)) | ||
61 | void led_set_keymap(uint8_t usb_led) {} | ||
62 | |||
63 | void led_set_user(uint8_t usb_led) { | ||
64 | led_set_keymap(usb_led); | ||
65 | } | ||
66 | |||
67 | |||
68 | __attribute__ ((weak)) | ||
69 | void suspend_power_down_keymap(void) {} | ||
70 | |||
71 | void suspend_power_down_user(void) { | ||
72 | suspend_power_down_keymap(); | ||
73 | } | ||
74 | |||
75 | |||
76 | __attribute__ ((weak)) | ||
77 | void suspend_wakeup_init_keymap(void) {} | ||
78 | |||
79 | void suspend_wakeup_init_user(void) { | ||
80 | suspend_wakeup_init_keymap(); | ||
81 | } | ||
82 | |||
83 | |||
84 | __attribute__ ((weak)) | ||
85 | void shutdown_keymap(void) {} | ||
86 | |||
87 | void shutdown_user (void) { | ||
88 | shutdown_keymap(); | ||
89 | } | ||
90 | |||
91 | __attribute__ ((weak)) | ||
92 | void eeconfig_init_keymap(void) {} | ||
93 | |||
94 | void eeconfig_init_user(void) { | ||
95 | eeconfig_init_keymap(); | ||
96 | } | ||
97 | ``` | ||