2022-04-17 00:13:05 +06:00
|
|
|
// Copyright 2022 QMK
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
#include "secure.h"
|
|
|
|
#include "process_secure.h"
|
|
|
|
#include "quantum_keycodes.h"
|
|
|
|
|
|
|
|
bool preprocess_secure(uint16_t keycode, keyrecord_t *record) {
|
|
|
|
if (secure_is_unlocking()) {
|
2022-05-15 04:07:08 +06:00
|
|
|
// !pressed will trigger on any already held keys (such as layer keys),
|
|
|
|
// and cause the request secure check to prematurely fail.
|
|
|
|
if (record->event.pressed) {
|
2022-04-17 00:13:05 +06:00
|
|
|
secure_keypress_event(record->event.key.row, record->event.key.col);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Normal keypresses should be disabled until the sequence is completed
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool process_secure(uint16_t keycode, keyrecord_t *record) {
|
|
|
|
#ifndef SECURE_DISABLE_KEYCODES
|
|
|
|
if (!record->event.pressed) {
|
2022-10-26 03:59:17 +06:00
|
|
|
if (keycode == QK_SECURE_LOCK) {
|
2022-04-17 00:13:05 +06:00
|
|
|
secure_lock();
|
|
|
|
return false;
|
|
|
|
}
|
2022-10-26 03:59:17 +06:00
|
|
|
if (keycode == QK_SECURE_UNLOCK) {
|
2022-04-17 00:13:05 +06:00
|
|
|
secure_unlock();
|
|
|
|
return false;
|
|
|
|
}
|
2022-10-26 03:59:17 +06:00
|
|
|
if (keycode == QK_SECURE_TOGGLE) {
|
2022-04-17 00:13:05 +06:00
|
|
|
secure_is_locked() ? secure_unlock() : secure_lock();
|
|
|
|
return false;
|
|
|
|
}
|
2022-10-26 03:59:17 +06:00
|
|
|
if (keycode == QK_SECURE_REQUEST) {
|
2022-05-15 04:07:08 +06:00
|
|
|
secure_request_unlock();
|
|
|
|
return false;
|
|
|
|
}
|
2022-04-17 00:13:05 +06:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return true;
|
2022-05-15 04:07:08 +06:00
|
|
|
}
|