logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

leader.h (3071B)


  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. * \brief User callback, invoked when a keycode is added to the leader sequence.
  21. *
  22. * \param keycode The keycode added to the leader sequence.
  23. *
  24. * \return `true` to finish the key sequence, `false` to continue.
  25. */
  26. bool leader_add_user(uint16_t keycode);
  27. /**
  28. * Begin the leader sequence, resetting the buffer and timer.
  29. */
  30. void leader_start(void);
  31. /**
  32. * End the leader sequence.
  33. */
  34. void leader_end(void);
  35. void leader_task(void);
  36. /**
  37. * Whether the leader sequence is active.
  38. */
  39. bool leader_sequence_active(void);
  40. /**
  41. * Add the given keycode to the sequence buffer.
  42. *
  43. * If `LEADER_NO_TIMEOUT` is defined, the timer is reset if the buffer is empty.
  44. *
  45. * \param keycode The keycode to add.
  46. *
  47. * \return `true` if the keycode was added, `false` if the buffer is full.
  48. */
  49. bool leader_sequence_add(uint16_t keycode);
  50. /**
  51. * Whether the leader sequence has reached the timeout.
  52. *
  53. * If `LEADER_NO_TIMEOUT` is defined, the buffer must also contain at least one key.
  54. */
  55. bool leader_sequence_timed_out(void);
  56. /**
  57. * Reset the leader sequence timer.
  58. */
  59. void leader_reset_timer(void);
  60. /**
  61. * Check the sequence buffer for the given keycode.
  62. *
  63. * \param kc The keycode to check.
  64. *
  65. * \return `true` if the sequence buffer matches.
  66. */
  67. bool leader_sequence_one_key(uint16_t kc);
  68. /**
  69. * Check the sequence buffer for the given keycodes.
  70. *
  71. * \param kc1 The first keycode to check.
  72. * \param kc2 The second keycode to check.
  73. *
  74. * \return `true` if the sequence buffer matches.
  75. */
  76. bool leader_sequence_two_keys(uint16_t kc1, uint16_t kc2);
  77. /**
  78. * Check the sequence buffer for the given keycodes.
  79. *
  80. * \param kc1 The first keycode to check.
  81. * \param kc2 The second keycode to check.
  82. * \param kc3 The third keycode to check.
  83. *
  84. * \return `true` if the sequence buffer matches.
  85. */
  86. bool leader_sequence_three_keys(uint16_t kc1, uint16_t kc2, uint16_t kc3);
  87. /**
  88. * Check the sequence buffer for the given keycodes.
  89. *
  90. * \param kc1 The first keycode to check.
  91. * \param kc2 The second keycode to check.
  92. * \param kc3 The third keycode to check.
  93. * \param kc4 The fourth keycode to check.
  94. *
  95. * \return `true` if the sequence buffer matches.
  96. */
  97. bool leader_sequence_four_keys(uint16_t kc1, uint16_t kc2, uint16_t kc3, uint16_t kc4);
  98. /**
  99. * Check the sequence buffer for the given keycodes.
  100. *
  101. * \param kc1 The first keycode to check.
  102. * \param kc2 The second keycode to check.
  103. * \param kc3 The third keycode to check.
  104. * \param kc4 The fourth keycode to check.
  105. * \param kc5 The fifth keycode to check.
  106. *
  107. * \return `true` if the sequence buffer matches.
  108. */
  109. bool leader_sequence_five_keys(uint16_t kc1, uint16_t kc2, uint16_t kc3, uint16_t kc4, uint16_t kc5);
  110. /** \} */