From c7994fb33cbd7cc3afa6f4ab9e06704e71136da1 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Wed, 1 Feb 2017 15:04:12 +0100 Subject: [PATCH] Separate effect and held timeouts Fixes #5. Signed-off-by: Gergely Nagy --- README.md | 11 +++++++++++ src/Akela/OneShot.cpp | 3 ++- src/Akela/OneShot.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bb9e7415..944b82a8 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,17 @@ modifiers and one-shot layer keys. It has the following methods: > > Defaults to 40. +### `.holdTimeOut` + +> The number of loop iterations to wait before considering a held one-shot key +> as intentionally held. In this case, the one-shot effect will not trigger when +> the key is released. In other words, holding a one-shot key at least this +> long, and then releasing it, will not trigger the one-shot effect. +> +> Not strictly a method, it is a variable one can assign a new value to. +> +> Defaults to 5. + ## Further reading Starting from the [example][plugin:example] is the recommended way of getting diff --git a/src/Akela/OneShot.cpp b/src/Akela/OneShot.cpp index 98693683..b1335309 100644 --- a/src/Akela/OneShot.cpp +++ b/src/Akela/OneShot.cpp @@ -25,6 +25,7 @@ namespace Akela { uint8_t OneShot::Timer = 0; uint8_t OneShot::timeOut = 40; + uint8_t OneShot::holdTimeOut = 5; uint32_t OneShot::State = 0; uint32_t OneShot::stickyState = 0; uint32_t OneShot::pressedState = 0; @@ -213,7 +214,7 @@ namespace Akela { } else { if (key_toggled_off (keyState)) { clearPressed (idx); - if (hasTimedOut ()) { + if (Timer >= holdTimeOut) { cancelOneShot (idx); } } diff --git a/src/Akela/OneShot.h b/src/Akela/OneShot.h index 77b7377e..68f9ff98 100644 --- a/src/Akela/OneShot.h +++ b/src/Akela/OneShot.h @@ -37,6 +37,7 @@ namespace Akela { static void cancel (bool withStickies); static void cancel (void) { cancel (false); }; static uint8_t timeOut; + static uint8_t holdTimeOut; static bool isModifierActive (Key key);