Align location of tap dance keycode (#22742)

This commit is contained in:
Joel Challis 2023-12-24 06:52:41 +00:00 committed by GitHub
parent 03848bb3aa
commit b824faca71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 7 deletions

View file

@ -173,7 +173,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) { switch (keycode) {
case TD(CT_CLN): // list all tap dance keycodes with tap-hold configurations case TD(CT_CLN): // list all tap dance keycodes with tap-hold configurations
action = &tap_dance_actions[TD_INDEX(keycode)]; action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(keycode)];
if (!record->event.pressed && action->state.count && !action->state.finished) { if (!record->event.pressed && action->state.count && !action->state.finished) {
tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data; tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data;
tap_code16(tap_hold->tap); tap_code16(tap_hold->tap);

View file

@ -133,7 +133,7 @@ bool preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) {
if (!active_td || keycode == active_td) return false; if (!active_td || keycode == active_td) return false;
action = &tap_dance_actions[TD_INDEX(active_td)]; action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(active_td)];
action->state.interrupted = true; action->state.interrupted = true;
action->state.interrupting_keycode = keycode; action->state.interrupting_keycode = keycode;
process_tap_dance_action_on_dance_finished(action); process_tap_dance_action_on_dance_finished(action);
@ -154,7 +154,7 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
switch (keycode) { switch (keycode) {
case QK_TAP_DANCE ... QK_TAP_DANCE_MAX: case QK_TAP_DANCE ... QK_TAP_DANCE_MAX:
action = &tap_dance_actions[TD_INDEX(keycode)]; action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(keycode)];
action->state.pressed = record->event.pressed; action->state.pressed = record->event.pressed;
if (record->event.pressed) { if (record->event.pressed) {
@ -182,7 +182,7 @@ void tap_dance_task(void) {
if (!active_td || timer_elapsed(last_tap_time) <= GET_TAPPING_TERM(active_td, &(keyrecord_t){})) return; if (!active_td || timer_elapsed(last_tap_time) <= GET_TAPPING_TERM(active_td, &(keyrecord_t){})) return;
action = &tap_dance_actions[TD_INDEX(active_td)]; action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(active_td)];
if (!action->state.interrupted) { if (!action->state.interrupted) {
process_tap_dance_action_on_dance_finished(action); process_tap_dance_action_on_dance_finished(action);
} }

View file

@ -19,6 +19,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include "action.h" #include "action.h"
#include "quantum_keycodes.h"
typedef struct { typedef struct {
uint16_t interrupting_keycode; uint16_t interrupting_keycode;
@ -74,8 +75,7 @@ typedef struct {
#define ACTION_TAP_DANCE_FN_ADVANCED_WITH_RELEASE(user_fn_on_each_tap, user_fn_on_each_release, user_fn_on_dance_finished, user_fn_on_dance_reset) \ #define ACTION_TAP_DANCE_FN_ADVANCED_WITH_RELEASE(user_fn_on_each_tap, user_fn_on_each_release, user_fn_on_dance_finished, user_fn_on_dance_reset) \
{ .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset, user_fn_on_each_release}, .user_data = NULL, } { .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset, user_fn_on_each_release}, .user_data = NULL, }
#define TD(n) (QK_TAP_DANCE | TD_INDEX(n)) #define TD_INDEX(code) QK_TAP_DANCE_GET_INDEX(code)
#define TD_INDEX(code) ((code)&0xFF)
#define TAP_DANCE_KEYCODE(state) TD(((tap_dance_action_t *)state) - tap_dance_actions) #define TAP_DANCE_KEYCODE(state) TD(((tap_dance_action_t *)state) - tap_dance_actions)
extern tap_dance_action_t tap_dance_actions[]; extern tap_dance_action_t tap_dance_actions[];

View file

@ -190,6 +190,10 @@
#define SH_T(kc) (QK_SWAP_HANDS | ((kc)&0xFF)) #define SH_T(kc) (QK_SWAP_HANDS | ((kc)&0xFF))
#define QK_SWAP_HANDS_GET_TAP_KEYCODE(kc) ((kc)&0xFF) #define QK_SWAP_HANDS_GET_TAP_KEYCODE(kc) ((kc)&0xFF)
// Tap dance
#define TD(i) (QK_TAP_DANCE | ((i)&0xFF))
#define QK_TAP_DANCE_GET_INDEX(kc) ((kc)&0xFF)
// MIDI aliases // MIDI aliases
#define MIDI_TONE_MIN QK_MIDI_NOTE_C_0 #define MIDI_TONE_MIN QK_MIDI_NOTE_C_0
#define MIDI_TONE_MAX QK_MIDI_NOTE_B_5 #define MIDI_TONE_MAX QK_MIDI_NOTE_B_5

View file

@ -83,7 +83,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) { switch (keycode) {
case TD(CT_CLN): case TD(CT_CLN):
action = &tap_dance_actions[TD_INDEX(keycode)]; action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(keycode)];
if (!record->event.pressed && action->state.count && !action->state.finished) { if (!record->event.pressed && action->state.count && !action->state.finished) {
tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data; tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data;
tap_code16(tap_hold->tap); tap_code16(tap_hold->tap);