summaryrefslogtreecommitdiffstats
path: root/quantum/process_keycode/process_secure.c
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2022-04-16 19:13:05 +0100
committerGitHub <noreply@github.com>2022-04-16 11:13:05 -0700
commit92a61aa0cd9a28056e6979f01a72b8742702dbfe (patch)
treea09ed136ab6355a762757cbffb5f836cb1b35b11 /quantum/process_keycode/process_secure.c
parentae4d518352204d1d7bdf32427b569a03f35fb494 (diff)
Implement XAP 'secure' core requirements (#16843)
Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Stefan Kerkmann <karlk90@pm.me>
Diffstat (limited to 'quantum/process_keycode/process_secure.c')
-rw-r--r--quantum/process_keycode/process_secure.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/quantum/process_keycode/process_secure.c b/quantum/process_keycode/process_secure.c
new file mode 100644
index 0000000000..827ace597a
--- /dev/null
+++ b/quantum/process_keycode/process_secure.c
@@ -0,0 +1,39 @@
+// 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()) {
+ if (!record->event.pressed) {
+ 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) {
+ if (keycode == SECURE_LOCK) {
+ secure_lock();
+ return false;
+ }
+ if (keycode == SECURE_UNLOCK) {
+ secure_unlock();
+ return false;
+ }
+ if (keycode == SECURE_TOGGLE) {
+ secure_is_locked() ? secure_unlock() : secure_lock();
+ return false;
+ }
+ }
+#endif
+ return true;
+} \ No newline at end of file