diff options
| author | zvecr | 2025-12-01 23:07:33 +0100 |
|---|---|---|
| committer | zvecr | 2025-12-01 23:07:33 +0100 |
| commit | b315b707e60f86d79d34bcb7a15084468117c1a1 (patch) | |
| tree | 7bbdc5f5d703c28310b4751dd3db280d8f55a6bd /quantum/process_keycode/process_dynamic_macro.c | |
| parent | e2bf515df4c51c4d2e3b442d23e52d6d43f7f726 (diff) | |
| parent | e10429baae2a4b3ffec67fe31a5e1ac3212817f0 (diff) | |
Merge branch 'develop'
Diffstat (limited to 'quantum/process_keycode/process_dynamic_macro.c')
| -rw-r--r-- | quantum/process_keycode/process_dynamic_macro.c | 23 |
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 #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); |