From 04b9b62bdc5ed394a06c5c73acdce0b261220e85 Mon Sep 17 00:00:00 2001
From: tsankuanglee <github@tklee.com>
Date: Tue, 31 Oct 2017 11:15:22 -0400
Subject: RETRO_TAPPING (#1922)

* add RETRO_TAP: tap anyway, even after TAP_TERM, if no interruption

* consistent variable name

* add option doc

* change name for consistency

* make RETRO_TAPPING default to off
---
 tmk_core/common/action.c         | 39 ++++++++++++++++++++++++++++++++++++---
 tmk_core/common/action_tapping.h |  2 ++
 2 files changed, 38 insertions(+), 3 deletions(-)

(limited to 'tmk_core/common')

diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index 41de01485..b39aa4cbc 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -36,6 +36,10 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 int tp_buttons;
 
+#ifdef RETRO_TAPPING
+int retro_tapping_counter = 0;
+#endif
+
 #ifdef FAUXCLICKY_ENABLE
 #include <fauxclicky.h>
 #endif
@@ -45,6 +49,9 @@ void action_exec(keyevent_t event)
     if (!IS_NOEVENT(event)) {
         dprint("\n---- action_exec: start -----\n");
         dprint("EVENT: "); debug_event(event); dprintln();
+#ifdef RETRO_TAPPING
+        retro_tapping_counter++;
+#endif
     }
 
 #ifdef FAUXCLICKY_ENABLE
@@ -586,6 +593,32 @@ void process_action(keyrecord_t *record, action_t action)
     }
 #endif
 
+#ifndef NO_ACTION_TAPPING
+  #ifdef RETRO_TAPPING
+  if (!is_tap_key(record->event.key)) {
+    retro_tapping_counter = 0;
+  } else {
+    if (event.pressed) {
+        if (tap_count > 0) {
+          retro_tapping_counter = 0;
+        } else {
+
+        }
+    } else {
+      if (tap_count > 0) {
+        retro_tapping_counter = 0;
+      } else {
+        if (retro_tapping_counter == 2) {
+          register_code(action.layer_tap.code);
+          unregister_code(action.layer_tap.code);
+        }
+        retro_tapping_counter = 0;
+      }
+    }
+  }
+  #endif
+#endif
+
 #ifndef NO_ACTION_ONESHOT
     /* Because we switch layers after a oneshot event, we need to release the
      * key before we leave the layer or no key up event will be generated.
@@ -619,7 +652,7 @@ void register_code(uint8_t code)
 #endif
         add_key(KC_CAPSLOCK);
         send_keyboard_report();
-        wait_ms(100);        
+        wait_ms(100);
         del_key(KC_CAPSLOCK);
         send_keyboard_report();
     }
@@ -630,7 +663,7 @@ void register_code(uint8_t code)
 #endif
         add_key(KC_NUMLOCK);
         send_keyboard_report();
-        wait_ms(100);        
+        wait_ms(100);
         del_key(KC_NUMLOCK);
         send_keyboard_report();
     }
@@ -641,7 +674,7 @@ void register_code(uint8_t code)
 #endif
         add_key(KC_SCROLLLOCK);
         send_keyboard_report();
-        wait_ms(100);        
+        wait_ms(100);
         del_key(KC_SCROLLLOCK);
         send_keyboard_report();
     }
diff --git a/tmk_core/common/action_tapping.h b/tmk_core/common/action_tapping.h
index 9b42d50dc..2f143ae8b 100644
--- a/tmk_core/common/action_tapping.h
+++ b/tmk_core/common/action_tapping.h
@@ -24,6 +24,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define TAPPING_TERM    200
 #endif
 
+//#define RETRO_TAPPING // Tap anyway, even after TAPPING_TERM, as long as there was no interruption
+
 /* tap count needed for toggling a feature */
 #ifndef TAPPING_TOGGLE
 #define TAPPING_TOGGLE  5
-- 
cgit v1.2.3