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.

119 lines
2.7 KiB

  1. // Copyright 2023 QMK
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. /**
  6. * \file
  7. *
  8. * \defgroup leader Leader Key
  9. * \{
  10. */
  11. /**
  12. * \brief User callback, invoked when the leader sequence begins.
  13. */
  14. void leader_start_user(void);
  15. /**
  16. * \brief User callback, invoked when the leader sequence ends.
  17. */
  18. void leader_end_user(void);
  19. /**
  20. * Begin the leader sequence, resetting the buffer and timer.
  21. */
  22. void leader_start(void);
  23. /**
  24. * End the leader sequence.
  25. */
  26. void leader_end(void);
  27. void leader_task(void);
  28. /**
  29. * Whether the leader sequence is active.
  30. */
  31. bool leader_sequence_active(void);
  32. /**
  33. * Add the given keycode to the sequence buffer.
  34. *
  35. * If `LEADER_NO_TIMEOUT` is defined, the timer is reset if the buffer is empty.
  36. *
  37. * \param keycode The keycode to add.
  38. *
  39. * \return `true` if the keycode was added, `false` if the buffer is full.
  40. */
  41. bool leader_sequence_add(uint16_t keycode);
  42. /**
  43. * Whether the leader sequence has reached the timeout.
  44. *
  45. * If `LEADER_NO_TIMEOUT` is defined, the buffer must also contain at least one key.
  46. */
  47. bool leader_sequence_timed_out(void);
  48. /**
  49. * Reset the leader sequence timer.
  50. */
  51. void leader_reset_timer(void);
  52. /**
  53. * Check the sequence buffer for the given keycode.
  54. *
  55. * \param kc The keycode to check.
  56. *
  57. * \return `true` if the sequence buffer matches.
  58. */
  59. bool leader_sequence_one_key(uint16_t kc);
  60. /**
  61. * Check the sequence buffer for the given keycodes.
  62. *
  63. * \param kc1 The first keycode to check.
  64. * \param kc2 The second keycode to check.
  65. *
  66. * \return `true` if the sequence buffer matches.
  67. */
  68. bool leader_sequence_two_keys(uint16_t kc1, uint16_t kc2);
  69. /**
  70. * Check the sequence buffer for the given keycodes.
  71. *
  72. * \param kc1 The first keycode to check.
  73. * \param kc2 The second keycode to check.
  74. * \param kc3 The third keycode to check.
  75. *
  76. * \return `true` if the sequence buffer matches.
  77. */
  78. bool leader_sequence_three_keys(uint16_t kc1, uint16_t kc2, uint16_t kc3);
  79. /**
  80. * Check the sequence buffer for the given keycodes.
  81. *
  82. * \param kc1 The first keycode to check.
  83. * \param kc2 The second keycode to check.
  84. * \param kc3 The third keycode to check.
  85. * \param kc4 The fourth keycode to check.
  86. *
  87. * \return `true` if the sequence buffer matches.
  88. */
  89. bool leader_sequence_four_keys(uint16_t kc1, uint16_t kc2, uint16_t kc3, uint16_t kc4);
  90. /**
  91. * Check the sequence buffer for the given keycodes.
  92. *
  93. * \param kc1 The first keycode to check.
  94. * \param kc2 The second keycode to check.
  95. * \param kc3 The third keycode to check.
  96. * \param kc4 The fourth keycode to check.
  97. * \param kc5 The fifth keycode to check.
  98. *
  99. * \return `true` if the sequence buffer matches.
  100. */
  101. bool leader_sequence_five_keys(uint16_t kc1, uint16_t kc2, uint16_t kc3, uint16_t kc4, uint16_t kc5);
  102. /** \} */