Cancel tapping when interrupted by other key

daktil_thumb_popravljen
tmk 2013-07-21 03:21:57 +09:00
parent f8fbecff4d
commit 3e023e5b0c
1 changed files with 45 additions and 26 deletions

View File

@ -88,16 +88,16 @@ bool process_tapping(keyrecord_t *keyp)
// first tap! // first tap!
debug("Tapping: First tap(0->1).\n"); debug("Tapping: First tap(0->1).\n");
tapping_key.tap.count = 1; tapping_key.tap.count = 1;
tapping_key.tap.interrupted = (waiting_buffer_has_anykey_pressed() ? true : false);
debug_tapping_key(); debug_tapping_key();
process_action(&tapping_key); process_action(&tapping_key);
// enqueue // copy tapping state
keyp->tap = tapping_key.tap; keyp->tap = tapping_key.tap;
// enqueue
return false; return false;
} }
#if TAPPING_TERM >= 500 #if TAPPING_TERM >= 500
/* This can prevent from typing some tap keys in a row at a time. */ /* This can settle mod/fn state fast but may prevent from typing fast. */
else if (!event.pressed && waiting_buffer_typed(event)) { else if (!event.pressed && waiting_buffer_typed(event)) {
// other key typed. not tap. // other key typed. not tap.
debug("Tapping: End. No tap. Interfered by typing key\n"); debug("Tapping: End. No tap. Interfered by typing key\n");
@ -110,7 +110,11 @@ bool process_tapping(keyrecord_t *keyp)
} }
#endif #endif
else { else {
// other key events shall be enq'd till tapping state settles. // set interrupted flag when other key preesed during tapping
if (event.pressed) {
tapping_key.tap.interrupted = true;
}
// enqueue
return false; return false;
} }
} }
@ -124,7 +128,7 @@ bool process_tapping(keyrecord_t *keyp)
debug_tapping_key(); debug_tapping_key();
return true; return true;
} }
else if (is_tap_key(keyp->event.key) && event.pressed) { else if (is_tap_key(event.key) && event.pressed) {
if (tapping_key.tap.count > 1) { if (tapping_key.tap.count > 1) {
debug("Tapping: Start new tap with releasing last tap(>1).\n"); debug("Tapping: Start new tap with releasing last tap(>1).\n");
// unregister key // unregister key
@ -143,7 +147,7 @@ bool process_tapping(keyrecord_t *keyp)
return true; return true;
} }
else { else {
if (!IS_NOEVENT(keyp->event)) { if (!IS_NOEVENT(event)) {
debug("Tapping: key event while last tap(>0).\n"); debug("Tapping: key event while last tap(>0).\n");
} }
process_action(keyp); process_action(keyp);
@ -168,7 +172,7 @@ bool process_tapping(keyrecord_t *keyp)
tapping_key = (keyrecord_t){}; tapping_key = (keyrecord_t){};
return true; return true;
} }
else if (is_tap_key(keyp->event.key) && event.pressed) { else if (is_tap_key(event.key) && event.pressed) {
if (tapping_key.tap.count > 1) { if (tapping_key.tap.count > 1) {
debug("Tapping: Start new tap with releasing last timeout tap(>1).\n"); debug("Tapping: Start new tap with releasing last timeout tap(>1).\n");
// unregister key // unregister key
@ -187,7 +191,7 @@ bool process_tapping(keyrecord_t *keyp)
return true; return true;
} }
else { else {
if (!IS_NOEVENT(keyp->event)) { if (!IS_NOEVENT(event)) {
debug("Tapping: key event while last timeout tap(>0).\n"); debug("Tapping: key event while last timeout tap(>0).\n");
} }
process_action(keyp); process_action(keyp);
@ -197,7 +201,9 @@ bool process_tapping(keyrecord_t *keyp)
} }
} else if (IS_TAPPING_RELEASED()) { } else if (IS_TAPPING_RELEASED()) {
if (WITHIN_TAPPING_TERM(event)) { if (WITHIN_TAPPING_TERM(event)) {
if (tapping_key.tap.count > 0 && IS_TAPPING_KEY(event.key) && event.pressed) { if (event.pressed) {
if (IS_TAPPING_KEY(event.key)) {
if (!tapping_key.tap.interrupted && tapping_key.tap.count > 0) {
// sequential tap. // sequential tap.
keyp->tap = tapping_key.tap; keyp->tap = tapping_key.tap;
keyp->tap.count += 1; keyp->tap.count += 1;
@ -206,7 +212,12 @@ bool process_tapping(keyrecord_t *keyp)
tapping_key = *keyp; tapping_key = *keyp;
debug_tapping_key(); debug_tapping_key();
return true; return true;
} else if (event.pressed && is_tap_key(event.key)) { } else {
// FIX: start new tap again
tapping_key = *keyp;
return true;
}
} else if (is_tap_key(event.key)) {
// Sequential tap can be interfered with other tap key. // Sequential tap can be interfered with other tap key.
debug("Tapping: Start with interfering other tap.\n"); debug("Tapping: Start with interfering other tap.\n");
tapping_key = *keyp; tapping_key = *keyp;
@ -214,11 +225,19 @@ bool process_tapping(keyrecord_t *keyp)
debug_tapping_key(); debug_tapping_key();
return true; return true;
} else { } else {
if (!IS_NOEVENT(keyp->event)) debug("Tapping: other key just after tap.\n"); // should none in buffer
// FIX: interrupted when other key is pressed
tapping_key.tap.interrupted = true;
process_action(keyp); process_action(keyp);
return true; return true;
} }
} else { } else {
if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n");
process_action(keyp);
return true;
}
} else {
// FIX: process_aciton here?
// timeout. no sequential tap. // timeout. no sequential tap.
debug("Tapping: End(Timeout after releasing last tap): "); debug("Tapping: End(Timeout after releasing last tap): ");
debug_event(event); debug("\n"); debug_event(event); debug("\n");
@ -227,7 +246,7 @@ bool process_tapping(keyrecord_t *keyp)
return false; return false;
} }
} }
// not tapping satate // not tapping state
else { else {
if (event.pressed && is_tap_key(event.key)) { if (event.pressed && is_tap_key(event.key)) {
debug("Tapping: Start(Press tap key).\n"); debug("Tapping: Start(Press tap key).\n");