diff options
author | Adam Lee <adam@bigtuna.io> | 2017-05-07 23:36:10 +0200 |
---|---|---|
committer | Adam Lee <adam@bigtuna.io> | 2017-05-07 23:36:10 +0200 |
commit | f2fcab96a8dd8cc70d6785da76621c48df1af94c (patch) | |
tree | 9be0967ab0d3795e6d20299988c84280f3ad98f6 /quantum/dynamic_macro.h | |
parent | f90321bdcbcbd196ee642cdd8cc31aa0f6ac121e (diff) | |
parent | 2704c163da590d3020f6d87717c400611de81110 (diff) | |
download | qmk_firmware-f2fcab96a8dd8cc70d6785da76621c48df1af94c.tar.gz qmk_firmware-f2fcab96a8dd8cc70d6785da76621c48df1af94c.tar.xz |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'quantum/dynamic_macro.h')
-rw-r--r-- | quantum/dynamic_macro.h | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/quantum/dynamic_macro.h b/quantum/dynamic_macro.h index 64093f293..9e7845c99 100644 --- a/quantum/dynamic_macro.h +++ b/quantum/dynamic_macro.h @@ -40,6 +40,7 @@ enum dynamic_macro_keycodes { DYN_REC_START1 = DYNAMIC_MACRO_RANGE, DYN_REC_START2, + DYN_REC_STOP, DYN_MACRO_PLAY1, DYN_MACRO_PLAY2, }; @@ -96,24 +97,29 @@ void dynamic_macro_play( /** * Record a single key in a dynamic macro. * + * @param macro_buffer[in] The start of the used macro buffer. * @param macro_pointer[in,out] The current buffer position. - * @param macro_end2[in] The end of the other macro which shouldn't be overwritten. + * @param macro2_end[in] The last buffer element it is safe to use before overwriting the other macro. * @param direction[in] Either +1 or -1, which way to iterate the buffer. * @param record[in] The current keypress. */ void dynamic_macro_record_key( + keyrecord_t *macro_buffer, keyrecord_t **macro_pointer, - keyrecord_t *macro_end2, + keyrecord_t *macro2_end, int8_t direction, keyrecord_t *record) { - if (*macro_pointer + direction != macro_end2) { + /* If we've just started recording, ignore all the key releases. */ + if (!record->event.pressed && *macro_pointer == macro_buffer) { + return; + } + + if (*macro_pointer - direction != macro2_end) { **macro_pointer = *record; *macro_pointer += direction; } else { - /* Notify about the end of buffer. The blinks are paired - * because they should happen on both down and up events. */ - backlight_toggle(); + dynamic_macro_led_blink(); } } @@ -209,9 +215,8 @@ bool process_record_dynamic_macro(uint16_t keycode, keyrecord_t *record) } else { /* A macro is being recorded right now. */ switch (keycode) { - case MO(_DYN): - /* Use the layer key used to access the macro recording as - * a stop button. */ + case DYN_REC_STOP: + /* Stop the macro recording. */ if (record->event.pressed) { /* Ignore the initial release * just after the recoding * starts. */ @@ -230,10 +235,10 @@ bool process_record_dynamic_macro(uint16_t keycode, keyrecord_t *record) /* Store the key in the macro buffer and process it normally. */ switch (macro_id) { case 1: - dynamic_macro_record_key(¯o_pointer, r_macro_end, +1, record); + dynamic_macro_record_key(macro_buffer, ¯o_pointer, r_macro_end, +1, record); break; case 2: - dynamic_macro_record_key(¯o_pointer, macro_end, -1, record); + dynamic_macro_record_key(r_macro_buffer, ¯o_pointer, macro_end, -1, record); break; } return true; |