You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.0 KiB

  1. // Copyright 2022 QMK
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. /** \file
  5. *
  6. * Exposes a set of functionality to act as a virtual padlock for your device
  7. * ... As long as that padlock is made of paper and its currently raining.
  8. */
  9. #include <stdint.h>
  10. #include <stdbool.h>
  11. /** \brief Available secure states
  12. */
  13. typedef enum {
  14. SECURE_LOCKED,
  15. SECURE_PENDING,
  16. SECURE_UNLOCKED,
  17. } secure_status_t;
  18. /** \brief Query current secure state
  19. */
  20. secure_status_t secure_get_status(void);
  21. /** \brief Helper to check if unlocking is currently locked
  22. */
  23. #define secure_is_locked() (secure_get_status() == SECURE_LOCKED)
  24. /** \brief Helper to check if unlocking is currently in progress
  25. */
  26. #define secure_is_unlocking() (secure_get_status() == SECURE_PENDING)
  27. /** \brief Helper to check if unlocking is currently unlocked
  28. */
  29. #define secure_is_unlocked() (secure_get_status() == SECURE_UNLOCKED)
  30. /** \brief Lock down the device
  31. */
  32. void secure_lock(void);
  33. /** \brief Force unlock the device
  34. *
  35. * \warning bypasses user unlock sequence
  36. */
  37. void secure_unlock(void);
  38. /** \brief Begin listening for an unlock sequence
  39. */
  40. void secure_request_unlock(void);
  41. /** \brief Flag to the secure subsystem that user activity has happened
  42. *
  43. * Call when some user activity has happened and the device should remain unlocked
  44. */
  45. void secure_activity_event(void);
  46. /** \brief Flag to the secure subsystem that user has triggered a keypress
  47. *
  48. * Call to trigger processing of the unlock sequence
  49. */
  50. void secure_keypress_event(uint8_t row, uint8_t col);
  51. /** \brief Handle various secure subsystem background tasks
  52. */
  53. void secure_task(void);
  54. /** \brief quantum hook called when changing secure status device
  55. */
  56. void secure_hook_quantum(secure_status_t secure_status);
  57. /** \brief user hook called when changing secure status device
  58. */
  59. bool secure_hook_user(secure_status_t secure_status);
  60. /** \brief keyboard hook called when changing secure status device
  61. */
  62. bool secure_hook_kb(secure_status_t secure_status);