]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - tmk_core/common/hook.h
core: Update comments in keycode.h
[max/tmk_keyboard.git] / tmk_core / common / hook.h
1 /*
2 Copyright 2016 Jun Wako <wakojun@gmail.com>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef _HOOKS_H_
19 #define _HOOKS_H_
20
21 #include "keyboard.h"
22 #include "led.h"
23 #include "action.h"
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 /* -------------------------------------
30  * Protocol hooks
31  * ------------------------------------- */
32
33 /* Called once, very early stage of initialization, just after processor startup. */
34 /* Default behaviour: do nothing. */
35 void hook_early_init(void);
36
37 /* Called once, very last stage of initialization, just before keyboard loop. */
38 /* Default behaviour: do nothing. */
39 void hook_late_init(void);
40
41 /* Called once, on getting SUSPEND event from USB. */
42 /* Default behaviour: do nothing. */
43 void hook_usb_suspend_entry(void);
44
45 /* Called repeatedly during the SUSPENDed state. */
46 /* Default behaviour: power down and periodically check
47  * the matrix, cause wakeup if needed. */
48 void hook_usb_suspend_loop(void);
49
50 /* Called once, on getting WAKE event from USB. */
51 /* Default behaviour: disables sleep LED breathing and restores 
52  * the "normal" indicator LED status by default. */
53 void hook_usb_wakeup(void);
54
55 /* Called repeatedly until getting to CONFIGURED state */
56 /* Default behaviour: do nothing. */
57 void hook_usb_startup_wait_loop(void);
58
59
60 /* -------------------------------------
61  * Keyboard hooks
62  * ------------------------------------- */
63
64 /* Called periodically from the keyboard loop (very often!) */
65 /* Default behaviour: do nothing. */
66 void hook_keyboard_loop(void);
67
68 /* Called on matrix state change event (every keypress => often!) */
69 /* Default behaviour: do nothing. */
70 void hook_matrix_change(keyevent_t event);
71
72 /* Called on default layer state change event. */
73 /* Default behaviour: do nothing. */
74 void hook_default_layer_change(uint32_t default_layer_state);
75
76 /* Called on layer state change event. */
77 /* Default behaviour: do nothing. */
78 void hook_layer_change(uint32_t layer_state);
79
80 /* Called on indicator LED update event (when reported from host). */
81 /* Default behaviour: calls keyboard_set_leds. */
82 void hook_keyboard_leds_change(uint8_t led_status);
83
84 /* Called once, on checking the bootmagic combos. */
85 /* Default behaviour: do nothing. */
86 void hook_bootmagic(void);
87
88 /* Called on before processing key event */
89 /* returns true if the event is consumed and default action is not needed. */
90 bool hook_process_action(keyrecord_t *record);
91
92 #ifdef __cplusplus
93 }
94 #endif
95
96 #endif /* _HOOKS_H_ */