qmk_firmware/quantum/secure.h

68 lines
1.6 KiB
C
Raw Normal View History

2022-04-10 23:43:18 +00:00
// Copyright 2022 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
/** \file
*
* Exposes a set of functionality to act as a virtual padlock for your device
* ... As long as that padlock is made of paper and its currently raining.
*/
2022-04-10 23:43:18 +00:00
#include <stdint.h>
#include <stdbool.h>
/** \brief Available secure states
*/
2022-04-10 23:43:18 +00:00
typedef enum {
SECURE_LOCKED,
SECURE_PENDING,
SECURE_UNLOCKED,
} secure_status_t;
/** \brief Query current secure state
*/
2022-04-10 23:43:18 +00:00
secure_status_t secure_get_status(void);
/** \brief Helper to check if unlocking is currently locked
*/
#define secure_is_locked() (secure_get_status() == SECURE_LOCKED)
/** \brief Helper to check if unlocking is currently in progress
*/
#define secure_is_unlocking() (secure_get_status() == SECURE_PENDING)
/** \brief Helper to check if unlocking is currently unlocked
*/
#define secure_is_unlocked() (secure_get_status() == SECURE_UNLOCKED)
2022-04-10 23:43:18 +00:00
/** \brief Lock down the device
*/
2022-04-10 23:43:18 +00:00
void secure_lock(void);
/** \brief Force unlock the device
*
* \warning bypasses user unlock sequence
*/
2022-04-10 23:43:18 +00:00
void secure_unlock(void);
/** \brief Begin listening for an unlock sequence
*/
2022-04-10 23:43:18 +00:00
void secure_request_unlock(void);
/** \brief Flag to the secure subsystem that user activity has happened
*
* Call when some user activity has happened and the device should remain unlocked
*/
2022-04-11 01:14:19 +00:00
void secure_activity_event(void);
/** \brief Flag to the secure subsystem that user has triggered a keypress
*
* Call to trigger processing of the unlock sequence
*/
2022-04-10 23:43:18 +00:00
void secure_keypress_event(uint8_t row, uint8_t col);
/** \brief Handle various secure subsystem background tasks
*/
2022-04-10 23:43:18 +00:00
void secure_task(void);