aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--keyboards/anavi/macropad8/keyboard.json2
-rw-r--r--platforms/suspend.c35
-rw-r--r--platforms/suspend.h4
-rw-r--r--quantum/keyboard.c8
-rw-r--r--tmk_core/protocol/chibios/chibios.c3
-rw-r--r--tmk_core/protocol/lufa/lufa.c3
-rw-r--r--tmk_core/protocol/vusb/protocol.c3
7 files changed, 50 insertions, 8 deletions
diff --git a/keyboards/anavi/macropad8/keyboard.json b/keyboards/anavi/macropad8/keyboard.json
index 8073a038a2..2fb24e58bb 100644
--- a/keyboards/anavi/macropad8/keyboard.json
+++ b/keyboards/anavi/macropad8/keyboard.json
@@ -20,10 +20,8 @@
"breathing": true,
"rainbow_mood": true,
"rainbow_swirl": true,
- "snake": true,
"knight": true,
"static_gradient": true,
- "rgb_test": true,
"alternating": true,
"twinkle": true
}
diff --git a/platforms/suspend.c b/platforms/suspend.c
index fea23cbd02..4756796ea4 100644
--- a/platforms/suspend.c
+++ b/platforms/suspend.c
@@ -4,6 +4,9 @@
#include "suspend.h"
#include "matrix.h"
+extern matrix_row_t matrix_previous[MATRIX_ROWS];
+static matrix_row_t wakeup_matrix[MATRIX_ROWS];
+
// TODO: Move to more correct location
__attribute__((weak)) void matrix_power_up(void) {}
__attribute__((weak)) void matrix_power_down(void) {}
@@ -44,8 +47,34 @@ bool suspend_wakeup_condition(void) {
matrix_power_up();
matrix_scan();
matrix_power_down();
- for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
- if (matrix_get_row(r)) return true;
+
+ bool wakeup = false;
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+ wakeup_matrix[row] = matrix_get_row(row);
+ wakeup |= wakeup_matrix[row] != 0;
+ }
+
+ return wakeup;
+}
+
+void update_matrix_state_after_wakeup(void) {
+ matrix_power_up();
+ matrix_scan();
+ matrix_power_down();
+
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+ const matrix_row_t current_row = matrix_get_row(row);
+ wakeup_matrix[row] |= current_row & ~matrix_previous[row];
+ matrix_previous[row] |= current_row;
+ }
+}
+
+bool keypress_is_wakeup_key(uint8_t row, uint8_t col) {
+ return (wakeup_matrix[row] & ((matrix_row_t)1 << col));
+}
+
+void wakeup_matrix_handle_key_event(uint8_t row, uint8_t col, bool pressed) {
+ if (!pressed) {
+ wakeup_matrix[row] &= ~((matrix_row_t)1 << col);
}
- return false;
}
diff --git a/platforms/suspend.h b/platforms/suspend.h
index e4f7f39ddb..3a7f51f9f0 100644
--- a/platforms/suspend.h
+++ b/platforms/suspend.h
@@ -14,6 +14,10 @@ void suspend_power_down_user(void);
void suspend_power_down_kb(void);
void suspend_power_down_quantum(void);
+bool keypress_is_wakeup_key(uint8_t row, uint8_t col);
+void update_matrix_state_after_wakeup(void);
+void wakeup_matrix_handle_key_event(uint8_t row, uint8_t col, bool pressed);
+
#ifndef USB_SUSPEND_WAKEUP_DELAY
# define USB_SUSPEND_WAKEUP_DELAY 0
#endif
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/>.
#include "sendchar.h"
#include "eeconfig.h"
#include "action_layer.h"
+#include "suspend.h"
#ifdef BOOTMAGIC_ENABLE
# include "bootmagic.h"
#endif
@@ -563,6 +564,7 @@ void switch_events(uint8_t row, uint8_t col, bool pressed) {
#if defined(RGB_MATRIX_ENABLE)
rgb_matrix_handle_key_event(row, col, pressed);
#endif
+ wakeup_matrix_handle_key_event(row, col, pressed);
}
/**
@@ -578,6 +580,8 @@ static inline void generate_tick_event(void) {
}
}
+matrix_row_t matrix_previous[MATRIX_ROWS];
+
/**
* @brief This task scans the keyboards matrix and processes any key presses
* that occur.
@@ -591,8 +595,6 @@ static bool matrix_task(void) {
return false;
}
- static matrix_row_t matrix_previous[MATRIX_ROWS];
-
matrix_scan();
bool matrix_changed = false;
for (uint8_t row = 0; row < MATRIX_ROWS && !matrix_changed; row++) {
@@ -626,7 +628,7 @@ static bool matrix_task(void) {
if (row_changes & col_mask) {
const bool key_pressed = current_row & col_mask;
- if (process_keypress) {
+ if (process_keypress && !keypress_is_wakeup_key(row, col)) {
action_exec(MAKE_KEYEVENT(row, col, key_pressed));
}
diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c
index 5720bc3c4c..b8cded99fc 100644
--- a/tmk_core/protocol/chibios/chibios.c
+++ b/tmk_core/protocol/chibios/chibios.c
@@ -191,6 +191,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
+ update_matrix_state_after_wakeup();
# endif
}
}
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index e13f4b548e..3e442ba033 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -826,6 +826,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
+ update_matrix_state_after_wakeup();
# endif
}
}
diff --git a/tmk_core/protocol/vusb/protocol.c b/tmk_core/protocol/vusb/protocol.c
index e2d0c4112e..b95750306a 100644
--- a/tmk_core/protocol/vusb/protocol.c
+++ b/tmk_core/protocol/vusb/protocol.c
@@ -125,6 +125,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
+ update_matrix_state_after_wakeup();
# endif
}
}