summaryrefslogtreecommitdiff
path: root/common/action_tapping.c
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-10-02 17:49:25 +0900
committertmk <nobody@nowhere>2013-10-03 12:40:33 +0900
commit8819cf6bb1da487de9bef9b01ee434fbdf710d4d (patch)
treecd15000fb03aaef3d4e83095c87061c1794da1c2 /common/action_tapping.c
parenta0f9c1fb4fc86c37353b5298c7a4d8d68b368d8c (diff)
Fix Tapping: release key immediately but modifier #65
- See https://github.com/tmk/tmk_keyboard/issues/60 - **Except for modifiers** a key pressed before the tapping starts should be released immediately - 'Mod-Tap key'(like shift-;) didn't work from this fix: 4d0b3aa Fix Tapping: release of a key pressed before tap This key sequence should register ':', not ';'. With the fix Shift is released before settlement of tapping, this registers ';'. Shift ~~___~~~~~~~ ;(Tap) ~~~____~~~~
Diffstat (limited to 'common/action_tapping.c')
-rw-r--r--common/action_tapping.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/common/action_tapping.c b/common/action_tapping.c
index 542949ddd3..826c233096 100644
--- a/common/action_tapping.c
+++ b/common/action_tapping.c
@@ -1,7 +1,9 @@
#include <stdint.h>
#include <stdbool.h>
#include "action.h"
+#include "action_layer.h"
#include "action_tapping.h"
+#include "keycode.h"
#include "timer.h"
#ifdef DEBUG_ACTION
@@ -95,22 +97,40 @@ bool process_tapping(keyrecord_t *keyp)
return false;
}
#if TAPPING_TERM >= 500
- /* This can settle mod/fn state fast but may prevent from typing fast. */
- else if (!event.pressed && waiting_buffer_typed(event)) {
- // other key typed. not tap.
+ /* Process a key typed within TAPPING_TERM
+ * This can register the key before settlement of tapping,
+ * useful for long TAPPING_TERM but may prevent fast typing.
+ */
+ else if (IS_RELEASED(event) && waiting_buffer_typed(event)) {
debug("Tapping: End. No tap. Interfered by typing key\n");
process_action(&tapping_key);
tapping_key = (keyrecord_t){};
debug_tapping_key();
-
// enqueue
return false;
}
#endif
- /* release a key pressed before tapping */
- else if (!event.pressed && !waiting_buffer_typed(event)) {
- /* Unexpected repeating occurs unless this event is processed immedately. */
- debug("Tapping: release a key pressed before tapping\n");
+ /* Process release event of a key pressed before tapping starts
+ * Without this unexpected repeating will occur with having fast repeating setting
+ * https://github.com/tmk/tmk_keyboard/issues/60
+ */
+ else if (IS_RELEASED(event) && !waiting_buffer_typed(event)) {
+ // Modifier should be retained till end of this tapping.
+ action_t action = layer_switch_get_action(event.key);
+ switch (action.kind.id) {
+ case ACT_LMODS:
+ case ACT_RMODS:
+ if (action.key.mods && !action.key.code) return false;
+ if (IS_MOD(action.key.code)) return false;
+ break;
+ case ACT_LMODS_TAP:
+ case ACT_RMODS_TAP:
+ if (action.key.mods && keyp->tap.count == 0) return false;
+ if (IS_MOD(action.key.code)) return false;
+ break;
+ }
+ // Release of key should be process immediately.
+ debug("Tapping: release event of a key pressed before tapping\n");
process_action(keyp);
return true;
}