Skip to content

Commit 3e97536

Browse files
committed
hook: Change file and func names(*_hook -> hook_*)
1 parent c64e9aa commit 3e97536

File tree

10 files changed

+55
-63
lines changed

10 files changed

+55
-63
lines changed

common.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SRC += $(COMMON_DIR)/host.c \
1010
$(COMMON_DIR)/print.c \
1111
$(COMMON_DIR)/debug.c \
1212
$(COMMON_DIR)/util.c \
13-
$(COMMON_DIR)/hooks.c \
13+
$(COMMON_DIR)/hook.c \
1414
$(COMMON_DIR)/avr/suspend.c \
1515
$(COMMON_DIR)/avr/xprintf.S \
1616
$(COMMON_DIR)/avr/timer.c \

common/action.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2626
#include "action_macro.h"
2727
#include "action_util.h"
2828
#include "action.h"
29-
#include "hooks.h"
29+
#include "hook.h"
3030

3131
#ifdef DEBUG_ACTION
3232
#include "debug.h"
@@ -40,7 +40,7 @@ void action_exec(keyevent_t event)
4040
if (!IS_NOEVENT(event)) {
4141
dprint("\n---- action_exec: start -----\n");
4242
dprint("EVENT: "); debug_event(event); dprintln();
43-
matrix_change_hook(event);
43+
hook_matrix_change(event);
4444
}
4545

4646
keyrecord_t record = { .event = event };

common/action_layer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "action.h"
44
#include "util.h"
55
#include "action_layer.h"
6-
#include "hooks.h"
6+
#include "hook.h"
77

88
#ifdef DEBUG_ACTION
99
#include "debug.h"
@@ -63,7 +63,7 @@ static void layer_state_set(uint32_t state)
6363
dprint("layer_state: ");
6464
layer_debug(); dprint(" to ");
6565
layer_state = state;
66-
layer_change_hook(layer_state);
66+
hook_layer_change(layer_state);
6767
layer_debug(); dprintln();
6868
clear_keyboard_but_mods(); // To avoid stuck keys
6969
}

common/bootmagic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "action_layer.h"
1010
#include "eeconfig.h"
1111
#include "bootmagic.h"
12-
#include "hooks.h"
12+
#include "hook.h"
1313

1414
keymap_config_t keymap_config;
1515

@@ -42,7 +42,7 @@ void bootmagic(void)
4242
}
4343

4444
/* user-defined checks */
45-
bootmagic_hook();
45+
hook_bootmagic();
4646

4747
/* debug enable */
4848
debug_config.raw = eeconfig_read_debug();

common/hooks.c renamed to common/hook.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

1818
#include "keyboard.h"
19-
#include "hooks.h"
19+
#include "hook.h"
2020

