diff options
| author | tmk <nobody@nowhere> | 2013-07-21 10:44:21 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-07-21 10:44:21 +0900 |
| commit | 25aec56c082936a463d609357a04332c97c9940b (patch) | |
| tree | 5c3813a5391b9b10f1dc07b259d075729f9c6344 /common/action_tapping.c | |
| parent | 86623f57247c92242751ceae4cb291e7f3d19540 (diff) | |
| parent | 3e023e5b0cf15d3008346c6b946ae3adc51f7f18 (diff) | |
| download | qmk_firmware-25aec56c082936a463d609357a04332c97c9940b.tar.gz qmk_firmware-25aec56c082936a463d609357a04332c97c9940b.zip | |
Merge branch 'bob_fix'
Diffstat (limited to 'common/action_tapping.c')
| -rw-r--r-- | common/action_tapping.c | 71 |
1 files changed, 45 insertions, 26 deletions
diff --git a/common/action_tapping.c b/common/action_tapping.c index 8b466079d..9b5512a8e 100644 --- a/common/action_tapping.c +++ b/common/action_tapping.c | |||
| @@ -88,16 +88,16 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 88 | // first tap! | 88 | // first tap! |
| 89 | debug("Tapping: First tap(0->1).\n"); | 89 | debug("Tapping: First tap(0->1).\n"); |
| 90 | tapping_key.tap.count = 1; | 90 | tapping_key.tap.count = 1; |
| 91 | tapping_key.tap.interrupted = (waiting_buffer_has_anykey_pressed() ? true : false); | ||
| 92 | debug_tapping_key(); | 91 | debug_tapping_key(); |
| 93 | process_action(&tapping_key); | 92 | process_action(&tapping_key); |
| 94 | 93 | ||
| 95 | // enqueue | 94 | // copy tapping state |
| 96 | keyp->tap = tapping_key.tap; | 95 | keyp->tap = tapping_key.tap; |
| 96 | // enqueue | ||
| 97 | return false; | 97 | return false; |
| 98 | } | 98 | } |
| 99 | #if TAPPING_TERM >= 500 | 99 | #if TAPPING_TERM >= 500 |
| 100 | /* This can prevent from typing some tap keys in a row at a time. */ | 100 | /* This can settle mod/fn state fast but may prevent from typing fast. */ |
| 101 | else if (!event.pressed && waiting_buffer_typed(event)) { | 101 | else if (!event.pressed && waiting_buffer_typed(event)) { |
| 102 | // other key typed. not tap. | 102 | // other key typed. not tap. |
| 103 | debug("Tapping: End. No tap. Interfered by typing key\n"); | 103 | debug("Tapping: End. No tap. Interfered by typing key\n"); |
| @@ -110,7 +110,11 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 110 | } | 110 | } |
| 111 | #endif | 111 | #endif |
| 112 | else { | 112 | else { |
| 113 | // other key events shall be enq'd till tapping state settles. | 113 | // set interrupted flag when other key preesed during tapping |
| 114 | if (event.pressed) { | ||
| 115 | tapping_key.tap.interrupted = true; | ||
| 116 | } | ||
| 117 | // enqueue | ||
| 114 | return false; | 118 | return false; |
| 115 | } | 119 | } |
| 116 | } | 120 | } |
| @@ -124,7 +128,7 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 124 | debug_tapping_key(); | 128 | debug_tapping_key(); |
| 125 | return true; | 129 | return true; |
| 126 | } | 130 | } |
| 127 | else if (is_tap_key(keyp->event.key) && event.pressed) { | 131 | else if (is_tap_key(event.key) && event.pressed) { |
| 128 | if (tapping_key.tap.count > 1) { | 132 | if (tapping_key.tap.count > 1) { |
| 129 | debug("Tapping: Start new tap with releasing last tap(>1).\n"); | 133 | debug("Tapping: Start new tap with releasing last tap(>1).\n"); |
| 130 | // unregister key | 134 | // unregister key |
| @@ -143,7 +147,7 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 143 | return true; | 147 | return true; |
| 144 | } | 148 | } |
| 145 | else { | 149 | else { |
| 146 | if (!IS_NOEVENT(keyp->event)) { | 150 | if (!IS_NOEVENT(event)) { |
| 147 | debug("Tapping: key event while last tap(>0).\n"); | 151 | debug("Tapping: key event while last tap(>0).\n"); |
| 148 | } | 152 | } |
| 149 | process_action(keyp); | 153 | process_action(keyp); |
| @@ -168,7 +172,7 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 168 | tapping_key = (keyrecord_t){}; | 172 | tapping_key = (keyrecord_t){}; |
| 169 | return true; | 173 | return true; |
| 170 | } | 174 | } |
| 171 | else if (is_tap_key(keyp->event.key) && event.pressed) { | 175 | else if (is_tap_key(event.key) && event.pressed) { |
| 172 | if (tapping_key.tap.count > 1) { | 176 | if (tapping_key.tap.count > 1) { |
| 173 | debug("Tapping: Start new tap with releasing last timeout tap(>1).\n"); | 177 | debug("Tapping: Start new tap with releasing last timeout tap(>1).\n"); |
| 174 | // unregister key | 178 | // unregister key |
| @@ -187,7 +191,7 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 187 | return true; | 191 | return true; |
| 188 | } | 192 | } |
| 189 | else { | 193 | else { |
| 190 | if (!IS_NOEVENT(keyp->event)) { | 194 | if (!IS_NOEVENT(event)) { |
| 191 | debug("Tapping: key event while last timeout tap(>0).\n"); | 195 | debug("Tapping: key event while last timeout tap(>0).\n"); |
| 192 | } | 196 | } |
| 193 | process_action(keyp); | 197 | process_action(keyp); |
| @@ -197,28 +201,43 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 197 | } | 201 | } |
| 198 | } else if (IS_TAPPING_RELEASED()) { | 202 | } else if (IS_TAPPING_RELEASED()) { |
| 199 | if (WITHIN_TAPPING_TERM(event)) { | 203 | if (WITHIN_TAPPING_TERM(event)) { |
| 200 | if (tapping_key.tap.count > 0 && IS_TAPPING_KEY(event.key) && event.pressed) { | 204 | if (event.pressed) { |
| 201 | // sequential tap. | 205 | if (IS_TAPPING_KEY(event.key)) { |
| 202 | keyp->tap = tapping_key.tap; | 206 | if (!tapping_key.tap.interrupted && tapping_key.tap.count > 0) { |
| 203 | keyp->tap.count += 1; | 207 | // sequential tap. |
| 204 | debug("Tapping: Tap press("); debug_dec(keyp->tap.count); debug(")\n"); | 208 | keyp->tap = tapping_key.tap; |
| 205 | process_action(keyp); | 209 | keyp->tap.count += 1; |
| 206 | tapping_key = *keyp; | 210 | debug("Tapping: Tap press("); debug_dec(keyp->tap.count); debug(")\n"); |
| 207 | debug_tapping_key(); | 211 | process_action(keyp); |
| 208 | return true; | 212 | tapping_key = *keyp; |
| 209 | } else if (event.pressed && is_tap_key(event.key)) { | 213 | debug_tapping_key(); |
| 210 | // Sequential tap can be interfered with other tap key. | 214 | return true; |
| 211 | debug("Tapping: Start with interfering other tap.\n"); | 215 | } else { |
| 212 | tapping_key = *keyp; | 216 | // FIX: start new tap again |
| 213 | waiting_buffer_scan_tap(); | 217 | tapping_key = *keyp; |
| 214 | debug_tapping_key(); | 218 | return true; |
| 215 | return true; | 219 | } |
| 220 | } else if (is_tap_key(event.key)) { | ||
| 221 | // Sequential tap can be interfered with other tap key. | ||
| 222 | debug("Tapping: Start with interfering other tap.\n"); | ||
| 223 | tapping_key = *keyp; | ||
| 224 | waiting_buffer_scan_tap(); | ||
| 225 | debug_tapping_key(); | ||
| 226 | return true; | ||
| 227 | } else { | ||
| 228 | // should none in buffer | ||
| 229 | // FIX: interrupted when other key is pressed | ||
| 230 | tapping_key.tap.interrupted = true; | ||
| 231 | process_action(keyp); | ||
| 232 | return true; | ||
| 233 | } | ||
| 216 | } else { | 234 | } else { |
| 217 | if (!IS_NOEVENT(keyp->event)) debug("Tapping: other key just after tap.\n"); | 235 | if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n"); |
| 218 | process_action(keyp); | 236 | process_action(keyp); |
| 219 | return true; | 237 | return true; |
| 220 | } | 238 | } |
| 221 | } else { | 239 | } else { |
| 240 | // FIX: process_aciton here? | ||
| 222 | // timeout. no sequential tap. | 241 | // timeout. no sequential tap. |
| 223 | debug("Tapping: End(Timeout after releasing last tap): "); | 242 | debug("Tapping: End(Timeout after releasing last tap): "); |
| 224 | debug_event(event); debug("\n"); | 243 | debug_event(event); debug("\n"); |
| @@ -227,7 +246,7 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 227 | return false; | 246 | return false; |
| 228 | } | 247 | } |
| 229 | } | 248 | } |
| 230 | // not tapping satate | 249 | // not tapping state |
| 231 | else { | 250 | else { |
| 232 | if (event.pressed && is_tap_key(event.key)) { | 251 | if (event.pressed && is_tap_key(event.key)) { |
| 233 | debug("Tapping: Start(Press tap key).\n"); | 252 | debug("Tapping: Start(Press tap key).\n"); |
