From 9908ed7ecd1bc0c45f0322b959811bd8fd641961 Mon Sep 17 00:00:00 2001 From: Albert Y <76888457+filterpaper@users.noreply.github.com> Date: Wed, 15 Feb 2023 04:44:18 +0800 Subject: [PATCH] Add swap hands status function (#19831) Co-authored-by: Drashna Jaelre --- docs/feature_swap_hands.md | 6 ++++++ quantum/action.c | 4 ++++ quantum/action.h | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/docs/feature_swap_hands.md b/docs/feature_swap_hands.md index 35131884e1..4d0d554093 100644 --- a/docs/feature_swap_hands.md +++ b/docs/feature_swap_hands.md @@ -44,3 +44,9 @@ As an example, if a split keyboard has a single encoder per side, you can swap t const uint8_t PROGMEM encoder_hand_swap_config[NUM_ENCODERS] = { 1, 0 }; #endif ``` + +### Functions :id=functions + +| Function | Description | +|----------------------|---------------------------------------------| +| `is_swap_hands_on()` | Returns true if Swap-Hands is currently on. | diff --git a/quantum/action.c b/quantum/action.c index ee412db393..d2e54bf8ec 100644 --- a/quantum/action.c +++ b/quantum/action.c @@ -161,6 +161,10 @@ void set_swap_hands_state(size_t index, uint8_t *swap_state, bool on) { } } +bool is_swap_hands_on(void) { + return swap_hands; +} + /** \brief Process Hand Swap * * FIXME: Needs documentation. diff --git a/quantum/action.h b/quantum/action.h index e4d28ba947..8ef6db6781 100644 --- a/quantum/action.h +++ b/quantum/action.h @@ -84,6 +84,13 @@ typedef uint32_t swap_state_row_t; # error "MATRIX_COLS: invalid value" # endif +/** + * @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