2121
/* -------------------------------------------------
2222
* Definitions of hardware-independent default hooks
@@ -25,33 +25,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2525
/* Called on layer state change event. */
2626
/* Default behaviour: do nothing. */
2727
__attribute__((weak))
28-
void layer_change_hook(uint8_t layer_state) {
28+
void hook_layer_change(uint8_t layer_state) {
2929
(void)layer_state;
3030
}
3131

3232
/* Called periodically from the matrix scan loop (very often!) */
3333
/* Default behaviour: do nothing. */
3434
__attribute__((weak))
35-
void scan_loop_hook(void) {}
35+
void hook_keyboard_loop(void) {}
3636

3737
/* Called on matrix state change event (every keypress => often!) */
3838
/* Default behaviour: do nothing. */
3939
__attribute__((weak))
40-
void matrix_change_hook(keyevent_t event) {
40+
void hook_matrix_change(keyevent_t event) {
4141
(void)event;
4242
}
4343

4444
/* Called on indicator LED update event (when reported from host). */
4545
/* Default behaviour: calls led_set (for compatibility). */
4646
__attribute__((weak))
47-
void led_update_hook(uint8_t led_status) {
47+
void hook_keyboard_leds_change(uint8_t led_status) {
4848
keyboard_set_leds(led_status);
4949
}
5050

5151
/* Called once, on checking the bootmagic combos. */
5252
/* Default behaviour: do nothing. */
5353
__attribute__((weak))
54-
void bootmagic_hook(void) {
54+
void hook_bootmagic(void) {
5555
/* An example: */
5656
// #include "bootmagic.h"
5757
// #include "keymap.h"

common/hooks.h renamed to common/hook.h

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,58 +27,48 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2727

2828
/* Called once, before initialising USB. */
2929
/* Default behaviour: do nothing. */
30-
void early_init_hook(void);
30+
void hook_early_init(void);
3131

3232
/* Called once, after USB is connected and keyboard initialised. */
3333
/* Default behaviour: do nothing. */
34-
void late_init_hook(void);
34+
void hook_late_init(void);
3535

3636
/* Called once, on getting SUSPEND event from USB. */
3737
/* Default behaviour: enables sleep LED breathing. */
38-
void suspend_entry_hook(void);
38+
void hook_suspend_entry(void);
3939

4040
/* Called repeatedly during the SUSPENDed state. */
4141
/* Default behaviour: power down and periodically check
4242
* the matrix, cause wakeup if needed. */
43-
void suspend_loop_hook(void);
43+
void hook_suspend_loop(void);
4444

4545
/* Called once, on getting WAKE event from USB. */
4646
/* Default behaviour: disables sleep LED breathing and restores
4747
* the "normal" indicator LED status by default. */
48-
void wakeup_hook(void);
48+
void hook_wakeup(void);
4949

5050
/* Called once, on checking the bootmagic combos. */
5151
/* Default behaviour: do nothing. */
52-
void bootmagic_hook(void);
52+
void hook_bootmagic(void);
5353

5454
/* -------------------------------------
5555
* Keyboard / periodic hooks
5656
* ------------------------------------- */
5757

58-
/* Called periodically from the matrix scan loop (very often!) */
58+
/* Called periodically from the keyboard loop (very often!) */
5959
/* Default behaviour: do nothing. */
60-
void scan_loop_hook(void);
60+
void hook_keyboard_loop(void);
6161

6262
/* Called on matrix state change event (every keypress => often!) */
6363
/* Default behaviour: do nothing. */
64-
void matrix_change_hook(keyevent_t event);
64+
void hook_matrix_change(keyevent_t event);
6565

6666
/* Called on layer state change event. */
6767
/* Default behaviour: do nothing. */
68-
void layer_change_hook(uint8_t layer_state);
69-
70-
/* Called on tap event. */
71-
/* Default behaviour: do nothing. */
72-
// void tap_event_hook(void);
73-
/* TODO */
74-
75-
/* Called on hold event. */
76-
/* Default behaviour: do nothing. */
77-
// void hold_event_hook(void);
78-
/* TODO */
68+
void hook_layer_change(uint8_t layer_state);
7969

8070
/* Called on indicator LED update event (when reported from host). */
81-
/* Default behaviour: calls led_set (for compatibility). */
82-
void led_update_hook(uint8_t led_status);
71+
/* Default behaviour: calls keyboard_set_leds (for compatibility). */
72+
void hook_keyboard_leds_change(uint8_t led_status);
8373

8474
#endif /* _HOOKS_H_ */

common/keyboard.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
3030
#include "bootmagic.h"
3131
#include "eeconfig.h"
3232
#include "backlight.h"
33-
#include "hooks.h"
33+
#include "hook.h"
3434
#ifdef MOUSEKEY_ENABLE
3535
# include "mousekey.h"
3636
#endif
@@ -129,11 +129,13 @@ void keyboard_task(void)
129129
if (debug_matrix) matrix_print();
130130
for (uint8_t c = 0; c < MATRIX_COLS; c++) {
131131
if (matrix_change & ((matrix_row_t)1<<c)) {
132-
action_exec((keyevent_t){
132+
keyevent_t e = (keyevent_t){
133133
.key = (keypos_t){ .row = r, .col = c },
134134
.pressed = (matrix_row & ((matrix_row_t)1<<c)),
135135
.time = (timer_read() | 1) /* time should not be 0 */
136-
});
136+
};
137+
action_exec(e);
138+
hook_matrix_change(e);
137139
// record a processed key
138140
matrix_prev[r] ^= ((matrix_row_t)1<<c);
139141
// process a key per task call
@@ -147,7 +149,7 @@ void keyboard_task(void)
147149

148150
MATRIX_LOOP_END:
149151

150-
scan_loop_hook();
152+
hook_keyboard_loop();
151153

152154
#ifdef MOUSEKEY_ENABLE
153155
// mousekey repeat & acceleration
@@ -170,7 +172,7 @@ void keyboard_task(void)
170172
if (led_status != host_keyboard_leds()) {
171173
led_status = host_keyboard_leds();
172174
if (debug_keyboard) dprintf("LED: %02X\n", led_status);
173-
led_update_hook(led_status);
175+
hook_keyboard_leds_change(led_status);
174176
}
175177
}
176178

protocol/chibios/main.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "sleep_led.h"
3636
#endif
3737
#include "suspend.h"
38-
#include "hooks.h"
38+
#include "hook.h"
3939

4040

4141
/* -------------------------
@@ -61,13 +61,13 @@ host_driver_t chibios_driver = {
6161

6262
/* Default hooks definitions. */
6363
__attribute__((weak))
64-
void early_init_hook(void) {}
64+
void hook_early_init(void) {}
6565

6666
__attribute__((weak))
67-
void late_init_hook(void) {}
67+
void hook_late_init(void) {}
6868

6969
__attribute__((weak))
70-
void suspend_loop_hook(void) {
70+
void hook_suspend_loop(void) {
7171
/* Do this in the suspended state */
7272
suspend_power_down(); // on AVR this deep sleeps for 15ms
7373
/* Remote wakeup */
@@ -108,7 +108,7 @@ int main(void) {
108108
// TESTING
109109
// chThdCreateStatic(waBlinkerThread, sizeof(waBlinkerThread), NORMALPRIO, blinkerThread, NULL);
110110

111-
early_init_hook();
111+
hook_early_init();
112112

113113
/* Init USB */
114114
init_usb_driver(&USB_DRIVER);
@@ -139,15 +139,15 @@ int main(void) {
139139

140140
print("Keyboard start.\n");
141141

142-
late_init_hook();
142+
hook_late_init();
143143

144144
/* Main loop */
145145
while(true) {
146146

147147
if(USB_DRIVER.state == USB_SUSPENDED) {
148148
print("[s]");
149149
while(USB_DRIVER.state == USB_SUSPENDED) {
150-
suspend_loop_hook();
150+
hook_suspend_loop();
151151
}
152152
/* Woken up */
153153
// variables have been already cleared

protocol/chibios/usb_main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
#include "sleep_led.h"
2828
#include "led.h"
2929
#endif
30-
#include "hooks.h"
30+
#include "hook.h"
3131

3232
/* TMK hooks */
3333
__attribute__((weak))
34-
void wakeup_hook(void) {
34+
void hook_wakeup(void) {
3535
#ifdef SLEEP_LED_ENABLE
3636
sleep_led_disable();
3737
// NOTE: converters may not accept this
@@ -40,7 +40,7 @@ void wakeup_hook(void) {
4040
}
4141

4242
__attribute__((weak))
43-
void suspend_entry_hook(void) {
43+
void hook_suspend_entry(void) {
4444
#ifdef SLEEP_LED_ENABLE
4545
sleep_led_enable();
4646
#endif /* SLEEP_LED_ENABLE */
@@ -814,13 +814,13 @@ static void usb_event_cb(USBDriver *usbp, usbevent_t event) {
814814

815815
case USB_EVENT_SUSPEND:
816816
//TODO: from ISR! print("[S]");
817-
suspend_entry_hook();
817+
hook_suspend_entry();
818818
return;
819819

820820
case USB_EVENT_WAKEUP:
821821
//TODO: from ISR! print("[W]");
822822
suspend_wakeup_init();
823-
wakeup_hook();
823+
hook_wakeup();
824824
return;
825825

826826
case USB_EVENT_STALLED:

protocol/lufa/lufa.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#include "sleep_led.h"
4949
#endif
5050
#include "suspend.h"
51-
#include "hooks.h"
51+
#include "hook.h"
5252

5353
#include "descriptor.h"
5454
#include "lufa.h"
@@ -181,13 +181,13 @@ void EVENT_USB_Device_Reset(void)
181181
void EVENT_USB_Device_Suspend()
182182
{
183183
print("[S]");
184-
suspend_entry_hook();
184+
hook_suspend_entry();
185185
}
186186

187187
void EVENT_USB_Device_WakeUp()
188188
{
189189
print("[W]");
190-
wakeup_hook();
190+
hook_wakeup();
191191
}
192192

193193
#ifdef CONSOLE_ENABLE
@@ -586,7 +586,7 @@ int main(void)
586586
{
587587
setup_mcu();
588588
keyboard_setup();
589-
early_init_hook();
589+
hook_early_init();
590590
setup_usb();
591591
sei();
592592

@@ -608,11 +608,11 @@ int main(void)
608608
#endif
609609

610610
print("Keyboard start.\n");
611-
late_init_hook();
611+
hook_late_init();
612612
while (1) {
613613
while (USB_DeviceState == DEVICE_STATE_Suspended) {
614614
print("[s]");
615-
suspend_loop_hook();
615+
hook_suspend_loop();
616616
}
617617

618618
keyboard_task();
@@ -626,21 +626,21 @@ int main(void)
626626

627627
/* hooks */
628628
__attribute__((weak))
629-
void early_init_hook(void) {}
629+
void hook_early_init(void) {}
630630

631631
__attribute__((weak))
632-
void late_init_hook(void) {}
632+
void hook_late_init(void) {}
633633

634634
__attribute__((weak))
635-
void suspend_entry_hook(void)
635+
void hook_suspend_entry(void)
636636
{
637637
#ifdef SLEEP_LED_ENABLE
638638
sleep_led_enable();
639639
#endif
640640
}
641641

642642
__attribute__((weak))
643-
void suspend_loop_hook(void)
643+
void hook_suspend_loop(void)
644644
{
645645
suspend_power_down();
646646
if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
@@ -649,7 +649,7 @@ void suspend_loop_hook(void)
649649
}
650650

651651
__attribute__((weak))
652-
void wakeup_hook(void)
652+
void hook_wakeup(void)
653653
{
654654
suspend_wakeup_init();
655655
#ifdef SLEEP_LED_ENABLE

0 commit comments

Comments
 (0)