]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Fix up tap_code functionality (#4609)
authorDrashna Jaelre <drashna@live.com>
Fri, 14 Dec 2018 17:01:58 +0000 (09:01 -0800)
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>
Fri, 14 Dec 2018 17:01:58 +0000 (09:01 -0800)
* Add delay in Tap Code to avoid issues

I think a few people have reporting issues with it working properly, and it may be a timing issue.  The 'register_code' uses this sort of delay in some of the functions, and
this is probably why.

Adding the 100ms delay should hopefully fix any issues with it.

* Make tap_code delay configurable

* Update documentation

* Bring tap_code16 inline with changes

* Fix type for tap_code16

Bad copy-paste job

* Just use the value check for the define

* Clarify timing in docs

Co-Authored-By: drashna <drashna@live.com>
* Wordsmithing

Co-Authored-By: drashna <drashna@live.com>
docs/config_options.md
docs/feature_macros.md
quantum/quantum.c
quantum/quantum.h
tmk_core/common/action.c
tmk_core/common/action.h

index b811fa877dc0582d0a9da1c3b725483a2a5bcc42..69fecc8b49ada27ee14dcb5f367d36d0e1946701 100644 (file)
@@ -160,6 +160,8 @@ If you define these options you will enable the associated feature, which may in
   * Set this to the number of combos that you're using in the [Combo](feature_combo.md) feature.
 * `#define COMBO_TERM 200`
   * how long for the Combo keys to be detected. Defaults to `TAPPING_TERM` if not defined.
+* `#define TAP_CODE_DELAY 100`
+  * Sets the delay between `register_code` and `unregister_code`, if you're having issues with it registering properly (common on VUSB boards). The value is in milliseconds.
 
 ## RGB Light Configuration
 
index 29ba29fef7db9e79d1a616ae06fee1517bbde9f9..aa13fb97f4f8ca54e03b55c42375f6dc3bf0c1bb 100644 (file)
@@ -250,6 +250,8 @@ Parallel to `register_code` function, this sends the `<kc>` keyup event to the c
 
 This will send `register_code(<kc>)` and then `unregister_code(<kc>)`. This is useful if you want to send both the press and release events ("tap" the key, rather than hold it).
 
+If you're having issues with taps (un)registering, you can add a delay between the register and unregister events by setting `#define TAP_CODE_DELAY 100` in your `config.h` file. The value is in milliseconds.
+
 ### `clear_keyboard();`
 
 This will clear all mods and keys currently pressed.
index 69692233ebe4254c95223c7790f6bdd7eda8ffe4..a57d4f89fe67014f655eca8796ac3d4d5b00cc1c 100644 (file)
@@ -132,6 +132,14 @@ void unregister_code16 (uint16_t code) {
   }
 }
 
+void tap_code16(uint16_t code) {
+  register_code16(code);
+  #if TAP_CODE_DELAY > 0
+    wait_ms(TAP_CODE_DELAY);
+  #endif
+  unregister_code16(code);
+}
+
 __attribute__ ((weak))
 bool process_action_kb(keyrecord_t *record) {
   return true;
index 5920e4b13955894c4f64c3c225c83f70646bd3b0..0faf1af29c876da170b4ad4713cfd95441bad23a 100644 (file)
@@ -243,7 +243,7 @@ void shutdown_user(void);
 
 void register_code16(uint16_t code);
 void unregister_code16(uint16_t code);
-inline void tap_code16(uint16_t code) { register_code16(code); unregister_code16(code); }
+void tap_code16(uint16_t code);
 
 #ifdef BACKLIGHT_ENABLE
 void backlight_init_ports(void);
index 8bdcd54e32cfbfa69ea74dce61f6e74188ae451a..456d1e25fe4dad2423adbe847a023c68a76d88b7 100644 (file)
@@ -847,6 +847,18 @@ void unregister_code(uint8_t code)
     #endif
 }
 
+/** \brief Utilities for actions. (FIXME: Needs better description)
+ *
+ * FIXME: Needs documentation.
+ */
+void tap_code(uint8_t code) {
+  register_code(code);
+  #if TAP_CODE_DELAY > 0
+    wait_ms(TAP_CODE_DELAY);
+  #endif
+  unregister_code(code);
+}
+
 /** \brief Utilities for actions. (FIXME: Needs better description)
  *
  * FIXME: Needs documentation.
index 833febe9ce9bfa503759a1b5872bf57a33e368df..5d797fd628ffad87af17bde99b4bdbf60e60fec3 100644 (file)
@@ -88,7 +88,7 @@ void process_record(keyrecord_t *record);
 void process_action(keyrecord_t *record, action_t action);
 void register_code(uint8_t code);
 void unregister_code(uint8_t code);
-inline void tap_code(uint8_t code) { register_code(code); unregister_code(code); }
+void tap_code(uint8_t code);
 void register_mods(uint8_t mods);
 void unregister_mods(uint8_t mods);
 //void set_mods(uint8_t mods);