From 942b3cf16cceec2afa72bea2f12ef543f395a5db Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Mon, 6 Dec 2021 09:38:36 -0800 Subject: Generalize Unicode defines (#15409) --- quantum/quantum.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index 35b6351e9d..5ecc183327 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -263,7 +263,7 @@ bool process_record_quantum(keyrecord_t *record) { #ifdef TAP_DANCE_ENABLE process_tap_dance(keycode, record) && #endif -#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE) +#if defined(UNICODE_COMMON_ENABLE) process_unicode_common(keycode, record) && #endif #ifdef LEADER_ENABLE @@ -387,7 +387,7 @@ void matrix_init_quantum() { #ifdef RGB_MATRIX_ENABLE rgb_matrix_init(); #endif -#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE) +#if defined(UNICODE_COMMON_ENABLE) unicode_input_mode_init(); #endif #ifdef HAPTIC_ENABLE -- cgit v1.2.1 From 672c6b47219067d1ec50057b17af4fcd98132ba4 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Sun, 26 Dec 2021 17:15:56 -0800 Subject: Make (un)register code functions weak (#15285) --- quantum/quantum.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index 5ecc183327..c106f795d0 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -76,9 +76,9 @@ uint8_t extract_mod_bits(uint16_t code) { return mods_to_send; } -static void do_code16(uint16_t code, void (*f)(uint8_t)) { f(extract_mod_bits(code)); } +void do_code16(uint16_t code, void (*f)(uint8_t)) { f(extract_mod_bits(code)); } -void register_code16(uint16_t code) { +__attribute__((weak)) void register_code16(uint16_t code) { if (IS_MOD(code) || code == KC_NO) { do_code16(code, register_mods); } else { @@ -87,7 +87,7 @@ void register_code16(uint16_t code) { register_code(code); } -void unregister_code16(uint16_t code) { +__attribute__((weak)) void unregister_code16(uint16_t code) { unregister_code(code); if (IS_MOD(code) || code == KC_NO) { do_code16(code, unregister_mods); @@ -96,7 +96,7 @@ void unregister_code16(uint16_t code) { } } -void tap_code16(uint16_t code) { +__attribute__((weak)) void tap_code16(uint16_t code) { register_code16(code); #if TAP_CODE_DELAY > 0 wait_ms(TAP_CODE_DELAY); -- cgit v1.2.1 From d840ef2b2855c7c6094e5881a4bc78a05297a488 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Wed, 19 Jan 2022 17:38:48 +0000 Subject: Relocate matrix_scan_quantum tasks (#15882) * Move matrix_scan_quantum tasks * Fix tests * Fix up missing refs --- quantum/quantum.c | 73 ++----------------------------------------------------- 1 file changed, 2 insertions(+), 71 deletions(-) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index c106f795d0..ac99bcbd45 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -47,10 +47,6 @@ float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS; # endif #endif -#ifdef AUTO_SHIFT_ENABLE -# include "process_auto_shift.h" -#endif - uint8_t extract_mod_bits(uint16_t code) { switch (code) { case QK_MODS ... QK_MODS_MAX: @@ -400,73 +396,8 @@ void matrix_init_quantum() { matrix_init_kb(); } -void matrix_scan_quantum() { -#if defined(AUDIO_ENABLE) && defined(AUDIO_INIT_DELAY) - // There are some tasks that need to be run a little bit - // after keyboard startup, or else they will not work correctly - // because of interaction with the USB device state, which - // may still be in flux... - // - // At the moment the only feature that needs this is the - // startup song. - static bool delayed_tasks_run = false; - static uint16_t delayed_task_timer = 0; - if (!delayed_tasks_run) { - if (!delayed_task_timer) { - delayed_task_timer = timer_read(); - } else if (timer_elapsed(delayed_task_timer) > 300) { - audio_startup(); - delayed_tasks_run = true; - } - } -#endif - -#if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE) - music_task(); -#endif - -#ifdef KEY_OVERRIDE_ENABLE - key_override_task(); -#endif - -#ifdef SEQUENCER_ENABLE - sequencer_task(); -#endif - -#ifdef TAP_DANCE_ENABLE - tap_dance_task(); -#endif - -#ifdef COMBO_ENABLE - combo_task(); -#endif - -#ifdef LED_MATRIX_ENABLE - led_matrix_task(); -#endif - -#ifdef WPM_ENABLE - decay_wpm(); -#endif - -#ifdef HAPTIC_ENABLE - haptic_task(); -#endif - -#ifdef DIP_SWITCH_ENABLE - dip_switch_read(false); -#endif - -#ifdef AUTO_SHIFT_ENABLE - autoshift_matrix_scan(); -#endif - - matrix_scan_kb(); -} - -#ifdef HD44780_ENABLED -# include "hd44780.h" -#endif +// TODO: remove legacy api +void matrix_scan_quantum() { matrix_scan_kb(); } //------------------------------------------------------------------------------ // Override these functions in your keymap file to play different tunes on -- cgit v1.2.1 From b45a037c7edcd9c1cfadceb69ed51e7d42aa58c1 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 22 Jan 2022 14:34:15 +1100 Subject: Rename some Quantum keycodes (#15968) * Rename some Quantum keycodes * Tweak EEPROM clear and debug keycode short aliases --- quantum/quantum.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index ac99bcbd45..f12b1a9526 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -302,12 +302,12 @@ bool process_record_quantum(keyrecord_t *record) { if (record->event.pressed) { switch (keycode) { #ifndef NO_RESET - case RESET: + case QK_BOOTLOADER: reset_keyboard(); return false; #endif #ifndef NO_DEBUG - case DEBUG: + case QK_DEBUG_TOGGLE: debug_enable ^= 1; if (debug_enable) { print("DEBUG: enabled.\n"); @@ -316,7 +316,7 @@ bool process_record_quantum(keyrecord_t *record) { } #endif return false; - case EEPROM_RESET: + case QK_CLEAR_EEPROM: eeconfig_init(); return false; #ifdef VELOCIKEY_ENABLE -- cgit v1.2.1 From 6e83b449409f7fe479210a9fab808e8bcae64977 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sat, 22 Jan 2022 21:17:02 +0000 Subject: Align location of some host led logic (#15954) * Align location of host led logic * Move more * align ifdefs * Fix up includes * Move callback defs * Convert comment to build message --- quantum/quantum.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index f12b1a9526..b59fcc9857 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -433,14 +433,7 @@ void suspend_power_down_quantum(void) { # endif // Turn off LED indicators - uint8_t leds_off = 0; -# if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE) - if (is_backlight_enabled()) { - // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off - leds_off |= (1 << USB_LED_CAPS_LOCK); - } -# endif - led_set(leds_off); + led_suspend(); // Turn off audio # ifdef AUDIO_ENABLE @@ -491,7 +484,7 @@ __attribute__((weak)) void suspend_wakeup_init_quantum(void) { #endif // Restore LED indicators - led_set(host_keyboard_leds()); + led_wakeup(); // Wake up underglow #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) -- cgit v1.2.1 From a8700404f7a73ba3a5da4670a04cf5f999578abd Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sun, 23 Jan 2022 02:41:57 +0000 Subject: Relocate matrix_init_quantum content (#15953) * Relocate matrix_init_quantum content * Update include order * Fix cherry pick from 15722 --- quantum/quantum.c | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index b59fcc9857..21f499165a 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -15,7 +15,6 @@ */ #include "quantum.h" -#include "magic.h" #ifdef BLUETOOTH_ENABLE # include "outputselect.h" @@ -368,35 +367,8 @@ layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_ void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3)); } -void matrix_init_quantum() { - magic(); - led_init_ports(); -#ifdef BACKLIGHT_ENABLE - backlight_init_ports(); -#endif -#ifdef AUDIO_ENABLE - audio_init(); -#endif -#ifdef LED_MATRIX_ENABLE - led_matrix_init(); -#endif -#ifdef RGB_MATRIX_ENABLE - rgb_matrix_init(); -#endif -#if defined(UNICODE_COMMON_ENABLE) - unicode_input_mode_init(); -#endif -#ifdef HAPTIC_ENABLE - haptic_init(); -#endif -#if defined(BLUETOOTH_ENABLE) && defined(OUTPUT_AUTO_ENABLE) - set_output(OUTPUT_AUTO); -#endif - - matrix_init_kb(); -} - // TODO: remove legacy api +void matrix_init_quantum() { matrix_init_kb(); } void matrix_scan_quantum() { matrix_scan_kb(); } //------------------------------------------------------------------------------ -- cgit v1.2.1 From 1f59fe6d1b1da209fa4475f10d082455ee1381eb Mon Sep 17 00:00:00 2001 From: Ga68 Date: Fri, 28 Jan 2022 23:03:21 -0800 Subject: Adjust tap_code16 to account for TAP_HOLD_CAPS_DELAY (#15635) Co-authored-by: Ga68 --- quantum/quantum.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index 21f499165a..833f53175f 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -93,9 +93,12 @@ __attribute__((weak)) void unregister_code16(uint16_t code) { __attribute__((weak)) void tap_code16(uint16_t code) { register_code16(code); -#if TAP_CODE_DELAY > 0 - wait_ms(TAP_CODE_DELAY); -#endif + if (code == KC_CAPS_LOCK) { + wait_ms(TAP_HOLD_CAPS_DELAY); + } + else if (TAP_CODE_DELAY > 0) { + wait_ms(TAP_CODE_DELAY); + } unregister_code16(code); } -- cgit v1.2.1 From b79b8dcdd036c1ad727985f088be1a03c5642be2 Mon Sep 17 00:00:00 2001 From: QMK Bot Date: Sat, 29 Jan 2022 04:25:49 -0800 Subject: Format code according to conventions (#16110) --- quantum/quantum.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index 833f53175f..ca3e4027dc 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -95,9 +95,8 @@ __attribute__((weak)) void tap_code16(uint16_t code) { register_code16(code); if (code == KC_CAPS_LOCK) { wait_ms(TAP_HOLD_CAPS_DELAY); - } - else if (TAP_CODE_DELAY > 0) { - wait_ms(TAP_CODE_DELAY); + } else if (TAP_CODE_DELAY > 0) { + wait_ms(TAP_CODE_DELAY); } unregister_code16(code); } -- cgit v1.2.1 From 135c93599036bbe646a69b568eef9219823a4be9 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Fri, 4 Feb 2022 18:10:00 +0000 Subject: Initial migration of suspend callbacks (#16067) * Initial migration of suspend logic * Add header --- quantum/quantum.c | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index ca3e4027dc..fb6220efa2 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -381,17 +381,6 @@ __attribute__((weak)) void startup_user() {} __attribute__((weak)) void shutdown_user() {} -/** \brief Run keyboard level Power down - * - * FIXME: needs doc - */ -__attribute__((weak)) void suspend_power_down_user(void) {} -/** \brief Run keyboard level Power down - * - * FIXME: needs doc - */ -__attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); } - void suspend_power_down_quantum(void) { #ifndef NO_SUSPEND_POWER_DOWN // Turn off backlight @@ -439,18 +428,6 @@ void suspend_power_down_quantum(void) { #endif } -/** \brief run user level code immediately after wakeup - * - * FIXME: needs doc - */ -__attribute__((weak)) void suspend_wakeup_init_user(void) {} - -/** \brief run keyboard level code immediately after wakeup - * - * FIXME: needs doc - */ -__attribute__((weak)) void suspend_wakeup_init_kb(void) { suspend_wakeup_init_user(); } - __attribute__((weak)) void suspend_wakeup_init_quantum(void) { // Turn on backlight #ifdef BACKLIGHT_ENABLE -- cgit v1.2.1 From 63646e8906e062d1c1de3925cba70c4e3426a855 Mon Sep 17 00:00:00 2001 From: QMK Bot Date: Sat, 12 Feb 2022 10:29:31 -0800 Subject: Format code according to conventions (#16322) --- quantum/quantum.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index fb6220efa2..dce41c08ae 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -56,7 +56,7 @@ uint8_t extract_mod_bits(uint16_t code) { 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_RIGHT_CTRL); if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RIGHT_SHIFT); if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RIGHT_ALT); @@ -71,7 +71,9 @@ uint8_t extract_mod_bits(uint16_t code) { return mods_to_send; } -void do_code16(uint16_t code, void (*f)(uint8_t)) { f(extract_mod_bits(code)); } +void do_code16(uint16_t code, void (*f)(uint8_t)) { + f(extract_mod_bits(code)); +} __attribute__((weak)) void register_code16(uint16_t code) { if (IS_MOD(code) || code == KC_NO) { @@ -101,13 +103,21 @@ __attribute__((weak)) void tap_code16(uint16_t code) { unregister_code16(code); } -__attribute__((weak)) bool process_action_kb(keyrecord_t *record) { return true; } +__attribute__((weak)) bool process_action_kb(keyrecord_t *record) { + return true; +} -__attribute__((weak)) bool process_record_kb(uint16_t keycode, keyrecord_t *record) { return process_record_user(keycode, record); } +__attribute__((weak)) bool process_record_kb(uint16_t keycode, keyrecord_t *record) { + return process_record_user(keycode, record); +} -__attribute__((weak)) bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; } +__attribute__((weak)) bool process_record_user(uint16_t keycode, keyrecord_t *record) { + return true; +} -__attribute__((weak)) void post_process_record_kb(uint16_t keycode, keyrecord_t *record) { post_process_record_user(keycode, record); } +__attribute__((weak)) void post_process_record_kb(uint16_t keycode, keyrecord_t *record) { + post_process_record_user(keycode, record); +} __attribute__((weak)) void post_process_record_user(uint16_t keycode, keyrecord_t *record) {} @@ -123,7 +133,8 @@ void reset_keyboard(void) { uint16_t timer_start = timer_read(); PLAY_SONG(goodbye_song); shutdown_user(); - while (timer_elapsed(timer_start) < 250) wait_ms(1); + while (timer_elapsed(timer_start) < 250) + wait_ms(1); stop_all_notes(); #else shutdown_user(); @@ -178,7 +189,7 @@ bool pre_process_record_quantum(keyrecord_t *record) { true)) { return false; } - return true; // continue processing + return true; // continue processing } /* Get keycode, and then call keyboard function */ @@ -367,11 +378,17 @@ layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_ return (state & mask12) == mask12 ? (state | mask3) : (state & ~mask3); } -void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3)); } +void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { + layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3)); +} // TODO: remove legacy api -void matrix_init_quantum() { matrix_init_kb(); } -void matrix_scan_quantum() { matrix_scan_kb(); } +void matrix_init_quantum() { + matrix_init_kb(); +} +void matrix_scan_quantum() { + matrix_scan_kb(); +} //------------------------------------------------------------------------------ // Override these functions in your keymap file to play different tunes on -- cgit v1.2.1