diff --git a/platforms/suspend.c b/platforms/suspend.c index 0818a726ce1b..74b45a3327bc 100644 --- a/platforms/suspend.c +++ b/platforms/suspend.c @@ -56,6 +56,20 @@ bool suspend_wakeup_condition(void) { return wakeup; } +void wakeup_matrix_update(void) { + matrix_power_up(); + matrix_scan(); + matrix_power_down(); + + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + matrix_row_t matrix_row = matrix_get_row(row); + matrix_row_t col_mask = 1; + for (uint8_t col = 0; col < MATRIX_COLS; col++, col_mask <<= 1) { + wakeup_matrix_handle_key_event(row, col, matrix_row & col_mask); + } + } +} + bool keypress_is_wakeup_key(uint8_t row, uint8_t col) { return (wakeup_matrix[row] & ((matrix_row_t)1 << col)); } diff --git a/platforms/suspend.h b/platforms/suspend.h index 762bef12dbc3..dbaab90805cc 100644 --- a/platforms/suspend.h +++ b/platforms/suspend.h @@ -15,6 +15,7 @@ void suspend_power_down_kb(void); void suspend_power_down_quantum(void); bool keypress_is_wakeup_key(uint8_t row, uint8_t col); +void wakeup_matrix_update(void); void wakeup_matrix_handle_key_event(uint8_t row, uint8_t col, bool pressed); #ifndef USB_SUSPEND_WAKEUP_DELAY diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c index b879bdac7787..3ae1e7d0239c 100644 --- a/tmk_core/protocol/chibios/chibios.c +++ b/tmk_core/protocol/chibios/chibios.c @@ -194,6 +194,9 @@ void protocol_pre_task(void) { // // Pause for a while to let things settle... wait_ms(USB_SUSPEND_WAKEUP_DELAY); + // ...and then update the wakeup matrix again as the waking key + // might have been released during the delay + wakeup_matrix_update(); # endif } } diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index b0c9758d2fd5..1ce81220282e 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -848,6 +848,9 @@ void protocol_pre_task(void) { // // Pause for a while to let things settle... wait_ms(USB_SUSPEND_WAKEUP_DELAY); + // ...and then update the wakeup matrix again as the waking key + // might have been released during the delay + wakeup_matrix_update(); # endif } } diff --git a/tmk_core/protocol/vusb/protocol.c b/tmk_core/protocol/vusb/protocol.c index 41ccf451fdbb..1b9ba2951d6f 100644 --- a/tmk_core/protocol/vusb/protocol.c +++ b/tmk_core/protocol/vusb/protocol.c @@ -145,6 +145,9 @@ void protocol_pre_task(void) { // // Pause for a while to let things settle... wait_ms(USB_SUSPEND_WAKEUP_DELAY); + // ...and then update the wakeup matrix again as the waking key + // might have been released during the delay + wakeup_matrix_update(); # endif } }