~ruther/qmk_firmware

f5b74918837bacc5aaa98641428309380d591707 — Albert Y 2 years ago 5d6d959
Add swap hands toggle functions (#20381)

3 files changed, 33 insertions(+), 3 deletions(-)

M docs/feature_swap_hands.md
M quantum/action.c
M quantum/action.h
M docs/feature_swap_hands.md => docs/feature_swap_hands.md +8 -3
@@ 47,6 47,11 @@ const uint8_t PROGMEM encoder_hand_swap_config[NUM_ENCODERS] = { 1, 0 };

### Functions :id=functions

| Function             | Description                                 |
|----------------------|---------------------------------------------|
| `is_swap_hands_on()` | Returns true if Swap-Hands is currently on. |
User callback functions to manipulate Swap-Hands:

| Function              | Description                                 |
|-----------------------|---------------------------------------------|
| `swap_hands_on()`     | Turns Swap-Hands on.                        |
| `swap_hands_off()`    | Turns Swap-Hands off.                       |
| `swap_hands_toggle()` | Toggles Swap-Hands.                         |
| `is_swap_hands_on()`  | Returns true if Swap-Hands is currently on. |

M quantum/action.c => quantum/action.c +12 -0
@@ 165,6 165,18 @@ void set_swap_hands_state(size_t index, uint8_t *swap_state, bool on) {
    }
}

void swap_hands_on(void) {
    swap_hands = true;
}

void swap_hands_off(void) {
    swap_hands = false;
}

void swap_hands_toggle(void) {
    swap_hands = !swap_hands;
}

bool is_swap_hands_on(void) {
    return swap_hands;
}

M quantum/action.h => quantum/action.h +13 -0
@@ 85,12 85,25 @@ typedef uint32_t swap_state_row_t;
#    endif

/**
 * @brief Enable swap hands
 */
void swap_hands_on(void);
/**
 * @brief Disable swap hands
 */
void swap_hands_off(void);
/**
 * @brief Toggle swap hands enable state
 */
void swap_hands_toggle(void);
/**
 * @brief Get the swap hands enable state
 *
 * @return true
 * @return false
 */
bool is_swap_hands_on(void);

void process_hand_swap(keyevent_t *record);
#endif