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) ~~~____~~~~
This commit is contained in:
parent
4eb4ccf713
commit
0f768fc84b
@ -1,7 +1,9 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
|
#include "action_layer.h"
|
||||||
#include "action_tapping.h"
|
#include "action_tapping.h"
|
||||||
|
#include "keycode.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
#ifdef DEBUG_ACTION
|
#ifdef DEBUG_ACTION
|
||||||
@ -95,22 +97,40 @@ bool process_tapping(keyrecord_t *keyp)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#if TAPPING_TERM >= 500
|
#if TAPPING_TERM >= 500
|
||||||
/* This can settle mod/fn state fast but may prevent from typing fast. */
|
/* Process a key typed within TAPPING_TERM
|
||||||
else if (!event.pressed && waiting_buffer_typed(event)) {
|
* This can register the key before settlement of tapping,
|
||||||
// other key typed. not tap.
|
* 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");
|
debug("Tapping: End. No tap. Interfered by typing key\n");
|
||||||
process_action(&tapping_key);
|
process_action(&tapping_key);
|
||||||
tapping_key = (keyrecord_t){};
|
tapping_key = (keyrecord_t){};
|
||||||
debug_tapping_key();
|
debug_tapping_key();
|
||||||
|
|
||||||
// enqueue
|
// enqueue
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* release a key pressed before tapping */
|
/* Process release event of a key pressed before tapping starts
|
||||||
else if (!event.pressed && !waiting_buffer_typed(event)) {
|
* Without this unexpected repeating will occur with having fast repeating setting
|
||||||
/* Unexpected repeating occurs unless this event is processed immedately. */
|
* https://github.com/tmk/tmk_keyboard/issues/60
|
||||||
debug("Tapping: release a key pressed before tapping\n");
|
*/
|
||||||
|
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);
|
process_action(keyp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -42,16 +42,15 @@ typedef struct {
|
|||||||
/* equivalent test of key_t */
|
/* equivalent test of key_t */
|
||||||
#define KEYEQ(keya, keyb) ((keya).row == (keyb).row && (keya).col == (keyb).col)
|
#define KEYEQ(keya, keyb) ((keya).row == (keyb).row && (keya).col == (keyb).col)
|
||||||
|
|
||||||
/* (time == 0) means no event and assumes matrix has no 255 line. */
|
/* Rules for No Event:
|
||||||
#define IS_NOEVENT(event) ((event).time == 0 || ((event).key.row == 255 && (event).key.col == 255))
|
* 1) (time == 0) to handle (keyevent_t){} as empty event
|
||||||
|
* 2) Matrix(255, 255) to make TICK event available
|
||||||
|
*/
|
||||||
|
static inline bool IS_NOEVENT(keyevent_t event) { return event.time == 0 || (event.key.row == 255 && event.key.col == 255); }
|
||||||
|
static inline bool IS_PRESSED(keyevent_t event) { return (!IS_NOEVENT(event) && event.pressed); }
|
||||||
|
static inline bool IS_RELEASED(keyevent_t event) { return (!IS_NOEVENT(event) && !event.pressed); }
|
||||||
|
|
||||||
#define NOEVENT (keyevent_t){ \
|
/* Tick event */
|
||||||
.key = (key_t){ .row = 255, .col = 255 }, \
|
|
||||||
.pressed = false, \
|
|
||||||
.time = 0 \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* tick event */
|
|
||||||
#define TICK (keyevent_t){ \
|
#define TICK (keyevent_t){ \
|
||||||
.key = (key_t){ .row = 255, .col = 255 }, \
|
.key = (key_t){ .row = 255, .col = 255 }, \
|
||||||
.pressed = false, \
|
.pressed = false, \
|
||||||
|
Reference in New Issue
Block a user