aboutsummaryrefslogtreecommitdiff
path: root/quantum/process_keycode
diff options
context:
space:
mode:
authorPavlos Vinieratos <pvinis@gmail.com>2016-07-15 23:54:08 +0200
committerPavlos Vinieratos <pvinis@gmail.com>2016-07-17 08:28:03 +0200
commitd3091faf363afc8fef73ddf4948f872439b0e827 (patch)
tree8741f3b0cf7ab54e3943598eafcef052faab30be /quantum/process_keycode
parentf3b56701ed7e6c622dc48e429780124ba5fde172 (diff)
downloadqmk_firmware-d3091faf363afc8fef73ddf4948f872439b0e827.tar.gz
qmk_firmware-d3091faf363afc8fef73ddf4948f872439b0e827.zip
change naming, and remove extraneous definition
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r--quantum/process_keycode/process_tap_dance.c32
-rw-r--r--quantum/process_keycode/process_tap_dance.h27
2 files changed, 23 insertions, 36 deletions
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c
index 40fba2a6a..93b326b5f 100644
--- a/quantum/process_keycode/process_tap_dance.c
+++ b/quantum/process_keycode/process_tap_dance.c
@@ -27,7 +27,7 @@ static void _process_tap_dance_action_fn (qk_tap_dance_state_t *state,
27 } 27 }
28} 28}
29 29
30void process_tap_dance_action (uint16_t keycode) 30void process_tap_dance_action_on_each_tap (uint16_t keycode)
31{ 31{
32 uint16_t idx = keycode - QK_TAP_DANCE; 32 uint16_t idx = keycode - QK_TAP_DANCE;
33 qk_tap_dance_action_t action; 33 qk_tap_dance_action_t action;
@@ -35,12 +35,8 @@ void process_tap_dance_action (uint16_t keycode)
35 action = tap_dance_actions[idx]; 35 action = tap_dance_actions[idx];
36 36
37 switch (action.type) { 37 switch (action.type) {
38 case QK_TAP_DANCE_TYPE_PAIR:
39 _process_tap_dance_action_pair (&qk_tap_dance_state,
40 action.pair.kc1, action.pair.kc2);
41 break;
42 case QK_TAP_DANCE_TYPE_FN: 38 case QK_TAP_DANCE_TYPE_FN:
43 _process_tap_dance_action_fn (&qk_tap_dance_state, action.fn.regular); 39 _process_tap_dance_action_fn (&qk_tap_dance_state, action.fn.on_each_tap);
44 break; 40 break;
45 41
46 default: 42 default:
@@ -48,7 +44,7 @@ void process_tap_dance_action (uint16_t keycode)
48 } 44 }
49} 45}
50 46
51void process_tap_dance_action_anyway (uint16_t keycode) 47void process_tap_dance_action_on_dance_finished (uint16_t keycode)
52{ 48{
53 uint16_t idx = keycode - QK_TAP_DANCE; 49 uint16_t idx = keycode - QK_TAP_DANCE;
54 qk_tap_dance_action_t action; 50 qk_tap_dance_action_t action;
@@ -56,8 +52,12 @@ void process_tap_dance_action_anyway (uint16_t keycode)
56 action = tap_dance_actions[idx]; 52 action = tap_dance_actions[idx];
57 53
58 switch (action.type) { 54 switch (action.type) {
55 case QK_TAP_DANCE_TYPE_PAIR:
56 _process_tap_dance_action_pair (&qk_tap_dance_state,
57 action.pair.kc1, action.pair.kc2);
58 break;
59 case QK_TAP_DANCE_TYPE_FN: 59 case QK_TAP_DANCE_TYPE_FN:
60 _process_tap_dance_action_fn (&qk_tap_dance_state, action.fn.anyway); 60 _process_tap_dance_action_fn (&qk_tap_dance_state, action.fn.on_dance_finished);
61 break; 61 break;
62 62
63 default: 63 default:
@@ -70,9 +70,9 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
70 70
71 switch(keycode) { 71 switch(keycode) {
72 case QK_TAP_DANCE ... QK_TAP_DANCE_MAX: 72 case QK_TAP_DANCE ... QK_TAP_DANCE_MAX:
73 process_tap_dance_action_anyway (qk_tap_dance_state.keycode); 73 process_tap_dance_action_on_each_tap (qk_tap_dance_state.keycode);
74 if (qk_tap_dance_state.keycode && qk_tap_dance_state.keycode != keycode) { 74 if (qk_tap_dance_state.keycode && qk_tap_dance_state.keycode != keycode) {
75 process_tap_dance_action (qk_tap_dance_state.keycode); 75 process_tap_dance_action_on_dance_finished (qk_tap_dance_state.keycode);
76 } else { 76 } else {
77 r = false; 77 r = false;
78 } 78 }
@@ -85,10 +85,9 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
85 break; 85 break;
86 86
87 default: 87 default:
88 process_tap_dance_action_on_each_tap (qk_tap_dance_state.keycode);
88 if (qk_tap_dance_state.keycode) { 89 if (qk_tap_dance_state.keycode) {
89 //process_tap_dance_action_anyway (qk_tap_dance_state.keycode); 90 process_tap_dance_action_on_dance_finished (qk_tap_dance_state.keycode);
90 process_tap_dance_action (qk_tap_dance_state.keycode);
91
92 reset_tap_dance (&qk_tap_dance_state); 91 reset_tap_dance (&qk_tap_dance_state);
93 } 92 }
94 break; 93 break;
@@ -99,8 +98,7 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
99 98
100void matrix_scan_tap_dance () { 99void matrix_scan_tap_dance () {
101 if (qk_tap_dance_state.keycode && timer_elapsed (qk_tap_dance_state.timer) > TAPPING_TERM) { 100 if (qk_tap_dance_state.keycode && timer_elapsed (qk_tap_dance_state.timer) > TAPPING_TERM) {
102 process_tap_dance_action (qk_tap_dance_state.keycode); 101 process_tap_dance_action_on_dance_finished (qk_tap_dance_state.keycode);
103
104 reset_tap_dance (&qk_tap_dance_state); 102 reset_tap_dance (&qk_tap_dance_state);
105 } 103 }
106} 104}
@@ -112,8 +110,8 @@ void reset_tap_dance (qk_tap_dance_state_t *state) {
112 action = tap_dance_actions[idx]; 110 action = tap_dance_actions[idx];
113 switch (action.type) { 111 switch (action.type) {
114 case QK_TAP_DANCE_TYPE_FN: 112 case QK_TAP_DANCE_TYPE_FN:
115 if (action.fn.reset) { 113 if (action.fn.on_reset) {
116 action.fn.reset(); 114 action.fn.on_reset(state);
117 } 115 }
118 break; 116 break;
119 117
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h
index bf925df0f..7b820584a 100644
--- a/quantum/process_keycode/process_tap_dance.h
+++ b/quantum/process_keycode/process_tap_dance.h
@@ -22,7 +22,6 @@ typedef enum
22} qk_tap_dance_type_t; 22} qk_tap_dance_type_t;
23 23
24typedef void (*qk_tap_dance_user_fn_t) (qk_tap_dance_state_t *state); 24typedef void (*qk_tap_dance_user_fn_t) (qk_tap_dance_state_t *state);
25typedef void (*qk_tap_dance_user_fn_reset_t) (void);
26 25
27typedef struct 26typedef struct
28{ 27{
@@ -33,9 +32,9 @@ typedef struct
33 uint16_t kc2; 32 uint16_t kc2;
34 } pair; 33 } pair;
35 struct { 34 struct {
36 qk_tap_dance_user_fn_t regular; 35 qk_tap_dance_user_fn_t on_each_tap;
37 qk_tap_dance_user_fn_t anyway; 36 qk_tap_dance_user_fn_t on_dance_finished;
38 qk_tap_dance_user_fn_reset_t reset; 37 qk_tap_dance_user_fn_t on_reset;
39 } fn; 38 } fn;
40 }; 39 };
41} qk_tap_dance_action_t; 40} qk_tap_dance_action_t;
@@ -45,24 +44,14 @@ typedef struct
45 .pair = { kc1, kc2 } \ 44 .pair = { kc1, kc2 } \
46 } 45 }
47 46
48#define ACTION_TAP_DANCE_FN(user_fn) { \ 47#define ACTION_TAP_DANCE_FN(user_fn) { \
49 .type = QK_TAP_DANCE_TYPE_FN, \ 48 .type = QK_TAP_DANCE_TYPE_FN, \
50 .fn = { user_fn, NULL, NULL } \ 49 .fn = { NULL, user_fn, NULL } \
51 } 50 }
52 51
53#define ACTION_TAP_DANCE_FN_ANYWAY(user_fn, user_fn_anyway) { \ 52#define ACTION_TAP_DANCE_FN_ADVANCED(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_reset) { \
54 .type = QK_TAP_DANCE_TYPE_FN, \ 53 .type = QK_TAP_DANCE_TYPE_FN, \
55 .fn = { user_fn, user_fn_anyway, NULL } \ 54 .fn = { user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_reset } \
56 }
57
58#define ACTION_TAP_DANCE_FN_RESET(user_fn, user_fn_reset) { \
59 .type = QK_TAP_DANCE_TYPE_FN, \
60 .fn = { user_fn, NULL, user_fn_reset } \
61 }
62
63#define ACTION_TAP_DANCE_FN_ANYWAY_RESET(user_fn, user_fn_anyway, user_fn_reset) { \
64 .type = QK_TAP_DANCE_TYPE_FN, \
65 .fn = { user_fn, user_fn_anyway, user_fn_reset } \
66 } 55 }
67 56
68extern const qk_tap_dance_action_t tap_dance_actions[]; 57extern const qk_tap_dance_action_t tap_dance_actions[];