diff options
| author | Drashna Jaelre <drashna@live.com> | 2025-05-04 17:21:47 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-05 10:21:47 +1000 |
| commit | 12caf0be4eab171ffeb041cc153f9addb68f404e (patch) | |
| tree | 0b89fa2aa4c5ce4a525d1385a10489844e413ee9 /quantum | |
| parent | bb9dd05c6ae0a53ced5591c70a898feef037b31c (diff) | |
Add additional hooks for Community modules (#25050)
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/action_layer.c | 19 | ||||
| -rw-r--r-- | quantum/action_layer.h | 3 | ||||
| -rw-r--r-- | quantum/led_matrix/led_matrix.c | 10 | ||||
| -rw-r--r-- | quantum/pointing_device/pointing_device.c | 9 | ||||
| -rw-r--r-- | quantum/pointing_device/pointing_device.h | 1 | ||||
| -rw-r--r-- | quantum/rgb_matrix/rgb_matrix.c | 10 |
6 files changed, 51 insertions, 1 deletions
diff --git a/quantum/action_layer.c b/quantum/action_layer.c index 7c09a5bd1e..5828dcb824 100644 --- a/quantum/action_layer.c +++ b/quantum/action_layer.c | |||
| @@ -27,11 +27,20 @@ __attribute__((weak)) layer_state_t default_layer_state_set_kb(layer_state_t sta | |||
| 27 | return default_layer_state_set_user(state); | 27 | return default_layer_state_set_user(state); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | /** \brief Default Layer State Set At Module Level | ||
| 31 | * | ||
| 32 | * Run module code on default layer state change | ||
| 33 | */ | ||
| 34 | __attribute__((weak)) layer_state_t default_layer_state_set_modules(layer_state_t state) { | ||
| 35 | return state; | ||
| 36 | } | ||
| 37 | |||
| 30 | /** \brief Default Layer State Set | 38 | /** \brief Default Layer State Set |
| 31 | * | 39 | * |
| 32 | * Static function to set the default layer state, prints debug info and clears keys | 40 | * Static function to set the default layer state, prints debug info and clears keys |
| 33 | */ | 41 | */ |
| 34 | static void default_layer_state_set(layer_state_t state) { | 42 | static void default_layer_state_set(layer_state_t state) { |
| 43 | state = default_layer_state_set_modules(state); | ||
| 35 | state = default_layer_state_set_kb(state); | 44 | state = default_layer_state_set_kb(state); |
| 36 | ac_dprintf("default_layer_state: "); | 45 | ac_dprintf("default_layer_state: "); |
| 37 | default_layer_debug(); | 46 | default_layer_debug(); |
| @@ -107,11 +116,21 @@ __attribute__((weak)) layer_state_t layer_state_set_kb(layer_state_t state) { | |||
| 107 | return layer_state_set_user(state); | 116 | return layer_state_set_user(state); |
| 108 | } | 117 | } |
| 109 | 118 | ||
| 119 | /** \brief Layer state set modules | ||
| 120 | * | ||
| 121 | * Runs module code on layer state change | ||
| 122 | */ | ||
| 123 | |||
| 124 | __attribute__((weak)) layer_state_t layer_state_set_modules(layer_state_t state) { | ||
| 125 | return state; | ||
| 126 | } | ||
| 127 | |||
| 110 | /** \brief Layer state set | 128 | /** \brief Layer state set |
| 111 | * | 129 | * |
| 112 | * Sets the layer to match the specified state (a bitmask) | 130 | * Sets the layer to match the specified state (a bitmask) |
| 113 | */ | 131 | */ |
| 114 | void layer_state_set(layer_state_t state) { | 132 | void layer_state_set(layer_state_t state) { |
| 133 | state = layer_state_set_modules(state); | ||
| 115 | state = layer_state_set_kb(state); | 134 | state = layer_state_set_kb(state); |
| 116 | ac_dprintf("layer_state: "); | 135 | ac_dprintf("layer_state: "); |
| 117 | layer_debug(); | 136 | layer_debug(); |
diff --git a/quantum/action_layer.h b/quantum/action_layer.h index a2410d49a5..067e33cdb5 100644 --- a/quantum/action_layer.h +++ b/quantum/action_layer.h | |||
| @@ -78,6 +78,7 @@ extern layer_state_t default_layer_state; | |||
| 78 | void default_layer_debug(void); | 78 | void default_layer_debug(void); |
| 79 | void default_layer_set(layer_state_t state); | 79 | void default_layer_set(layer_state_t state); |
| 80 | 80 | ||
| 81 | __attribute__((weak)) layer_state_t default_layer_state_set_modules(layer_state_t state); | ||
| 81 | __attribute__((weak)) layer_state_t default_layer_state_set_kb(layer_state_t state); | 82 | __attribute__((weak)) layer_state_t default_layer_state_set_kb(layer_state_t state); |
| 82 | __attribute__((weak)) layer_state_t default_layer_state_set_user(layer_state_t state); | 83 | __attribute__((weak)) layer_state_t default_layer_state_set_user(layer_state_t state); |
| 83 | 84 | ||
| @@ -114,6 +115,7 @@ void layer_and(layer_state_t state); | |||
| 114 | void layer_xor(layer_state_t state); | 115 | void layer_xor(layer_state_t state); |
| 115 | layer_state_t layer_state_set_user(layer_state_t state); | 116 | layer_state_t layer_state_set_user(layer_state_t state); |
| 116 | layer_state_t layer_state_set_kb(layer_state_t state); | 117 | layer_state_t layer_state_set_kb(layer_state_t state); |
| 118 | layer_state_t layer_state_set_modules(layer_state_t state); | ||
| 117 | 119 | ||
| 118 | /** | 120 | /** |
| 119 | * @brief Applies the tri layer to global layer state. Not be used in layer_state_set_(kb|user) functions. | 121 | * @brief Applies the tri layer to global layer state. Not be used in layer_state_set_(kb|user) functions. |
| @@ -149,6 +151,7 @@ layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_ | |||
| 149 | # define layer_or(state) (void)state | 151 | # define layer_or(state) (void)state |
| 150 | # define layer_and(state) (void)state | 152 | # define layer_and(state) (void)state |
| 151 | # define layer_xor(state) (void)state | 153 | # define layer_xor(state) (void)state |
| 154 | # define layer_state_set_modules(state) (void)state | ||
| 152 | # define layer_state_set_kb(state) (void)state | 155 | # define layer_state_set_kb(state) (void)state |
| 153 | # define layer_state_set_user(state) (void)state | 156 | # define layer_state_set_user(state) (void)state |
| 154 | # define update_tri_layer(layer1, layer2, layer3) | 157 | # define update_tri_layer(layer1, layer2, layer3) |
diff --git a/quantum/led_matrix/led_matrix.c b/quantum/led_matrix/led_matrix.c index f9d76e2776..00bc199ecf 100644 --- a/quantum/led_matrix/led_matrix.c +++ b/quantum/led_matrix/led_matrix.c | |||
| @@ -358,7 +358,12 @@ void led_matrix_task(void) { | |||
| 358 | } | 358 | } |
| 359 | } | 359 | } |
| 360 | 360 | ||
| 361 | __attribute__((weak)) bool led_matrix_indicators_modules(void) { | ||
| 362 | return true; | ||
| 363 | } | ||
| 364 | |||
| 361 | void led_matrix_indicators(void) { | 365 | void led_matrix_indicators(void) { |
| 366 | led_matrix_indicators_modules(); | ||
| 362 | led_matrix_indicators_kb(); | 367 | led_matrix_indicators_kb(); |
| 363 | } | 368 | } |
| 364 | 369 | ||
| @@ -370,6 +375,10 @@ __attribute__((weak)) bool led_matrix_indicators_user(void) { | |||
| 370 | return true; | 375 | return true; |
| 371 | } | 376 | } |
| 372 | 377 | ||
| 378 | __attribute__((weak)) bool led_matrix_indicators_advanced_modules(uint8_t led_min, uint8_t led_max) { | ||
| 379 | return true; | ||
| 380 | } | ||
| 381 | |||
| 373 | void led_matrix_indicators_advanced(effect_params_t *params) { | 382 | void led_matrix_indicators_advanced(effect_params_t *params) { |
| 374 | /* special handling is needed for "params->iter", since it's already been incremented. | 383 | /* special handling is needed for "params->iter", since it's already been incremented. |
| 375 | * Could move the invocations to led_task_render, but then it's missing a few checks | 384 | * Could move the invocations to led_task_render, but then it's missing a few checks |
| @@ -377,6 +386,7 @@ void led_matrix_indicators_advanced(effect_params_t *params) { | |||
| 377 | * led_task_render, right before the iter++ line. | 386 | * led_task_render, right before the iter++ line. |
| 378 | */ | 387 | */ |
| 379 | LED_MATRIX_USE_LIMITS_ITER(min, max, params->iter - 1); | 388 | LED_MATRIX_USE_LIMITS_ITER(min, max, params->iter - 1); |
| 389 | led_matrix_indicators_advanced_modules(min, max); | ||
| 380 | led_matrix_indicators_advanced_kb(min, max); | 390 | led_matrix_indicators_advanced_kb(min, max); |
| 381 | } | 391 | } |
| 382 | 392 | ||
diff --git a/quantum/pointing_device/pointing_device.c b/quantum/pointing_device/pointing_device.c index 5ee65c9c61..564c2d294c 100644 --- a/quantum/pointing_device/pointing_device.c +++ b/quantum/pointing_device/pointing_device.c | |||
| @@ -109,6 +109,11 @@ const pointing_device_driver_t custom_pointing_device_driver = { | |||
| 109 | 109 | ||
| 110 | const pointing_device_driver_t *pointing_device_driver = &POINTING_DEVICE_DRIVER(POINTING_DEVICE_DRIVER_NAME); | 110 | const pointing_device_driver_t *pointing_device_driver = &POINTING_DEVICE_DRIVER(POINTING_DEVICE_DRIVER_NAME); |
| 111 | 111 | ||
| 112 | __attribute__((weak)) void pointing_device_init_modules(void) {} | ||
| 113 | __attribute__((weak)) report_mouse_t pointing_device_task_modules(report_mouse_t mouse_report) { | ||
| 114 | return mouse_report; | ||
| 115 | } | ||
| 116 | |||
| 112 | /** | 117 | /** |
| 113 | * @brief Keyboard level code pointing device initialisation | 118 | * @brief Keyboard level code pointing device initialisation |
| 114 | * | 119 | * |
| @@ -190,6 +195,7 @@ __attribute__((weak)) void pointing_device_init(void) { | |||
| 190 | } | 195 | } |
| 191 | #endif | 196 | #endif |
| 192 | 197 | ||
| 198 | pointing_device_init_modules(); | ||
| 193 | pointing_device_init_kb(); | 199 | pointing_device_init_kb(); |
| 194 | pointing_device_init_user(); | 200 | pointing_device_init_user(); |
| 195 | } | 201 | } |
| @@ -319,8 +325,9 @@ __attribute__((weak)) bool pointing_device_task(void) { | |||
| 319 | local_mouse_report = is_keyboard_left() ? pointing_device_task_combined_kb(local_mouse_report, shared_mouse_report) : pointing_device_task_combined_kb(shared_mouse_report, local_mouse_report); | 325 | local_mouse_report = is_keyboard_left() ? pointing_device_task_combined_kb(local_mouse_report, shared_mouse_report) : pointing_device_task_combined_kb(shared_mouse_report, local_mouse_report); |
| 320 | #else | 326 | #else |
| 321 | local_mouse_report = pointing_device_adjust_by_defines(local_mouse_report); | 327 | local_mouse_report = pointing_device_adjust_by_defines(local_mouse_report); |
| 322 | local_mouse_report = pointing_device_task_kb(local_mouse_report); | ||
| 323 | #endif | 328 | #endif |
| 329 | local_mouse_report = pointing_device_task_modules(local_mouse_report); | ||
| 330 | local_mouse_report = pointing_device_task_kb(local_mouse_report); | ||
| 324 | // automatic mouse layer function | 331 | // automatic mouse layer function |
| 325 | #ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE | 332 | #ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE |
| 326 | pointing_device_task_auto_mouse(local_mouse_report); | 333 | pointing_device_task_auto_mouse(local_mouse_report); |
diff --git a/quantum/pointing_device/pointing_device.h b/quantum/pointing_device/pointing_device.h index d8b583c87e..e7a0819ed9 100644 --- a/quantum/pointing_device/pointing_device.h +++ b/quantum/pointing_device/pointing_device.h | |||
| @@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 17 | 17 | ||
| 18 | #pragma once | 18 | #pragma once |
| 19 | 19 | ||
| 20 | #include <stdbool.h> | ||
| 20 | #include <stdint.h> | 21 | #include <stdint.h> |
| 21 | #include "host.h" | 22 | #include "host.h" |
| 22 | #include "report.h" | 23 | #include "report.h" |
diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c index 3fc9085f06..94852e3520 100644 --- a/quantum/rgb_matrix/rgb_matrix.c +++ b/quantum/rgb_matrix/rgb_matrix.c | |||
| @@ -393,7 +393,12 @@ void rgb_matrix_task(void) { | |||
| 393 | } | 393 | } |
| 394 | } | 394 | } |
| 395 | 395 | ||
| 396 | __attribute__((weak)) bool rgb_matrix_indicators_modules(void) { | ||
| 397 | return true; | ||
| 398 | } | ||
| 399 | |||
| 396 | void rgb_matrix_indicators(void) { | 400 | void rgb_matrix_indicators(void) { |
| 401 | rgb_matrix_indicators_modules(); | ||
| 397 | rgb_matrix_indicators_kb(); | 402 | rgb_matrix_indicators_kb(); |
| 398 | } | 403 | } |
| 399 | 404 | ||
| @@ -433,6 +438,10 @@ struct rgb_matrix_limits_t rgb_matrix_get_limits(uint8_t iter) { | |||
| 433 | return limits; | 438 | return limits; |
| 434 | } | 439 | } |
| 435 | 440 | ||
| 441 | __attribute__((weak)) bool rgb_matrix_indicators_advanced_modules(uint8_t led_min, uint8_t led_max) { | ||
| 442 | return true; | ||
| 443 | } | ||
| 444 | |||
| 436 | void rgb_matrix_indicators_advanced(effect_params_t *params) { | 445 | void rgb_matrix_indicators_advanced(effect_params_t *params) { |
| 437 | /* special handling is needed for "params->iter", since it's already been incremented. | 446 | /* special handling is needed for "params->iter", since it's already been incremented. |
| 438 | * Could move the invocations to rgb_task_render, but then it's missing a few checks | 447 | * Could move the invocations to rgb_task_render, but then it's missing a few checks |
| @@ -440,6 +449,7 @@ void rgb_matrix_indicators_advanced(effect_params_t *params) { | |||
| 440 | * rgb_task_render, right before the iter++ line. | 449 | * rgb_task_render, right before the iter++ line. |
| 441 | */ | 450 | */ |
| 442 | RGB_MATRIX_USE_LIMITS_ITER(min, max, params->iter - 1); | 451 | RGB_MATRIX_USE_LIMITS_ITER(min, max, params->iter - 1); |
| 452 | rgb_matrix_indicators_advanced_modules(min, max); | ||
| 443 | rgb_matrix_indicators_advanced_kb(min, max); | 453 | rgb_matrix_indicators_advanced_kb(min, max); |
| 444 | } | 454 | } |
| 445 | 455 | ||
