summaryrefslogtreecommitdiffstats
path: root/quantum/process_keycode/process_tap_dance.h
diff options
context:
space:
mode:
authorGergely Nagy <algernon@madhouse-project.org>2016-08-17 13:04:50 +0200
committerGergely Nagy <algernon@madhouse-project.org>2016-08-17 15:05:58 +0200
commit29f64d7a93d941167c6c6e95f893ab84586b2205 (patch)
tree673ae25744608863609e022dbb0600c830893157 /quantum/process_keycode/process_tap_dance.h
parentd78058cc75a9b05a6885991506d5f807ebb2a9f9 (diff)
downloadqmk_firmware-29f64d7a93d941167c6c6e95f893ab84586b2205.tar.gz
qmk_firmware-29f64d7a93d941167c6c6e95f893ab84586b2205.tar.xz
tap-dance: Major rework, to make it more reliable
This reworks how the tap-dance feature works: instead of one global state, we have a state for each tap-dance key, so we can cancel them when another tap-dance key is in flight. This fixes #527. Since we have a state for each key, we can avoid situation where a keyup would mess with our global state. This fixes #563. And while here, we also make sure to fire events only once, and this fixes #574. There is one breaking change, though: tap-dance debugging support was removed, because dumping the whole state would increase the firmware size too much. Any keymap that made use of this, will have to be updated (but there's no such keymap in the repo). Also, there's a nice trick used in this rework: we need to iterate through tap_dance_actions in a few places, to check for timeouts, and so on. For this, we'd need to know the size of the array. We can't discover that at compile-time, because tap-dance gets compiled separately. We'd like to avoid having to terminate the list with a sentinel value, because that would require updates to all keymaps that use the feature. So, we keep track of the highest tap-dance code seen so far, and iterate until that index. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Diffstat (limited to 'quantum/process_keycode/process_tap_dance.h')
-rw-r--r--quantum/process_keycode/process_tap_dance.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h
index 6a1258067..d7b857bdc 100644
--- a/quantum/process_keycode/process_tap_dance.h
+++ b/quantum/process_keycode/process_tap_dance.h
@@ -11,8 +11,9 @@ typedef struct
uint8_t count;
uint16_t keycode;
uint16_t timer;
- bool active:1;
- bool pressed:1;
+ bool interrupted;
+ bool pressed;
+ bool finished;
} qk_tap_dance_state_t;
#define TD(n) (QK_TAP_DANCE + n)
@@ -26,6 +27,7 @@ typedef struct
qk_tap_dance_user_fn_t on_dance_finished;
qk_tap_dance_user_fn_t on_reset;
} fn;
+ qk_tap_dance_state_t state;
void *user_data;
} qk_tap_dance_action_t;
@@ -48,8 +50,7 @@ typedef struct
.fn = { user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_reset } \
}
-extern const qk_tap_dance_action_t tap_dance_actions[];
-extern bool td_debug_enable;
+extern qk_tap_dance_action_t tap_dance_actions[];
/* To be used internally */