secure keycodes?

This commit is contained in:
zvecr 2022-04-13 00:37:44 +01:00
parent 2563e7b2a0
commit b0b6594ded
4 changed files with 35 additions and 2 deletions

View File

@ -3,8 +3,9 @@
#include "secure.h" #include "secure.h"
#include "process_secure.h" #include "process_secure.h"
#include "quantum_keycodes.h"
bool process_secure(uint16_t keycode, keyrecord_t *record) { bool preprocess_secure(uint16_t keycode, keyrecord_t *record) {
if (secure_is_unlocking()) { if (secure_is_unlocking()) {
if (!record->event.pressed) { if (!record->event.pressed) {
secure_keypress_event(record->event.key.row, record->event.key.col); secure_keypress_event(record->event.key.row, record->event.key.col);
@ -16,3 +17,23 @@ bool process_secure(uint16_t keycode, keyrecord_t *record) {
return true; 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_lock();
return false;
}
if (keycode == SECURE_TOGGLE) {
secure_is_locked() ? secure_unlock() : secure_lock();
return false;
}
}
#endif
return true;
}

View File

@ -6,4 +6,6 @@
#include <stdbool.h> #include <stdbool.h>
#include "action.h" #include "action.h"
bool preprocess_secure(uint16_t keycode, keyrecord_t *record);
bool process_secure(uint16_t keycode, keyrecord_t *record); bool process_secure(uint16_t keycode, keyrecord_t *record);

View File

@ -212,6 +212,12 @@ bool process_record_quantum(keyrecord_t *record) {
// return false; // return false;
// } // }
#if defined(SECURE_ENABLE)
if (!preprocess_secure(keycode, record)) {
return false;
}
#endif
#ifdef VELOCIKEY_ENABLE #ifdef VELOCIKEY_ENABLE
if (velocikey_enabled() && record->event.pressed) { if (velocikey_enabled() && record->event.pressed) {
velocikey_accelerate(); velocikey_accelerate();
@ -246,10 +252,10 @@ bool process_record_quantum(keyrecord_t *record) {
#if defined(VIA_ENABLE) #if defined(VIA_ENABLE)
process_record_via(keycode, record) && process_record_via(keycode, record) &&
#endif #endif
process_record_kb(keycode, record) &&
#if defined(SECURE_ENABLE) #if defined(SECURE_ENABLE)
process_secure(keycode, record) && process_secure(keycode, record) &&
#endif #endif
process_record_kb(keycode, record) &&
#if defined(SEQUENCER_ENABLE) #if defined(SEQUENCER_ENABLE)
process_sequencer(keycode, record) && process_sequencer(keycode, record) &&
#endif #endif

View File

@ -597,6 +597,10 @@ enum quantum_keycodes {
QK_MAKE, QK_MAKE,
SECURE_LOCK,
SECURE_UNLOCK,
SECURE_TOGGLE,
// Start of custom keycode range for keyboards and keymaps - always leave at the end // Start of custom keycode range for keyboards and keymaps - always leave at the end
SAFE_RANGE SAFE_RANGE
}; };