[Core] Convert Dynamic Macro to a Core Feature (#5948)

* Convert Dynamic Macro to a Core Feature

This imports the code from Dynamic Macro into the core code, and handles it, as such.

This deprecates the old method but does not remove it, for legacy support. This way, no existing user files need to be touched.

Additionally, this reorganizes the documentation to better reflect the changes.

Also, it adds user hooks to the feature so users can customize the existing functionality.

Based heavily on and closes #2976

* Apply suggestions from code review

Co-Authored-By: fauxpark <fauxpark@gmail.com>
Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com>

* Cleanup based on feedback

* Add short-form keycodes and document them

- add short-form keycodes to quantum/quantum_keycodes.h
- document the new aliases in docs/feature_dynamic_macros.md

* Add Dynamic Macros section and keycodes to docs/keycodes.md

* Make anti-nesting optional

* Add documentation for DYNAMIC_MACRO_NO_NESTING option

* Fix Merge artifacts

* Fix formatting typo in docs

Co-Authored-By: James Young <18669334+noroadsleft@users.noreply.github.com>

* Remove DYNAMIC_MACRO_RANGE as it's not needed

* Fix includes and layer var type
This commit is contained in:
Drashna Jaelre
2019-11-04 22:59:13 -08:00
committed by James Young
parent 0e664f92c4
commit 542cb0a8ce
9 changed files with 384 additions and 59 deletions

View File

@ -26,7 +26,7 @@
#ifdef BACKLIGHT_ENABLE
# include "backlight.h"
extern backlight_config_t backlight_config;
extern backlight_config_t backlight_config;
#endif
#ifdef FAUXCLICKY_ENABLE
@ -89,7 +89,7 @@ static void do_code16(uint16_t code, void (*f)(uint8_t)) {
uint8_t mods_to_send = 0;
if (code & QK_RMODS_MIN) { // Right mod flag is set
if (code & QK_RMODS_MIN) { // Right mod flag is set
if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RCTL);
if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RSFT);
if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RALT);
@ -222,6 +222,10 @@ bool process_record_quantum(keyrecord_t *record) {
// Must run first to be able to mask key_up events.
process_key_lock(&keycode, record) &&
#endif
#if defined(DYNAMIC_MACRO_ENABLE) && !defined(DYNAMIC_MACRO_USER_CALL)
// Must run asap to ensure all keypresses are recorded.
process_dynamic_macro(keycode, record) &&
#endif
#if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY)
process_clicky(keycode, record) &&
#endif // AUDIO_CLICKY
@ -563,7 +567,7 @@ bool process_record_quantum(keyrecord_t *record) {
keymap_config.swap_backslash_backspace = true;
break;
case MAGIC_HOST_NKRO:
clear_keyboard(); // clear first buffer to prevent stuck keys
clear_keyboard(); // clear first buffer to prevent stuck keys
keymap_config.nkro = true;
break;
case MAGIC_SWAP_ALT_GUI:
@ -606,7 +610,7 @@ bool process_record_quantum(keyrecord_t *record) {
keymap_config.swap_backslash_backspace = false;
break;
case MAGIC_UNHOST_NKRO:
clear_keyboard(); // clear first buffer to prevent stuck keys
clear_keyboard(); // clear first buffer to prevent stuck keys
keymap_config.nkro = false;
break;
case MAGIC_UNSWAP_ALT_GUI:
@ -644,7 +648,7 @@ bool process_record_quantum(keyrecord_t *record) {
#endif
break;
case MAGIC_TOGGLE_NKRO:
clear_keyboard(); // clear first buffer to prevent stuck keys
clear_keyboard(); // clear first buffer to prevent stuck keys
keymap_config.nkro = !keymap_config.nkro;
break;
case MAGIC_EE_HANDS_LEFT: