qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

leader.h (3071B)


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