aboutsummaryrefslogtreecommitdiffstats
path: root/quantum/process_keycode
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r--quantum/process_keycode/process_dynamic_macro.c23
-rw-r--r--quantum/process_keycode/process_led_matrix.c6
-rw-r--r--quantum/process_keycode/process_rgb_matrix.c14
3 files changed, 42 insertions, 1 deletions
diff --git a/quantum/process_keycode/process_dynamic_macro.c b/quantum/process_keycode/process_dynamic_macro.c
index f8e8256ac8..20e90c6e14 100644
--- a/quantum/process_keycode/process_dynamic_macro.c
+++ b/quantum/process_keycode/process_dynamic_macro.c
@@ -89,6 +89,11 @@ __attribute__((weak)) bool dynamic_macro_valid_key_user(uint16_t keycode, keyrec
#define DYNAMIC_MACRO_CURRENT_LENGTH(BEGIN, POINTER) ((int)(direction * ((POINTER) - (BEGIN))))
#define DYNAMIC_MACRO_CURRENT_CAPACITY(BEGIN, END2) ((int)(direction * ((END2) - (BEGIN)) + 1))
+#ifdef DYNAMIC_MACRO_KEEP_ORIGINAL_LAYER_STATE
+static layer_state_t dm1_layer_state;
+static layer_state_t dm2_layer_state;
+#endif
+
/**
* Start recording of the dynamic macro.
*
@@ -100,8 +105,16 @@ void dynamic_macro_record_start(keyrecord_t **macro_pointer, keyrecord_t *macro_
dynamic_macro_record_start_kb(direction);
- clear_keyboard();
+#ifdef DYNAMIC_MACRO_KEEP_ORIGINAL_LAYER_STATE
+ if (direction == 1) {
+ dm1_layer_state = layer_state;
+ } else if (direction == -1) {
+ dm2_layer_state = layer_state;
+ }
+#else
layer_clear();
+#endif
+ clear_keyboard();
*macro_pointer = macro_buffer;
}
@@ -118,7 +131,15 @@ void dynamic_macro_play(keyrecord_t *macro_buffer, keyrecord_t *macro_end, int8_
layer_state_t saved_layer_state = layer_state;
clear_keyboard();
+#ifdef DYNAMIC_MACRO_KEEP_ORIGINAL_LAYER_STATE
+ if (direction == 1) {
+ layer_state_set(dm1_layer_state);
+ } else if (direction == -1) {
+ layer_state_set(dm2_layer_state);
+ }
+#else
layer_clear();
+#endif
while (macro_buffer != macro_end) {
process_record(macro_buffer);
diff --git a/quantum/process_keycode/process_led_matrix.c b/quantum/process_keycode/process_led_matrix.c
index 7f95bf1011..3342b33b92 100644
--- a/quantum/process_keycode/process_led_matrix.c
+++ b/quantum/process_keycode/process_led_matrix.c
@@ -40,6 +40,12 @@ bool process_led_matrix(uint16_t keycode, keyrecord_t *record) {
case QK_LED_MATRIX_SPEED_DOWN:
led_matrix_decrease_speed();
return false;
+ case QK_LED_MATRIX_FLAG_NEXT:
+ led_matrix_flags_step();
+ return false;
+ case QK_LED_MATRIX_FLAG_PREVIOUS:
+ led_matrix_flags_step_reverse();
+ return false;
}
}
diff --git a/quantum/process_keycode/process_rgb_matrix.c b/quantum/process_keycode/process_rgb_matrix.c
index fd2aa1a0c7..c18212294d 100644
--- a/quantum/process_keycode/process_rgb_matrix.c
+++ b/quantum/process_keycode/process_rgb_matrix.c
@@ -94,6 +94,20 @@ bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
rgb_matrix_decrease_speed();
}
return false;
+ case QK_RGB_MATRIX_FLAG_NEXT:
+ if (shifted) {
+ rgb_matrix_flags_step_reverse();
+ } else {
+ rgb_matrix_flags_step();
+ }
+ return false;
+ case QK_RGB_MATRIX_FLAG_PREVIOUS:
+ if (shifted) {
+ rgb_matrix_flags_step();
+ } else {
+ rgb_matrix_flags_step_reverse();
+ }
+ return false;
}
}