aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorDrashna Jaelre <[email protected]>2025-05-04 17:21:47 -0700
committerGitHub <[email protected]>2025-05-05 10:21:47 +1000
commit12caf0be4eab171ffeb041cc153f9addb68f404e (patch)
tree0b89fa2aa4c5ce4a525d1385a10489844e413ee9 /quantum
parentbb9dd05c6ae0a53ced5591c70a898feef037b31c (diff)
downloadqmk_firmware-12caf0be4eab171ffeb041cc153f9addb68f404e.tar.gz
qmk_firmware-12caf0be4eab171ffeb041cc153f9addb68f404e.zip
Add additional hooks for Community modules (#25050)
Diffstat (limited to 'quantum')
-rw-r--r--quantum/action_layer.c19
-rw-r--r--quantum/action_layer.h3
-rw-r--r--quantum/led_matrix/led_matrix.c10
-rw-r--r--quantum/pointing_device/pointing_device.c9
-rw-r--r--quantum/pointing_device/pointing_device.h1
-rw-r--r--quantum/rgb_matrix/rgb_matrix.c10
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
return default_layer_state_set_user(state);
}
+/** \brief Default Layer State Set At Module Level
+ *
+ * Run module code on default layer state change
+ */
+__attribute__((weak)) layer_state_t default_layer_state_set_modules(layer_state_t state) {
+ return state;
+}
+
/** \brief Default Layer State Set
*
* Static function to set the default layer state, prints debug info and clears keys
*/
static void default_layer_state_set(layer_state_t state) {
+ state = default_layer_state_set_modules(state);
state = default_layer_state_set_kb(state);
ac_dprintf("default_layer_state: ");
default_layer_debug();
@@ -107,11 +116,21 @@ __attribute__((weak)) layer_state_t layer_state_set_kb(layer_state_t state) {
return layer_state_set_user(state);
}
+/** \brief Layer state set modules
+ *
+ * Runs module code on layer state change
+ */
+
+__attribute__((weak)) layer_state_t layer_state_set_modules(layer_state_t state) {
+ return state;
+}
+
/** \brief Layer state set
*
* Sets the layer to match the specified state (a bitmask)
*/
void layer_state_set(layer_state_t state) {
+ state = layer_state_set_modules(state);
state = layer_state_set_kb(state);
ac_dprintf("layer_state: ");
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;
void default_layer_debug(void);
void default_layer_set(layer_state_t state);
+__attribute__((weak)) layer_state_t default_layer_state_set_modules(layer_state_t state);
__attribute__((weak)) layer_state_t default_layer_state_set_kb(layer_state_t state);
__attribute__((weak)) layer_state_t default_layer_state_set_user(layer_state_t state);
@@ -114,6 +115,7 @@ void layer_and(layer_state_t state);
void layer_xor(layer_state_t state);
layer_state_t layer_state_set_user(layer_state_t state);
layer_state_t layer_state_set_kb(layer_state_t state);
+layer_state_t layer_state_set_modules(layer_state_t state);
/**
* @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_
# define layer_or(state) (void)state
# define layer_and(state) (void)state
# define layer_xor(state) (void)state
+# define layer_state_set_modules(state) (void)state
# define layer_state_set_kb(state) (void)state
# define layer_state_set_user(state) (void)state
# 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) {
}
}
+__attribute__((weak)) bool led_matrix_indicators_modules(void) {
+ return true;
+}
+
void led_matrix_indicators(void) {
+ led_matrix_indicators_modules();
led_matrix_indicators_kb();
}
@@ -370,6 +375,10 @@ __attribute__((weak)) bool led_matrix_indicators_user(void) {
return true;
}
+__attribute__((weak)) bool led_matrix_indicators_advanced_modules(uint8_t led_min, uint8_t led_max) {
+ return true;
+}
+
void led_matrix_indicators_advanced(effect_params_t *params) {
/* special handling is needed for "params->iter", since it's already been incremented.
* 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) {
* led_task_render, right before the iter++ line.
*/
LED_MATRIX_USE_LIMITS_ITER(min, max, params->iter - 1);
+ led_matrix_indicators_advanced_modules(min, max);
led_matrix_indicators_advanced_kb(min, max);
}
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 = {
const pointing_device_driver_t *pointing_device_driver = &POINTING_DEVICE_DRIVER(POINTING_DEVICE_DRIVER_NAME);
+__attribute__((weak)) void pointing_device_init_modules(void) {}
+__attribute__((weak)) report_mouse_t pointing_device_task_modules(report_mouse_t mouse_report) {
+ return mouse_report;
+}
+
/**
* @brief Keyboard level code pointing device initialisation
*
@@ -190,6 +195,7 @@ __attribute__((weak)) void pointing_device_init(void) {
}
#endif
+ pointing_device_init_modules();
pointing_device_init_kb();
pointing_device_init_user();
}
@@ -319,8 +325,9 @@ __attribute__((weak)) bool pointing_device_task(void) {
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);
#else
local_mouse_report = pointing_device_adjust_by_defines(local_mouse_report);
- local_mouse_report = pointing_device_task_kb(local_mouse_report);
#endif
+ local_mouse_report = pointing_device_task_modules(local_mouse_report);
+ local_mouse_report = pointing_device_task_kb(local_mouse_report);
// automatic mouse layer function
#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE
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/>.
#pragma once
+#include <stdbool.h>
#include <stdint.h>
#include "host.h"
#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) {
}
}
+__attribute__((weak)) bool rgb_matrix_indicators_modules(void) {
+ return true;
+}
+
void rgb_matrix_indicators(void) {
+ rgb_matrix_indicators_modules();
rgb_matrix_indicators_kb();
}
@@ -433,6 +438,10 @@ struct rgb_matrix_limits_t rgb_matrix_get_limits(uint8_t iter) {
return limits;
}
+__attribute__((weak)) bool rgb_matrix_indicators_advanced_modules(uint8_t led_min, uint8_t led_max) {
+ return true;
+}
+
void rgb_matrix_indicators_advanced(effect_params_t *params) {
/* special handling is needed for "params->iter", since it's already been incremented.
* 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) {
* rgb_task_render, right before the iter++ line.
*/
RGB_MATRIX_USE_LIMITS_ITER(min, max, params->iter - 1);
+ rgb_matrix_indicators_advanced_modules(min, max);
rgb_matrix_indicators_advanced_kb(min, max);
}