From eee0384167b965c60120e1222bc24c0b40cadac4 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 11 Jul 2023 17:07:24 +1000 Subject: [PATCH] process_keycode: remove direct `quantum.h` includes (#21486) --- quantum/action_layer.h | 1 + quantum/midi/qmk_midi.c | 4 + quantum/process_keycode/process_audio.h | 4 + quantum/process_keycode/process_auto_shift.c | 167 +++++++++--------- quantum/process_keycode/process_auto_shift.h | 6 +- quantum/process_keycode/process_autocorrect.c | 4 + quantum/process_keycode/process_autocorrect.h | 4 +- quantum/process_keycode/process_backlight.h | 4 +- quantum/process_keycode/process_caps_word.c | 8 + quantum/process_keycode/process_caps_word.h | 5 +- quantum/process_keycode/process_clicky.h | 4 + quantum/process_keycode/process_combo.c | 11 +- quantum/process_keycode/process_combo.h | 6 +- .../process_keycode/process_dynamic_macro.c | 9 + .../process_keycode/process_dynamic_macro.h | 4 +- .../process_dynamic_tapping_term.c | 4 +- .../process_dynamic_tapping_term.h | 1 + quantum/process_keycode/process_grave_esc.c | 3 + quantum/process_keycode/process_grave_esc.h | 4 +- quantum/process_keycode/process_haptic.h | 1 + quantum/process_keycode/process_joystick.h | 3 +- quantum/process_keycode/process_key_lock.h | 4 +- .../process_keycode/process_key_override.c | 6 +- .../process_keycode/process_key_override.h | 3 +- quantum/process_keycode/process_leader.c | 1 + quantum/process_keycode/process_leader.h | 4 +- quantum/process_keycode/process_magic.c | 5 + quantum/process_keycode/process_magic.h | 4 +- quantum/process_keycode/process_midi.c | 26 ++- quantum/process_keycode/process_midi.h | 5 +- quantum/process_keycode/process_music.c | 2 + quantum/process_keycode/process_music.h | 4 +- .../process_programmable_button.h | 3 +- quantum/process_keycode/process_repeat_key.c | 4 + quantum/process_keycode/process_repeat_key.h | 4 +- quantum/process_keycode/process_rgb.c | 8 + quantum/process_keycode/process_rgb.h | 4 +- quantum/process_keycode/process_secure.h | 1 + quantum/process_keycode/process_sequencer.h | 4 +- quantum/process_keycode/process_space_cadet.c | 2 + quantum/process_keycode/process_space_cadet.h | 4 +- quantum/process_keycode/process_steno.c | 1 + quantum/process_keycode/process_steno.h | 4 +- quantum/process_keycode/process_tap_dance.c | 7 + quantum/process_keycode/process_tap_dance.h | 43 ++--- quantum/process_keycode/process_tri_layer.h | 2 + 46 files changed, 257 insertions(+), 155 deletions(-) diff --git a/quantum/action_layer.h b/quantum/action_layer.h index ff783bb3e7..a2410d49a5 100644 --- a/quantum/action_layer.h +++ b/quantum/action_layer.h @@ -20,6 +20,7 @@ along with this program. If not, see . #include #include "keyboard.h" #include "action.h" +#include "bitwise.h" #ifdef DYNAMIC_KEYMAP_ENABLE # ifndef DYNAMIC_KEYMAP_LAYER_COUNT diff --git a/quantum/midi/qmk_midi.c b/quantum/midi/qmk_midi.c index f6a5d92281..688259784c 100644 --- a/quantum/midi/qmk_midi.c +++ b/quantum/midi/qmk_midi.c @@ -5,6 +5,10 @@ #include "usb_descriptor.h" #include "process_midi.h" +#ifdef AUDIO_ENABLE +# include "audio.h" +#endif + /******************************************************************************* * MIDI ******************************************************************************/ diff --git a/quantum/process_keycode/process_audio.h b/quantum/process_keycode/process_audio.h index 42cfab4af2..c80136f2c2 100644 --- a/quantum/process_keycode/process_audio.h +++ b/quantum/process_keycode/process_audio.h @@ -1,5 +1,9 @@ #pragma once +#include +#include +#include "action.h" + float compute_freq_for_midi_note(uint8_t note); bool process_audio(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 63e893fc18..9b78214e43 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -14,27 +14,28 @@ * along with this program. If not, see . */ -#ifdef AUTO_SHIFT_ENABLE +#include "process_auto_shift.h" +#include "quantum.h" +#include "action_util.h" +#include "timer.h" +#include "keycodes.h" -# include -# include "process_auto_shift.h" - -# ifndef AUTO_SHIFT_DISABLED_AT_STARTUP -# define AUTO_SHIFT_STARTUP_STATE true /* enabled */ -# else -# define AUTO_SHIFT_STARTUP_STATE false /* disabled */ -# endif +#ifndef AUTO_SHIFT_DISABLED_AT_STARTUP +# define AUTO_SHIFT_STARTUP_STATE true /* enabled */ +#else +# define AUTO_SHIFT_STARTUP_STATE false /* disabled */ +#endif // Stores the last Auto Shift key's up or down time, for evaluation or keyrepeat. static uint16_t autoshift_time = 0; -# if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING) +#if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING) // Stores the last key's up or down time, to replace autoshift_time so that Tap Hold times are accurate. static uint16_t retroshift_time = 0; // Stores a possibly Retro Shift key's up or down time, as retroshift_time needs // to be set before the Retro Shift key is evaluated if it is interrupted by an // Auto Shifted key. static uint16_t last_retroshift_time; -# endif +#endif static uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT; static uint16_t autoshift_lastkey = KC_NO; static keyrecord_t autoshift_lastrecord; @@ -68,23 +69,23 @@ __attribute__((weak)) bool get_custom_auto_shifted_key(uint16_t keycode, keyreco /** \brief Called on physical press, returns whether is Auto Shift key */ __attribute__((weak)) bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { switch (keycode) { -# ifndef NO_AUTO_SHIFT_ALPHA +#ifndef NO_AUTO_SHIFT_ALPHA case AUTO_SHIFT_ALPHA: -# endif -# ifndef NO_AUTO_SHIFT_NUMERIC +#endif +#ifndef NO_AUTO_SHIFT_NUMERIC case AUTO_SHIFT_NUMERIC: -# endif -# ifndef NO_AUTO_SHIFT_SPECIAL -# ifndef NO_AUTO_SHIFT_TAB +#endif +#ifndef NO_AUTO_SHIFT_SPECIAL +# ifndef NO_AUTO_SHIFT_TAB case KC_TAB: -# endif -# ifndef NO_AUTO_SHIFT_SYMBOLS +# endif +# ifndef NO_AUTO_SHIFT_SYMBOLS case AUTO_SHIFT_SYMBOLS: -# endif # endif -# ifdef AUTO_SHIFT_ENTER +#endif +#ifdef AUTO_SHIFT_ENTER case KC_ENT: -# endif +#endif return true; } return get_custom_auto_shifted_key(keycode, record); @@ -130,9 +131,9 @@ bool get_autoshift_shift_state(uint16_t keycode) { /** \brief Restores the shift key if it was cancelled by Auto Shift */ static void autoshift_flush_shift(void) { autoshift_flags.holding_shift = false; -# ifdef CAPS_WORD_ENABLE +#ifdef CAPS_WORD_ENABLE if (!is_caps_word_on()) -# endif // CAPS_WORD_ENABLE +#endif // CAPS_WORD_ENABLE { del_weak_mods(MOD_BIT(KC_LSFT)); } @@ -154,26 +155,26 @@ static void autoshift_flush_shift(void) { static bool autoshift_press(uint16_t keycode, uint16_t now, keyrecord_t *record) { // clang-format off if ((get_mods() -# if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING) +#if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING) | get_oneshot_mods() -# endif +#endif ) & (~MOD_BIT(KC_LSFT)) ) { // clang-format on // Prevents keyrepeating unshifted value of key after using it in a key combo. autoshift_lastkey = KC_NO; -# ifndef AUTO_SHIFT_MODIFIERS +#ifndef AUTO_SHIFT_MODIFIERS // We can't return true here anymore because custom unshifted values are // possible and there's no good way to tell whether the press returned // true upon release. set_autoshift_shift_state(keycode, false); autoshift_press_user(keycode, false, record); -# if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING) +# if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING) set_oneshot_mods(get_oneshot_mods() & (~MOD_BIT(KC_LSFT))); clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); -# endif - return false; # endif + return false; +#endif } // Store record to be sent to user functions if there's no release record then. @@ -181,19 +182,19 @@ static bool autoshift_press(uint16_t keycode, uint16_t now, keyrecord_t *record) autoshift_lastrecord.event.pressed = false; autoshift_lastrecord.event.time = 0; // clang-format off -# if defined(AUTO_SHIFT_REPEAT) || defined(AUTO_SHIFT_REPEAT_PER_KEY) +#if defined(AUTO_SHIFT_REPEAT) || defined(AUTO_SHIFT_REPEAT_PER_KEY) if (keycode == autoshift_lastkey && -# ifdef AUTO_SHIFT_REPEAT_PER_KEY +# ifdef AUTO_SHIFT_REPEAT_PER_KEY get_auto_shift_repeat(autoshift_lastkey, record) && -# endif -# if !defined(AUTO_SHIFT_NO_AUTO_REPEAT) || defined(AUTO_SHIFT_NO_AUTO_REPEAT_PER_KEY) +# endif +# if !defined(AUTO_SHIFT_NO_AUTO_REPEAT) || defined(AUTO_SHIFT_NO_AUTO_REPEAT_PER_KEY) ( !autoshift_flags.lastshifted -# ifdef AUTO_SHIFT_NO_AUTO_REPEAT_PER_KEY +# ifdef AUTO_SHIFT_NO_AUTO_REPEAT_PER_KEY || get_auto_shift_no_auto_repeat(autoshift_lastkey, record) -# endif - ) && # endif + ) && +# endif TIMER_DIFF_16(now, autoshift_time) < GET_TAPPING_TERM(autoshift_lastkey, record) ) { // clang-format on @@ -210,23 +211,23 @@ static bool autoshift_press(uint16_t keycode, uint16_t now, keyrecord_t *record) autoshift_press_user(autoshift_lastkey, autoshift_flags.lastshifted, record); return false; } -# endif +#endif // Use physical shift state of press event to be more like normal typing. -# if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING) +#if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING) autoshift_flags.lastshifted = (get_mods() | get_oneshot_mods()) & MOD_BIT(KC_LSFT); set_oneshot_mods(get_oneshot_mods() & (~MOD_BIT(KC_LSFT))); -# else +#else autoshift_flags.lastshifted = get_mods() & MOD_BIT(KC_LSFT); -# endif +#endif // Record the keycode so we can simulate it later. autoshift_lastkey = keycode; autoshift_time = now; autoshift_flags.in_progress = true; -# if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING) +#if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING) clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); -# endif +#endif return false; } @@ -247,11 +248,11 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger, k autoshift_flags.lastshifted = autoshift_flags.lastshifted || TIMER_DIFF_16(now, autoshift_time) >= -# ifdef AUTO_SHIFT_TIMEOUT_PER_KEY +#ifdef AUTO_SHIFT_TIMEOUT_PER_KEY get_autoshift_timeout(autoshift_lastkey, record) -# else +#else autoshift_timeout -# endif +#endif ; // clang-format on set_autoshift_shift_state(autoshift_lastkey, autoshift_flags.lastshifted); @@ -266,23 +267,23 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger, k autoshift_press_user(autoshift_lastkey, autoshift_flags.lastshifted, record); // clang-format off -# if (defined(AUTO_SHIFT_REPEAT) || defined(AUTO_SHIFT_REPEAT_PER_KEY)) && (!defined(AUTO_SHIFT_NO_AUTO_REPEAT) || defined(AUTO_SHIFT_NO_AUTO_REPEAT_PER_KEY)) +#if (defined(AUTO_SHIFT_REPEAT) || defined(AUTO_SHIFT_REPEAT_PER_KEY)) && (!defined(AUTO_SHIFT_NO_AUTO_REPEAT) || defined(AUTO_SHIFT_NO_AUTO_REPEAT_PER_KEY)) if (matrix_trigger -# ifdef AUTO_SHIFT_REPEAT_PER_KEY +# ifdef AUTO_SHIFT_REPEAT_PER_KEY && get_auto_shift_repeat(autoshift_lastkey, record) -# endif -# ifdef AUTO_SHIFT_NO_AUTO_REPEAT_PER_KEY +# endif +# ifdef AUTO_SHIFT_NO_AUTO_REPEAT_PER_KEY && !get_auto_shift_no_auto_repeat(autoshift_lastkey, record) -# endif +# endif ) { // Prevents release. return; } -# endif +#endif // clang-format on -# if TAP_CODE_DELAY > 0 +#if TAP_CODE_DELAY > 0 wait_ms(TAP_CODE_DELAY); -# endif +#endif autoshift_release_user(autoshift_lastkey, autoshift_flags.lastshifted, record); autoshift_flush_shift(); @@ -310,11 +311,11 @@ void autoshift_matrix_scan(void) { if (autoshift_flags.in_progress) { const uint16_t now = timer_read(); if (TIMER_DIFF_16(now, autoshift_time) >= -# ifdef AUTO_SHIFT_TIMEOUT_PER_KEY +#ifdef AUTO_SHIFT_TIMEOUT_PER_KEY get_autoshift_timeout(autoshift_lastkey, &autoshift_lastrecord) -# else +#else autoshift_timeout -# endif +#endif ) { autoshift_end(autoshift_lastkey, now, true, &autoshift_lastrecord); } @@ -335,18 +336,18 @@ void autoshift_disable(void) { autoshift_flush_shift(); } -# ifndef AUTO_SHIFT_NO_SETUP +#ifndef AUTO_SHIFT_NO_SETUP void autoshift_timer_report(void) { -# ifdef SEND_STRING_ENABLE +# ifdef SEND_STRING_ENABLE const char *autoshift_timeout_str = get_u16_str(autoshift_timeout, ' '); // Skip padding spaces while (*autoshift_timeout_str == ' ') { autoshift_timeout_str++; } send_string(autoshift_timeout_str); -# endif -} # endif +} +#endif bool get_autoshift_state(void) { return autoshift_flags.enabled; @@ -368,11 +369,11 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { // https://github.com/qmk/qmk_firmware/pull/9826#issuecomment-733559550 // clang-format off const uint16_t now = -# if !defined(RETRO_SHIFT) || defined(NO_ACTION_TAPPING) +#if !defined(RETRO_SHIFT) || defined(NO_ACTION_TAPPING) timer_read() -# else +#else (record->event.pressed) ? retroshift_time : timer_read() -# endif +#endif ; // clang-format on @@ -393,7 +394,7 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { autoshift_disable(); break; -# ifndef AUTO_SHIFT_NO_SETUP +#ifndef AUTO_SHIFT_NO_SETUP case AS_UP: autoshift_timeout += 5; break; @@ -403,27 +404,27 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { case AS_RPT: autoshift_timer_report(); break; -# endif +#endif } // If Retro Shift is disabled, possible custom actions shouldn't happen. // clang-format off -# if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING) -# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY +#if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING) +# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY const bool is_hold_on_interrupt = get_hold_on_other_key_press(keycode, record); -# else +# else const bool is_hold_on_interrupt = false; -# endif -# endif +# endif +#endif if (IS_RETRO(keycode) -# if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING) +#if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING) // Not tapped or #defines mean that rolls should use hold action. && ( record->tap.count == 0 -# ifdef RETRO_TAPPING_PER_KEY +# ifdef RETRO_TAPPING_PER_KEY || !get_retro_tapping(keycode, record) -# endif - || (record->tap.interrupted && is_hold_on_interrupt)) # endif + || (record->tap.interrupted && is_hold_on_interrupt)) +#endif ) { // clang-format on autoshift_lastkey = KC_NO; @@ -439,21 +440,21 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { // tap.count gets set to 0 in process_action // clang-format off else if (IS_RETRO(keycode) -# if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING) +#if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING) && ( record->tap.count == 0 -# ifdef RETRO_TAPPING_PER_KEY +# ifdef RETRO_TAPPING_PER_KEY || !get_retro_tapping(keycode, record) -# endif - ) # endif + ) +#endif ) { // Fixes modifiers not being applied to rolls with AUTO_SHIFT_MODIFIERS set. -# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY +#ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY if (autoshift_flags.in_progress && get_hold_on_other_key_press(keycode, record)) { autoshift_end(KC_NO, now, false, &autoshift_lastrecord); } -# endif +#endif // clang-format on return true; } @@ -479,7 +480,7 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { return true; } -# if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING) +#if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING) // Called to record time before possible delays by action_tapping_process. void retroshift_poll_time(keyevent_t *event) { last_retroshift_time = retroshift_time; @@ -493,6 +494,4 @@ void retroshift_swap_times(void) { last_retroshift_time = temp; } } -# endif - #endif diff --git a/quantum/process_keycode/process_auto_shift.h b/quantum/process_keycode/process_auto_shift.h index 780177d2ff..885a47b533 100644 --- a/quantum/process_keycode/process_auto_shift.h +++ b/quantum/process_keycode/process_auto_shift.h @@ -16,7 +16,11 @@ #pragma once -#include "quantum.h" +#include +#include +#include "action.h" +#include "keyboard.h" +#include "keycodes.h" #ifndef AUTO_SHIFT_TIMEOUT # define AUTO_SHIFT_TIMEOUT 175 diff --git a/quantum/process_keycode/process_autocorrect.c b/quantum/process_keycode/process_autocorrect.c index cc1f19e4f9..edc47718f3 100644 --- a/quantum/process_keycode/process_autocorrect.c +++ b/quantum/process_keycode/process_autocorrect.c @@ -6,7 +6,11 @@ #include "process_autocorrect.h" #include +#include "keycodes.h" +#include "quantum_keycodes.h" #include "keycode_config.h" +#include "send_string.h" +#include "action_util.h" #if __has_include("autocorrect_data.h") # include "autocorrect_data.h" diff --git a/quantum/process_keycode/process_autocorrect.h b/quantum/process_keycode/process_autocorrect.h index 9cc7d46a8b..ea77d6f56f 100644 --- a/quantum/process_keycode/process_autocorrect.h +++ b/quantum/process_keycode/process_autocorrect.h @@ -6,7 +6,9 @@ #pragma once -#include "quantum.h" +#include +#include +#include "action.h" bool process_autocorrect(uint16_t keycode, keyrecord_t *record); bool process_autocorrect_user(uint16_t *keycode, keyrecord_t *record, uint8_t *typo_buffer_size, uint8_t *mods); diff --git a/quantum/process_keycode/process_backlight.h b/quantum/process_keycode/process_backlight.h index 7fe887ae67..e926833e79 100644 --- a/quantum/process_keycode/process_backlight.h +++ b/quantum/process_keycode/process_backlight.h @@ -16,6 +16,8 @@ #pragma once -#include "quantum.h" +#include +#include +#include "action.h" bool process_backlight(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/process_keycode/process_caps_word.c b/quantum/process_keycode/process_caps_word.c index d4382680bf..1088c8f76c 100644 --- a/quantum/process_keycode/process_caps_word.c +++ b/quantum/process_keycode/process_caps_word.c @@ -13,6 +13,14 @@ // limitations under the License. #include "process_caps_word.h" +#include "process_auto_shift.h" +#include "caps_word.h" +#include "keycodes.h" +#include "quantum_keycodes.h" +#include "modifiers.h" +#include "timer.h" +#include "action_tapping.h" +#include "action_util.h" #ifdef CAPS_WORD_INVERT_ON_SHIFT static uint8_t held_mods = 0; diff --git a/quantum/process_keycode/process_caps_word.h b/quantum/process_keycode/process_caps_word.h index f215bbc3a3..f5eb140d32 100644 --- a/quantum/process_keycode/process_caps_word.h +++ b/quantum/process_keycode/process_caps_word.h @@ -14,8 +14,9 @@ #pragma once -#include "quantum.h" -#include "caps_word.h" +#include +#include +#include "action.h" /** * @brief Process handler for Caps Word feature. diff --git a/quantum/process_keycode/process_clicky.h b/quantum/process_keycode/process_clicky.h index 67b6463c5d..dfdba14131 100644 --- a/quantum/process_keycode/process_clicky.h +++ b/quantum/process_keycode/process_clicky.h @@ -1,5 +1,9 @@ #pragma once +#include +#include +#include "action.h" + void clicky_play(void); bool process_clicky(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index bbee560be9..0d4f4f3dba 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c @@ -14,11 +14,16 @@ * along with this program. If not, see . */ -#include "keymap_common.h" -#include "print.h" #include "process_combo.h" +#include +#include "process_auto_shift.h" +#include "caps_word.h" +#include "timer.h" +#include "keyboard.h" +#include "keymap_common.h" +#include "action_layer.h" #include "action_tapping.h" -#include "action.h" +#include "action_util.h" #include "keymap_introspection.h" __attribute__((weak)) void process_combo_event(uint16_t combo_index, bool pressed) {} diff --git a/quantum/process_keycode/process_combo.h b/quantum/process_keycode/process_combo.h index bba5d5ee63..f1d534236e 100644 --- a/quantum/process_keycode/process_combo.h +++ b/quantum/process_keycode/process_combo.h @@ -16,9 +16,11 @@ #pragma once -#include "progmem.h" -#include "quantum.h" #include +#include +#include "action.h" +#include "keycodes.h" +#include "quantum_keycodes.h" #ifdef EXTRA_SHORT_COMBOS # define MAX_COMBO_LENGTH 6 diff --git a/quantum/process_keycode/process_dynamic_macro.c b/quantum/process_keycode/process_dynamic_macro.c index a022949d3d..5e4a6fa308 100644 --- a/quantum/process_keycode/process_dynamic_macro.c +++ b/quantum/process_keycode/process_dynamic_macro.c @@ -17,6 +17,15 @@ /* Author: Wojciech Siewierski < wojciech dot siewierski at onet dot pl > */ #include "process_dynamic_macro.h" +#include +#include "action_layer.h" +#include "keycodes.h" +#include "debug.h" +#include "wait.h" + +#ifdef BACKLIGHT_ENABLE +# include "backlight.h" +#endif // default feedback method void dynamic_macro_led_blink(void) { diff --git a/quantum/process_keycode/process_dynamic_macro.h b/quantum/process_keycode/process_dynamic_macro.h index 9841254af4..2f10733cae 100644 --- a/quantum/process_keycode/process_dynamic_macro.h +++ b/quantum/process_keycode/process_dynamic_macro.h @@ -18,7 +18,9 @@ /* Author: Wojciech Siewierski < wojciech dot siewierski at onet dot pl > */ #pragma once -#include "quantum.h" +#include +#include +#include "action.h" /* May be overridden with a custom value. Be aware that the effective * macro length is half of this value: each keypress is recorded twice diff --git a/quantum/process_keycode/process_dynamic_tapping_term.c b/quantum/process_keycode/process_dynamic_tapping_term.c index 146b9fccd7..cf52626e42 100644 --- a/quantum/process_keycode/process_dynamic_tapping_term.c +++ b/quantum/process_keycode/process_dynamic_tapping_term.c @@ -14,8 +14,10 @@ * along with this program. If not, see . */ -#include "quantum.h" #include "process_dynamic_tapping_term.h" +#include "quantum.h" +#include "keycodes.h" +#include "send_string.h" #ifndef DYNAMIC_TAPPING_TERM_INCREMENT # define DYNAMIC_TAPPING_TERM_INCREMENT 5 diff --git a/quantum/process_keycode/process_dynamic_tapping_term.h b/quantum/process_keycode/process_dynamic_tapping_term.h index 85e83ee73b..fee29e18df 100644 --- a/quantum/process_keycode/process_dynamic_tapping_term.h +++ b/quantum/process_keycode/process_dynamic_tapping_term.h @@ -16,6 +16,7 @@ #pragma once +#include #include #include "action.h" diff --git a/quantum/process_keycode/process_grave_esc.c b/quantum/process_keycode/process_grave_esc.c index ddf027391d..d786f57a80 100644 --- a/quantum/process_keycode/process_grave_esc.c +++ b/quantum/process_keycode/process_grave_esc.c @@ -14,6 +14,9 @@ * along with this program. If not, see . */ #include "process_grave_esc.h" +#include "keycodes.h" +#include "modifiers.h" +#include "action_util.h" /* true if the last press of QK_GRAVE_ESCAPE was shifted (i.e. GUI or SHIFT were pressed), false otherwise. * Used to ensure that the correct keycode is released if the key is released. diff --git a/quantum/process_keycode/process_grave_esc.h b/quantum/process_keycode/process_grave_esc.h index bbf4483763..358ff3c4e7 100644 --- a/quantum/process_keycode/process_grave_esc.h +++ b/quantum/process_keycode/process_grave_esc.h @@ -15,6 +15,8 @@ */ #pragma once -#include "quantum.h" +#include +#include +#include "action.h" bool process_grave_esc(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/process_keycode/process_haptic.h b/quantum/process_keycode/process_haptic.h index 6dbb0f014d..7e61f6c0d6 100644 --- a/quantum/process_keycode/process_haptic.h +++ b/quantum/process_keycode/process_haptic.h @@ -15,6 +15,7 @@ */ #pragma once +#include #include #include "action.h" diff --git a/quantum/process_keycode/process_joystick.h b/quantum/process_keycode/process_joystick.h index 1fb8757708..aa1a443271 100644 --- a/quantum/process_keycode/process_joystick.h +++ b/quantum/process_keycode/process_joystick.h @@ -17,6 +17,7 @@ #pragma once #include -#include "quantum.h" +#include +#include "action.h" bool process_joystick(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/process_keycode/process_key_lock.h b/quantum/process_keycode/process_key_lock.h index 5159b0ba02..858945a8e4 100644 --- a/quantum/process_keycode/process_key_lock.h +++ b/quantum/process_keycode/process_key_lock.h @@ -16,7 +16,9 @@ #pragma once -#include "quantum.h" +#include +#include +#include "action.h" void cancel_key_lock(void); bool process_key_lock(uint16_t *keycode, keyrecord_t *record); diff --git a/quantum/process_keycode/process_key_override.c b/quantum/process_keycode/process_key_override.c index de628d3fec..6ce1e4d925 100644 --- a/quantum/process_keycode/process_key_override.c +++ b/quantum/process_keycode/process_key_override.c @@ -15,12 +15,10 @@ * along with this program. If not, see . */ -#include "quantum.h" +#include "process_key_override.h" #include "report.h" #include "timer.h" -#include "process_key_override.h" - -#include +#include "debug.h" #ifndef KEY_OVERRIDE_REPEAT_DELAY # define KEY_OVERRIDE_REPEAT_DELAY 500 diff --git a/quantum/process_keycode/process_key_override.h b/quantum/process_keycode/process_key_override.h index fd76f297a8..3e37c7e63a 100644 --- a/quantum/process_keycode/process_key_override.h +++ b/quantum/process_keycode/process_key_override.h @@ -18,9 +18,8 @@ #pragma once #include -#include #include - +#include "action.h" #include "action_layer.h" /** diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c index a9823b6285..ca017a577d 100644 --- a/quantum/process_keycode/process_leader.c +++ b/quantum/process_keycode/process_leader.c @@ -16,6 +16,7 @@ #include "process_leader.h" #include "leader.h" +#include "quantum_keycodes.h" bool process_leader(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { diff --git a/quantum/process_keycode/process_leader.h b/quantum/process_keycode/process_leader.h index eb0f721f60..b78fbb94df 100644 --- a/quantum/process_keycode/process_leader.h +++ b/quantum/process_keycode/process_leader.h @@ -16,6 +16,8 @@ #pragma once -#include "quantum.h" +#include +#include +#include "action.h" bool process_leader(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/process_keycode/process_magic.c b/quantum/process_keycode/process_magic.c index 5fafe8550f..3b35884d68 100644 --- a/quantum/process_keycode/process_magic.c +++ b/quantum/process_keycode/process_magic.c @@ -14,8 +14,13 @@ * along with this program. If not, see . */ #include "process_magic.h" +#include "keycode_config.h" +#include "keycodes.h" +#include "eeconfig.h" #ifdef AUDIO_ENABLE +# include "audio.h" + # ifndef AG_NORM_SONG # define AG_NORM_SONG SONG(AG_NORM_SOUND) # endif diff --git a/quantum/process_keycode/process_magic.h b/quantum/process_keycode/process_magic.h index 1eb39f1455..aa65a43bae 100644 --- a/quantum/process_keycode/process_magic.h +++ b/quantum/process_keycode/process_magic.h @@ -15,6 +15,8 @@ */ #pragma once -#include "quantum.h" +#include +#include +#include "action.h" bool process_magic(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/process_keycode/process_midi.c b/quantum/process_keycode/process_midi.c index ce62559849..377fcb69e2 100644 --- a/quantum/process_keycode/process_midi.c +++ b/quantum/process_keycode/process_midi.c @@ -15,12 +15,13 @@ */ #include "process_midi.h" -#ifdef MIDI_ENABLE -# include -# include "midi.h" -# include "qmk_midi.h" +#include +#include "midi.h" +#include "qmk_midi.h" +#include "timer.h" +#include "debug.h" -# ifdef MIDI_BASIC +#ifdef MIDI_BASIC void process_midi_basic_noteon(uint8_t note) { midi_send_noteon(&midi_device, 0, note, 127); @@ -34,12 +35,9 @@ void process_midi_all_notes_off(void) { midi_send_cc(&midi_device, 0, 0x7B, 0); } -# endif // MIDI_BASIC - -# ifdef MIDI_ADVANCED - -# include "timer.h" +#endif // MIDI_BASIC +#ifdef MIDI_ADVANCED static uint8_t tone_status[2][MIDI_TONE_COUNT]; static uint8_t midi_modulation; @@ -248,11 +246,11 @@ bool process_midi(uint16_t keycode, keyrecord_t *record) { return true; } -# endif // MIDI_ADVANCED +#endif // MIDI_ADVANCED void midi_task(void) { midi_device_process(&midi_device); -# ifdef MIDI_ADVANCED +#ifdef MIDI_ADVANCED if (timer_elapsed(midi_modulation_timer) < midi_config.modulation_interval) return; midi_modulation_timer = timer_read(); @@ -270,7 +268,5 @@ void midi_task(void) { if (midi_modulation > 127) midi_modulation = 127; } -# endif +#endif } - -#endif // MIDI_ENABLE diff --git a/quantum/process_keycode/process_midi.h b/quantum/process_keycode/process_midi.h index e528c6ec0c..64ccc610f9 100644 --- a/quantum/process_keycode/process_midi.h +++ b/quantum/process_keycode/process_midi.h @@ -16,7 +16,10 @@ #pragma once -#include "quantum.h" +#include +#include +#include "action.h" +#include "quantum_keycodes.h" #ifdef MIDI_ENABLE diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c index 7c572079a7..f047668504 100644 --- a/quantum/process_keycode/process_music.c +++ b/quantum/process_keycode/process_music.c @@ -14,8 +14,10 @@ * along with this program. If not, see . */ #include "process_music.h" +#include "timer.h" #ifdef AUDIO_ENABLE +# include "audio.h" # include "process_audio.h" #endif #if defined(MIDI_ENABLE) && defined(MIDI_BASIC) diff --git a/quantum/process_keycode/process_music.h b/quantum/process_keycode/process_music.h index 83726a05ba..ed39d3cda5 100644 --- a/quantum/process_keycode/process_music.h +++ b/quantum/process_keycode/process_music.h @@ -16,7 +16,9 @@ #pragma once -#include "quantum.h" +#include +#include +#include "action.h" #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) diff --git a/quantum/process_keycode/process_programmable_button.h b/quantum/process_keycode/process_programmable_button.h index 47c6ce5614..ef818af4ca 100644 --- a/quantum/process_keycode/process_programmable_button.h +++ b/quantum/process_keycode/process_programmable_button.h @@ -18,6 +18,7 @@ along with this program. If not, see . #pragma once #include -#include "quantum.h" +#include +#include "action.h" bool process_programmable_button(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/process_keycode/process_repeat_key.c b/quantum/process_keycode/process_repeat_key.c index f819aa226e..73f4ddedcf 100644 --- a/quantum/process_keycode/process_repeat_key.c +++ b/quantum/process_keycode/process_repeat_key.c @@ -13,6 +13,10 @@ // limitations under the License. #include "process_repeat_key.h" +#include "repeat_key.h" +#include "keycodes.h" +#include "quantum_keycodes.h" +#include "action_util.h" // Default implementation of remember_last_key_user(). __attribute__((weak)) bool remember_last_key_user(uint16_t keycode, keyrecord_t* record, uint8_t* remembered_mods) { diff --git a/quantum/process_keycode/process_repeat_key.h b/quantum/process_keycode/process_repeat_key.h index eddc50f254..c3b200c632 100644 --- a/quantum/process_keycode/process_repeat_key.h +++ b/quantum/process_keycode/process_repeat_key.h @@ -14,7 +14,9 @@ #pragma once -#include "quantum.h" +#include +#include +#include "action.h" /** * @brief Process handler for remembering the last key. diff --git a/quantum/process_keycode/process_rgb.c b/quantum/process_keycode/process_rgb.c index dae129786e..4e63bf3ca8 100644 --- a/quantum/process_keycode/process_rgb.c +++ b/quantum/process_keycode/process_rgb.c @@ -14,6 +14,14 @@ * along with this program. If not, see . */ #include "process_rgb.h" +#include "action_util.h" + +#ifdef RGB_MATRIX_ENABLE +# include "rgb_matrix.h" +#endif +#ifdef RGBLIGHT_ENABLE +# include "rgblight.h" +#endif typedef void (*rgb_func_pointer)(void); diff --git a/quantum/process_keycode/process_rgb.h b/quantum/process_keycode/process_rgb.h index 26aca46896..b1069d4bb6 100644 --- a/quantum/process_keycode/process_rgb.h +++ b/quantum/process_keycode/process_rgb.h @@ -15,6 +15,8 @@ */ #pragma once -#include "quantum.h" +#include +#include +#include "action.h" bool process_rgb(const uint16_t keycode, const keyrecord_t *record); diff --git a/quantum/process_keycode/process_secure.h b/quantum/process_keycode/process_secure.h index 2814264b92..78d793f0f6 100644 --- a/quantum/process_keycode/process_secure.h +++ b/quantum/process_keycode/process_secure.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include "action.h" diff --git a/quantum/process_keycode/process_sequencer.h b/quantum/process_keycode/process_sequencer.h index 2b85f24299..3a9bdc2b24 100644 --- a/quantum/process_keycode/process_sequencer.h +++ b/quantum/process_keycode/process_sequencer.h @@ -16,6 +16,8 @@ #pragma once -#include "quantum.h" +#include +#include +#include "action.h" bool process_sequencer(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/process_keycode/process_space_cadet.c b/quantum/process_keycode/process_space_cadet.c index 3109ea1711..4d9f01077e 100644 --- a/quantum/process_keycode/process_space_cadet.c +++ b/quantum/process_keycode/process_space_cadet.c @@ -14,6 +14,8 @@ * along with this program. If not, see . */ #include "process_space_cadet.h" +#include "keycodes.h" +#include "timer.h" #include "action_tapping.h" // ********** OBSOLETE DEFINES, STOP USING! (pls?) ********** diff --git a/quantum/process_keycode/process_space_cadet.h b/quantum/process_keycode/process_space_cadet.h index fcb70f3b43..6d10051532 100644 --- a/quantum/process_keycode/process_space_cadet.h +++ b/quantum/process_keycode/process_space_cadet.h @@ -15,7 +15,9 @@ */ #pragma once -#include "quantum.h" +#include +#include +#include "action.h" void perform_space_cadet(keyrecord_t *record, uint16_t sc_keycode, uint8_t holdMod, uint8_t tapMod, uint8_t keycode); bool process_space_cadet(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/process_keycode/process_steno.c b/quantum/process_keycode/process_steno.c index d5ad61ba85..af26d4ca86 100644 --- a/quantum/process_keycode/process_steno.c +++ b/quantum/process_keycode/process_steno.c @@ -15,6 +15,7 @@ */ #include "process_steno.h" #include "quantum_keycodes.h" +#include "eeconfig.h" #include "keymap_steno.h" #include #ifdef VIRTSER_ENABLE diff --git a/quantum/process_keycode/process_steno.h b/quantum/process_keycode/process_steno.h index 68d6097b9b..0dd2103218 100644 --- a/quantum/process_keycode/process_steno.h +++ b/quantum/process_keycode/process_steno.h @@ -16,7 +16,9 @@ #pragma once -#include "quantum.h" +#include +#include +#include "action.h" #define BOLT_STROKE_SIZE 4 #define GEMINI_STROKE_SIZE 6 diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c index 706f5cddbb..1b2c6c8a44 100644 --- a/quantum/process_keycode/process_tap_dance.c +++ b/quantum/process_keycode/process_tap_dance.c @@ -13,7 +13,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + +#include "process_tap_dance.h" #include "quantum.h" +#include "action_layer.h" +#include "action_tapping.h" +#include "action_util.h" +#include "timer.h" +#include "wait.h" static uint16_t active_td; static uint16_t last_tap_time; diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h index 5cb6d9202c..386f504619 100644 --- a/quantum/process_keycode/process_tap_dance.h +++ b/quantum/process_keycode/process_tap_dance.h @@ -16,18 +16,17 @@ #pragma once -#ifdef TAP_DANCE_ENABLE - -# include -# include +#include +#include +#include "action.h" typedef struct { uint16_t interrupting_keycode; uint8_t count; uint8_t weak_mods; -# ifndef NO_ACTION_ONESHOT +#ifndef NO_ACTION_ONESHOT uint8_t oneshot_mods; -# endif +#endif bool pressed : 1; bool finished : 1; bool interrupted : 1; @@ -56,24 +55,24 @@ typedef struct { void (*layer_function)(uint8_t); } tap_dance_dual_role_t; -# define ACTION_TAP_DANCE_DOUBLE(kc1, kc2) \ - { .fn = {tap_dance_pair_on_each_tap, tap_dance_pair_finished, tap_dance_pair_reset}, .user_data = (void *)&((tap_dance_pair_t){kc1, kc2}), } +#define ACTION_TAP_DANCE_DOUBLE(kc1, kc2) \ + { .fn = {tap_dance_pair_on_each_tap, tap_dance_pair_finished, tap_dance_pair_reset}, .user_data = (void *)&((tap_dance_pair_t){kc1, kc2}), } -# define ACTION_TAP_DANCE_LAYER_MOVE(kc, layer) \ - { .fn = {tap_dance_dual_role_on_each_tap, tap_dance_dual_role_finished, tap_dance_dual_role_reset}, .user_data = (void *)&((tap_dance_dual_role_t){kc, layer, layer_move}), } +#define ACTION_TAP_DANCE_LAYER_MOVE(kc, layer) \ + { .fn = {tap_dance_dual_role_on_each_tap, tap_dance_dual_role_finished, tap_dance_dual_role_reset}, .user_data = (void *)&((tap_dance_dual_role_t){kc, layer, layer_move}), } -# define ACTION_TAP_DANCE_LAYER_TOGGLE(kc, layer) \ - { .fn = {NULL, tap_dance_dual_role_finished, tap_dance_dual_role_reset}, .user_data = (void *)&((tap_dance_dual_role_t){kc, layer, layer_invert}), } +#define ACTION_TAP_DANCE_LAYER_TOGGLE(kc, layer) \ + { .fn = {NULL, tap_dance_dual_role_finished, tap_dance_dual_role_reset}, .user_data = (void *)&((tap_dance_dual_role_t){kc, layer, layer_invert}), } -# define ACTION_TAP_DANCE_FN(user_fn) \ - { .fn = {NULL, user_fn, NULL}, .user_data = NULL, } +#define ACTION_TAP_DANCE_FN(user_fn) \ + { .fn = {NULL, user_fn, NULL}, .user_data = NULL, } -# define ACTION_TAP_DANCE_FN_ADVANCED(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset) \ - { .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset}, .user_data = NULL, } +#define ACTION_TAP_DANCE_FN_ADVANCED(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset) \ + { .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset}, .user_data = NULL, } -# define TD(n) (QK_TAP_DANCE | TD_INDEX(n)) -# define TD_INDEX(code) ((code)&0xFF) -# define TAP_DANCE_KEYCODE(state) TD(((tap_dance_action_t *)state) - tap_dance_actions) +#define TD(n) (QK_TAP_DANCE | TD_INDEX(n)) +#define TD_INDEX(code) ((code)&0xFF) +#define TAP_DANCE_KEYCODE(state) TD(((tap_dance_action_t *)state) - tap_dance_actions) extern tap_dance_action_t tap_dance_actions[]; @@ -92,9 +91,3 @@ void tap_dance_pair_reset(tap_dance_state_t *state, void *user_data); void tap_dance_dual_role_on_each_tap(tap_dance_state_t *state, void *user_data); void tap_dance_dual_role_finished(tap_dance_state_t *state, void *user_data); void tap_dance_dual_role_reset(tap_dance_state_t *state, void *user_data); - -#else - -# define TD(n) KC_NO - -#endif diff --git a/quantum/process_keycode/process_tri_layer.h b/quantum/process_keycode/process_tri_layer.h index 9c4e3df1c2..5e6e4ff94d 100644 --- a/quantum/process_keycode/process_tri_layer.h +++ b/quantum/process_keycode/process_tri_layer.h @@ -3,6 +3,8 @@ #pragma once +#include +#include #include "action.h" /**