aboutsummaryrefslogtreecommitdiff
path: root/quantum/process_keycode
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r--quantum/process_keycode/process_rgb_matrix.c101
-rw-r--r--quantum/process_keycode/process_rgb_matrix.h10
-rw-r--r--quantum/process_keycode/process_tap_dance.c12
-rw-r--r--quantum/process_keycode/process_tap_dance.h4
-rw-r--r--quantum/process_keycode/process_underglow.c91
-rw-r--r--quantum/process_keycode/process_underglow.h10
6 files changed, 222 insertions, 6 deletions
diff --git a/quantum/process_keycode/process_rgb_matrix.c b/quantum/process_keycode/process_rgb_matrix.c
new file mode 100644
index 0000000000..fd2aa1a0c7
--- /dev/null
+++ b/quantum/process_keycode/process_rgb_matrix.c
@@ -0,0 +1,101 @@
+// Copyright 2024 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "process_rgb_matrix.h"
+#include "rgb_matrix.h"
+#include "action_util.h"
+#include "keycodes.h"
+#include "modifiers.h"
+
+bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
+#ifdef RGB_TRIGGER_ON_KEYDOWN
+ if (record->event.pressed) {
+#else
+ if (!record->event.pressed) {
+#endif
+ bool shifted = get_mods() & MOD_MASK_SHIFT;
+ switch (keycode) {
+ case QK_RGB_MATRIX_ON:
+ rgb_matrix_enable();
+ return false;
+ case QK_RGB_MATRIX_OFF:
+ rgb_matrix_disable();
+ return false;
+ case QK_RGB_MATRIX_TOGGLE:
+ rgb_matrix_toggle();
+ return false;
+ case QK_RGB_MATRIX_MODE_NEXT:
+ if (shifted) {
+ rgb_matrix_step_reverse();
+ } else {
+ rgb_matrix_step();
+ }
+ return false;
+ case QK_RGB_MATRIX_MODE_PREVIOUS:
+ if (shifted) {
+ rgb_matrix_step();
+ } else {
+ rgb_matrix_step_reverse();
+ }
+ return false;
+ case QK_RGB_MATRIX_HUE_UP:
+ if (shifted) {
+ rgb_matrix_decrease_hue();
+ } else {
+ rgb_matrix_increase_hue();
+ }
+ return false;
+ case QK_RGB_MATRIX_HUE_DOWN:
+ if (shifted) {
+ rgb_matrix_increase_hue();
+ } else {
+ rgb_matrix_decrease_hue();
+ }
+ return false;
+ case QK_RGB_MATRIX_SATURATION_UP:
+ if (shifted) {
+ rgb_matrix_decrease_sat();
+ } else {
+ rgb_matrix_increase_sat();
+ }
+ return false;
+ case QK_RGB_MATRIX_SATURATION_DOWN:
+ if (shifted) {
+ rgb_matrix_increase_sat();
+ } else {
+ rgb_matrix_decrease_sat();
+ }
+ return false;
+ case QK_RGB_MATRIX_VALUE_UP:
+ if (shifted) {
+ rgb_matrix_decrease_val();
+ } else {
+ rgb_matrix_increase_val();
+ }
+ return false;
+ case QK_RGB_MATRIX_VALUE_DOWN:
+ if (shifted) {
+ rgb_matrix_increase_val();
+ } else {
+ rgb_matrix_decrease_val();
+ }
+ return false;
+ case QK_RGB_MATRIX_SPEED_UP:
+ if (shifted) {
+ rgb_matrix_decrease_speed();
+ } else {
+ rgb_matrix_increase_speed();
+ }
+ return false;
+ case QK_RGB_MATRIX_SPEED_DOWN:
+ if (shifted) {
+ rgb_matrix_increase_speed();
+ } else {
+ rgb_matrix_decrease_speed();
+ }
+ return false;
+ }
+ }
+
+ return true;
+}
diff --git a/quantum/process_keycode/process_rgb_matrix.h b/quantum/process_keycode/process_rgb_matrix.h
new file mode 100644
index 0000000000..a02bf57b5f
--- /dev/null
+++ b/quantum/process_keycode/process_rgb_matrix.h
@@ -0,0 +1,10 @@
+// Copyright 2024 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "action.h"
+
+bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record);
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c
index ce3b8fc81f..11df62763d 100644
--- a/quantum/process_keycode/process_tap_dance.c
+++ b/quantum/process_keycode/process_tap_dance.c
@@ -21,6 +21,7 @@
#include "action_util.h"
#include "timer.h"
#include "wait.h"
+#include "keymap_introspection.h"
static uint16_t active_td;
static uint16_t last_tap_time;
@@ -133,7 +134,7 @@ bool preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) {
if (!active_td || keycode == active_td) return false;
- action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(active_td)];
+ action = tap_dance_get(QK_TAP_DANCE_GET_INDEX(active_td));
action->state.interrupted = true;
action->state.interrupting_keycode = keycode;
process_tap_dance_action_on_dance_finished(action);
@@ -150,11 +151,16 @@ bool preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) {
}
bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
+ int td_index;
tap_dance_action_t *action;
switch (keycode) {
case QK_TAP_DANCE ... QK_TAP_DANCE_MAX:
- action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(keycode)];
+ td_index = QK_TAP_DANCE_GET_INDEX(keycode);
+ if (td_index >= tap_dance_count()) {
+ return false;
+ }
+ action = tap_dance_get(td_index);
action->state.pressed = record->event.pressed;
if (record->event.pressed) {
@@ -182,7 +188,7 @@ void tap_dance_task(void) {
if (!active_td || timer_elapsed(last_tap_time) <= GET_TAPPING_TERM(active_td, &(keyrecord_t){})) return;
- action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(active_td)];
+ action = tap_dance_get(QK_TAP_DANCE_GET_INDEX(active_td));
if (!action->state.interrupted) {
process_tap_dance_action_on_dance_finished(action);
}
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h
index c0137c14a3..5cccbdf439 100644
--- a/quantum/process_keycode/process_tap_dance.h
+++ b/quantum/process_keycode/process_tap_dance.h
@@ -35,7 +35,7 @@ typedef struct {
typedef void (*tap_dance_user_fn_t)(tap_dance_state_t *state, void *user_data);
-typedef struct {
+typedef struct tap_dance_action_t {
tap_dance_state_t state;
struct {
tap_dance_user_fn_t on_each_tap;
@@ -78,8 +78,6 @@ typedef struct {
#define TD_INDEX(code) QK_TAP_DANCE_GET_INDEX(code)
#define TAP_DANCE_KEYCODE(state) TD(((tap_dance_action_t *)state) - tap_dance_actions)
-extern tap_dance_action_t tap_dance_actions[];
-
void reset_tap_dance(tap_dance_state_t *state);
/* To be used internally */
diff --git a/quantum/process_keycode/process_underglow.c b/quantum/process_keycode/process_underglow.c
new file mode 100644
index 0000000000..779672ac07
--- /dev/null
+++ b/quantum/process_keycode/process_underglow.c
@@ -0,0 +1,91 @@
+// Copyright 2024 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "process_underglow.h"
+#include "rgblight.h"
+#include "action_util.h"
+#include "keycodes.h"
+#include "modifiers.h"
+
+bool process_underglow(uint16_t keycode, keyrecord_t *record) {
+ if (record->event.pressed) {
+ uint8_t shifted = get_mods() & MOD_MASK_SHIFT;
+ switch (keycode) {
+ case QK_UNDERGLOW_TOGGLE:
+ rgblight_toggle();
+ return false;
+ case QK_UNDERGLOW_MODE_NEXT:
+ if (shifted) {
+ rgblight_step_reverse();
+ } else {
+ rgblight_step();
+ }
+ return false;
+ case QK_UNDERGLOW_MODE_PREVIOUS:
+ if (shifted) {
+ rgblight_step();
+ } else {
+ rgblight_step_reverse();
+ }
+ return false;
+ case QK_UNDERGLOW_HUE_UP:
+ if (shifted) {
+ rgblight_decrease_hue();
+ } else {
+ rgblight_increase_hue();
+ }
+ return false;
+ case QK_UNDERGLOW_HUE_DOWN:
+ if (shifted) {
+ rgblight_increase_hue();
+ } else {
+ rgblight_decrease_hue();
+ }
+ return false;
+ case QK_UNDERGLOW_SATURATION_UP:
+ if (shifted) {
+ rgblight_decrease_sat();
+ } else {
+ rgblight_increase_sat();
+ }
+ return false;
+ case QK_UNDERGLOW_SATURATION_DOWN:
+ if (shifted) {
+ rgblight_increase_sat();
+ } else {
+ rgblight_decrease_sat();
+ }
+ return false;
+ case QK_UNDERGLOW_VALUE_UP:
+ if (shifted) {
+ rgblight_decrease_val();
+ } else {
+ rgblight_increase_val();
+ }
+ return false;
+ case QK_UNDERGLOW_VALUE_DOWN:
+ if (shifted) {
+ rgblight_increase_hue();
+ } else {
+ rgblight_decrease_hue();
+ }
+ return false;
+ case QK_UNDERGLOW_SPEED_UP:
+ if (shifted) {
+ rgblight_decrease_speed();
+ } else {
+ rgblight_increase_speed();
+ }
+ return false;
+ case QK_UNDERGLOW_SPEED_DOWN:
+ if (shifted) {
+ rgblight_increase_speed();
+ } else {
+ rgblight_decrease_speed();
+ }
+ return false;
+ }
+ }
+
+ return true;
+}
diff --git a/quantum/process_keycode/process_underglow.h b/quantum/process_keycode/process_underglow.h
new file mode 100644
index 0000000000..b409cafbb8
--- /dev/null
+++ b/quantum/process_keycode/process_underglow.h
@@ -0,0 +1,10 @@
+// Copyright 2024 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "action.h"
+
+bool process_underglow(uint16_t keycode, keyrecord_t *record);