summaryrefslogtreecommitdiff
path: root/quantum/keyboard.c
diff options
context:
space:
mode:
authorStefan Kerkmann <karlk90@pm.me>2025-11-11 13:35:03 +0100
committerGitHub <noreply@github.com>2025-11-11 23:35:03 +1100
commitc68e4dec10db07f16f6d2b5dd883bbcfc09cde25 (patch)
tree4b4a59b1f30a476c012466629bcbe21f1b756405 /quantum/keyboard.c
parent1ddcf57382f94548aba23871c57c7ce835f203b9 (diff)
[Core] suspend: suppress wake up keypress (#23389)
* suspend: suppress wake up keypress Waking the host from suspend is done by pressing any key on the keyboard, the regular key codes assigned to the keys are not important and must not be sent - otherwise they usually end up in password prompts as ghost characters that have to be deleted again. This commit adds suppression for all keys pressed at the time of wake up. Once a key is released it functions as a regular key again. Signed-off-by: Stefan Kerkmann <karlk90@pm.me> * suspend: update wake up matrix after wake up delay If USB_SUSPEND_WAKEUP_DELAY is set, the keyboard sleeps during wake up - which can be up to multiple seconds. To handle key presses and releases in that time frame we have to handle the following cases: 1. Key not pressed before suspend, and not pressed after wakeup → do nothing (normal case). 2. Key not pressed before suspend, but pressed after wakeup → set the wakeup_matrix bit to 1 (so that the press and release events would be suppressed). 3. Key pressed before suspend, but not pressed after wakeup → do nothing (the release event will be generated on the first matrix_task() call after the wakeup). 4. Key pressed before suspend, and still pressed after wakeup → do nothing (the release event will be generated some time later). Signed-off-by: Stefan Kerkmann <karlk90@pm.me> Co-authored-by: Sergey Vlasov <sigprof@gmail.com> * keyboards: anavi: macropad8: disable snake and rgb_test effects ...to shrink the binary size.
Diffstat (limited to 'quantum/keyboard.c')
-rw-r--r--quantum/keyboard.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/quantum/keyboard.c b/quantum/keyboard.c
index ce8c8efa68..e0c9373165 100644
--- a/quantum/keyboard.c
+++ b/quantum/keyboard.c
@@ -33,6 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
33#include "sendchar.h" 33#include "sendchar.h"
34#include "eeconfig.h" 34#include "eeconfig.h"
35#include "action_layer.h" 35#include "action_layer.h"
36#include "suspend.h"
36#ifdef BOOTMAGIC_ENABLE 37#ifdef BOOTMAGIC_ENABLE
37# include "bootmagic.h" 38# include "bootmagic.h"
38#endif 39#endif
@@ -563,6 +564,7 @@ void switch_events(uint8_t row, uint8_t col, bool pressed) {
563#if defined(RGB_MATRIX_ENABLE) 564#if defined(RGB_MATRIX_ENABLE)
564 rgb_matrix_handle_key_event(row, col, pressed); 565 rgb_matrix_handle_key_event(row, col, pressed);
565#endif 566#endif
567 wakeup_matrix_handle_key_event(row, col, pressed);
566} 568}
567 569
568/** 570/**
@@ -578,6 +580,8 @@ static inline void generate_tick_event(void) {
578 } 580 }
579} 581}
580 582
583matrix_row_t matrix_previous[MATRIX_ROWS];
584
581/** 585/**
582 * @brief This task scans the keyboards matrix and processes any key presses 586 * @brief This task scans the keyboards matrix and processes any key presses
583 * that occur. 587 * that occur.
@@ -591,8 +595,6 @@ static bool matrix_task(void) {
591 return false; 595 return false;
592 } 596 }
593 597
594 static matrix_row_t matrix_previous[MATRIX_ROWS];
595
596 matrix_scan(); 598 matrix_scan();
597 bool matrix_changed = false; 599 bool matrix_changed = false;
598 for (uint8_t row = 0; row < MATRIX_ROWS && !matrix_changed; row++) { 600 for (uint8_t row = 0; row < MATRIX_ROWS && !matrix_changed; row++) {
@@ -626,7 +628,7 @@ static bool matrix_task(void) {
626 if (row_changes & col_mask) { 628 if (row_changes & col_mask) {
627 const bool key_pressed = current_row & col_mask; 629 const bool key_pressed = current_row & col_mask;
628 630
629 if (process_keypress) { 631 if (process_keypress && !keypress_is_wakeup_key(row, col)) {
630 action_exec(MAKE_KEYEVENT(row, col, key_pressed)); 632 action_exec(MAKE_KEYEVENT(row, col, key_pressed));
631 } 633 }
632 634