Process entire unlock sequence

This commit is contained in:
zvecr 2022-04-12 01:49:30 +01:00
parent d19285019d
commit 320f161c72

View File

@ -15,7 +15,9 @@
#ifndef SECURE_UNLOCK_SEQUENCE #ifndef SECURE_UNLOCK_SEQUENCE
# define SECURE_UNLOCK_SEQUENCE \ # define SECURE_UNLOCK_SEQUENCE \
{ \ { \
{ 0, 0 } \ {0, 0}, { \
0, 1 \
} \
} }
#endif #endif
@ -51,12 +53,17 @@ void secure_activity_event(void) {
void secure_keypress_event(uint8_t row, uint8_t col) { void secure_keypress_event(uint8_t row, uint8_t col) {
static const uint8_t sequence[][2] = SECURE_UNLOCK_SEQUENCE; static const uint8_t sequence[][2] = SECURE_UNLOCK_SEQUENCE;
static const uint8_t sequence_len = sizeof(sequence) / sizeof(sequence[0]);
// TODO: check keypress is actually part of unlock sequence static uint8_t offset = 0;
uint8_t offset = 0;
if ((sequence[offset][0] == row) && (sequence[offset][1] == col)) { if ((sequence[offset][0] == row) && (sequence[offset][1] == col)) {
offset++;
if (offset == sequence_len) {
offset = 0;
secure_unlock(); secure_unlock();
}
} else { } else {
offset = 0;
secure_lock(); secure_lock();
} }
} }