Add DYN_REC_STOP to dynamic macros

Dynamic macro functionality is modified to check for `DYN_REC_STOP`, so
that macro recording can be stopped with a designated key combination
(e.g. `qs` or anything) instead of mandating the use of a `_DYN` layer.

`_DYN` layer stopping can still be done by passing `DYN_REC_STOP` within
`process_record_user()`:

    bool process_record_user(uint16_t keycode, keyrecord_t *record) {
      uint16_t macro_kc = (keycode == MO(_DYN) ? DYN_REC_STOP : keycode);
      if (!process_record_dynamic_macro(macro_kc, record)) {
        return false;
      }
      return true;
    }
This commit is contained in:
Weiyi Lou 2017-04-29 22:02:01 +10:00
parent 26bbfd7812
commit 4ff40a551a

View file

@ -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,
};
@ -209,9 +210,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. */