From faa0a6c7569c1590673d1c3e406466afe5b38706 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 26 Oct 2018 11:57:58 -0700 Subject: [PATCH 1/8] 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. --- tmk_core/common/action.c | 10 ++++++++++ tmk_core/common/action.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index 8bdcd54e32cf..4f1bb32f7a7c 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -847,6 +847,16 @@ 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); + wait_ms(100); + unregister_code(code); +} + /** \brief Utilities for actions. (FIXME: Needs better description) * * FIXME: Needs documentation. diff --git a/tmk_core/common/action.h b/tmk_core/common/action.h index 833febe9ce9b..5d797fd628ff 100644 --- a/tmk_core/common/action.h +++ b/tmk_core/common/action.h @@ -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); From fd48a77a24f19e7572c6d581e9537f5e091fe892 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 12 Dec 2018 09:07:14 -0800 Subject: [PATCH 2/8] Make tap_code delay configurable --- tmk_core/common/action.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index 4f1bb32f7a7c..3bffc80365a1 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -853,7 +853,9 @@ void unregister_code(uint8_t code) */ void tap_code(uint8_t code) { register_code(code); - wait_ms(100); + #if defined(TAP_CODE_DELAY) && TAP_CODE_DELAY > 0 + wait_ms(TAP_CODE_DELAY); + #endif unregister_code(code); } From 02859d94297163266d32e7341f890721f467988b Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 12 Dec 2018 09:15:15 -0800 Subject: [PATCH 3/8] Update documentation --- docs/config_options.md | 2 ++ docs/feature_macros.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/docs/config_options.md b/docs/config_options.md index b811fa877dc0..b6a65b712839 100644 --- a/docs/config_options.md +++ b/docs/config_options.md @@ -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). ## RGB Light Configuration diff --git a/docs/feature_macros.md b/docs/feature_macros.md index ba5d91882fb7..5c09961304f0 100644 --- a/docs/feature_macros.md +++ b/docs/feature_macros.md @@ -232,6 +232,8 @@ Parallel to `register_code` function, this sends the `` keyup event to the c This will send `register_code()` and then `unregister_code()`. This is useful if you want to send both the press and release events ("tap" the key, rather than hold it). +You can add a delay between the register and unregister event by adding `#define TAP_CODE_DELAY 100` to your `config.h` file. + ### `clear_keyboard();` This will clear all mods and keys currently pressed. From 1a5884fca15e5a434f336ded4785c9fb0b59a5cb Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 12 Dec 2018 09:15:34 -0800 Subject: [PATCH 4/8] Bring tap_code16 inline with changes --- quantum/quantum.c | 8 ++++++++ quantum/quantum.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/quantum/quantum.c b/quantum/quantum.c index 69692233ebe4..feb4435b632c 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -132,6 +132,14 @@ void unregister_code16 (uint16_t code) { } } +void tap_code16(uint8_t code) { + register_code16(code); + #if defined(TAP_CODE_DELAY) && TAP_CODE_DELAY > 0 + wait_ms(TAP_CODE_DELAY); + #endif + unregister_code16(code); +} + __attribute__ ((weak)) bool process_action_kb(keyrecord_t *record) { return true; diff --git a/quantum/quantum.h b/quantum/quantum.h index 41c7d8351a9a..d7da6bef3c6b 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -242,7 +242,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); From 70368c25d54591848e82a6d58f47a1cd97e6e474 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 12 Dec 2018 09:33:06 -0800 Subject: [PATCH 5/8] Fix type for tap_code16 Bad copy-paste job --- quantum/quantum.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/quantum.c b/quantum/quantum.c index feb4435b632c..e1c290771bda 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -132,7 +132,7 @@ void unregister_code16 (uint16_t code) { } } -void tap_code16(uint8_t code) { +void tap_code16(uint16_t code) { register_code16(code); #if defined(TAP_CODE_DELAY) && TAP_CODE_DELAY > 0 wait_ms(TAP_CODE_DELAY); From a510fc2b0a659240ba30b743a9fd9b369a937b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Wed, 12 Dec 2018 09:54:09 -0800 Subject: [PATCH 6/8] Clarify timing in docs Co-Authored-By: drashna --- docs/config_options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config_options.md b/docs/config_options.md index b6a65b712839..69fecc8b49ad 100644 --- a/docs/config_options.md +++ b/docs/config_options.md @@ -161,7 +161,7 @@ If you define these options you will enable the associated feature, which may in * `#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). + * 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 From fb72fc3287496d894d4ce729d7ecb35427cbc97e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Wed, 12 Dec 2018 09:55:14 -0800 Subject: [PATCH 7/8] Wordsmithing Co-Authored-By: drashna --- docs/feature_macros.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/feature_macros.md b/docs/feature_macros.md index 5c09961304f0..7f6d764ae5c6 100644 --- a/docs/feature_macros.md +++ b/docs/feature_macros.md @@ -232,7 +232,7 @@ Parallel to `register_code` function, this sends the `` keyup event to the c This will send `register_code()` and then `unregister_code()`. This is useful if you want to send both the press and release events ("tap" the key, rather than hold it). -You can add a delay between the register and unregister event by adding `#define TAP_CODE_DELAY 100` to your `config.h` file. +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();` From 015a0f500aa0e709c8b33a22d3dc19c9b53ff3d3 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 12 Dec 2018 09:42:06 -0800 Subject: [PATCH 8/8] Just use the value check for the define --- quantum/quantum.c | 2 +- tmk_core/common/action.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/quantum/quantum.c b/quantum/quantum.c index e1c290771bda..a57d4f89fe67 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -134,7 +134,7 @@ void unregister_code16 (uint16_t code) { void tap_code16(uint16_t code) { register_code16(code); - #if defined(TAP_CODE_DELAY) && TAP_CODE_DELAY > 0 + #if TAP_CODE_DELAY > 0 wait_ms(TAP_CODE_DELAY); #endif unregister_code16(code); diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index 3bffc80365a1..456d1e25fe4d 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -853,7 +853,7 @@ void unregister_code(uint8_t code) */ void tap_code(uint8_t code) { register_code(code); - #if defined(TAP_CODE_DELAY) && TAP_CODE_DELAY > 0 + #if TAP_CODE_DELAY > 0 wait_ms(TAP_CODE_DELAY); #endif unregister_code(code);