summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/process_keycode/process_dynamic_macro.c23
1 files changed, 22 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
89#define DYNAMIC_MACRO_CURRENT_LENGTH(BEGIN, POINTER) ((int)(direction * ((POINTER) - (BEGIN)))) 89#define DYNAMIC_MACRO_CURRENT_LENGTH(BEGIN, POINTER) ((int)(direction * ((POINTER) - (BEGIN))))
90#define DYNAMIC_MACRO_CURRENT_CAPACITY(BEGIN, END2) ((int)(direction * ((END2) - (BEGIN)) + 1)) 90#define DYNAMIC_MACRO_CURRENT_CAPACITY(BEGIN, END2) ((int)(direction * ((END2) - (BEGIN)) + 1))
91 91
92#ifdef DYNAMIC_MACRO_KEEP_ORIGINAL_LAYER_STATE
93static layer_state_t dm1_layer_state;
94static layer_state_t dm2_layer_state;
95#endif
96
92/** 97/**
93 * Start recording of the dynamic macro. 98 * Start recording of the dynamic macro.
94 * 99 *
@@ -100,8 +105,16 @@ void dynamic_macro_record_start(keyrecord_t **macro_pointer, keyrecord_t *macro_
100 105
101 dynamic_macro_record_start_kb(direction); 106 dynamic_macro_record_start_kb(direction);
102 107
103 clear_keyboard(); 108#ifdef DYNAMIC_MACRO_KEEP_ORIGINAL_LAYER_STATE
109 if (direction == 1) {
110 dm1_layer_state = layer_state;
111 } else if (direction == -1) {
112 dm2_layer_state = layer_state;
113 }
114#else
104 layer_clear(); 115 layer_clear();
116#endif
117 clear_keyboard();
105 *macro_pointer = macro_buffer; 118 *macro_pointer = macro_buffer;
106} 119}
107 120
@@ -118,7 +131,15 @@ void dynamic_macro_play(keyrecord_t *macro_buffer, keyrecord_t *macro_end, int8_
118 layer_state_t saved_layer_state = layer_state; 131 layer_state_t saved_layer_state = layer_state;
119 132
120 clear_keyboard(); 133 clear_keyboard();
134#ifdef DYNAMIC_MACRO_KEEP_ORIGINAL_LAYER_STATE
135 if (direction == 1) {
136 layer_state_set(dm1_layer_state);
137 } else if (direction == -1) {
138 layer_state_set(dm2_layer_state);
139 }
140#else
121 layer_clear(); 141 layer_clear();
142#endif
122 143
123 while (macro_buffer != macro_end) { 144 while (macro_buffer != macro_end) {
124 process_record(macro_buffer); 145 process_record(macro_buffer);