Fix bug with layer caching in get_event_keycode (#8693)
* Fix bug with layer caching in get_event_keycode * Improve namingmaster
parent
eb7fc7f9d9
commit
23124b9fd1
|
@ -149,18 +149,21 @@ void reset_keyboard(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert record into usable keycode via the contained event. */
|
/* Convert record into usable keycode via the contained event. */
|
||||||
uint16_t get_record_keycode(keyrecord_t *record) { return get_event_keycode(record->event); }
|
uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) { return get_event_keycode(record->event, update_layer_cache); }
|
||||||
|
|
||||||
/* Convert event into usable keycode. Checks the layer cache to ensure that it
|
/* Convert event into usable keycode. Checks the layer cache to ensure that it
|
||||||
* retains the correct keycode after a layer change, if the key is still pressed.
|
* retains the correct keycode after a layer change, if the key is still pressed.
|
||||||
|
* "update_layer_cache" is to ensure that it only updates the layer cache when
|
||||||
|
* appropriate, otherwise, it will update it and cause layer tap (and other keys)
|
||||||
|
* from triggering properly.
|
||||||
*/
|
*/
|
||||||
uint16_t get_event_keycode(keyevent_t event) {
|
uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) {
|
||||||
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
|
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
|
||||||
/* TODO: Use store_or_get_action() or a similar function. */
|
/* TODO: Use store_or_get_action() or a similar function. */
|
||||||
if (!disable_action_cache) {
|
if (!disable_action_cache) {
|
||||||
uint8_t layer;
|
uint8_t layer;
|
||||||
|
|
||||||
if (event.pressed) {
|
if (event.pressed && update_layer_cache) {
|
||||||
layer = layer_switch_get_layer(event.key);
|
layer = layer_switch_get_layer(event.key);
|
||||||
update_source_layers_cache(event.key, layer);
|
update_source_layers_cache(event.key, layer);
|
||||||
} else {
|
} else {
|
||||||
|
@ -174,7 +177,7 @@ uint16_t get_event_keycode(keyevent_t event) {
|
||||||
|
|
||||||
/* Get keycode, and then call keyboard function */
|
/* Get keycode, and then call keyboard function */
|
||||||
void post_process_record_quantum(keyrecord_t *record) {
|
void post_process_record_quantum(keyrecord_t *record) {
|
||||||
uint16_t keycode = get_record_keycode(record);
|
uint16_t keycode = get_record_keycode(record, false);
|
||||||
post_process_record_kb(keycode, record);
|
post_process_record_kb(keycode, record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +185,7 @@ void post_process_record_quantum(keyrecord_t *record) {
|
||||||
then processes internal quantum keycodes, and then processes
|
then processes internal quantum keycodes, and then processes
|
||||||
ACTIONs. */
|
ACTIONs. */
|
||||||
bool process_record_quantum(keyrecord_t *record) {
|
bool process_record_quantum(keyrecord_t *record) {
|
||||||
uint16_t keycode = get_record_keycode(record);
|
uint16_t keycode = get_record_keycode(record, true);
|
||||||
|
|
||||||
// This is how you use actions here
|
// This is how you use actions here
|
||||||
// if (keycode == KC_LEAD) {
|
// if (keycode == KC_LEAD) {
|
||||||
|
|
|
@ -252,8 +252,8 @@ void matrix_init_kb(void);
|
||||||
void matrix_scan_kb(void);
|
void matrix_scan_kb(void);
|
||||||
void matrix_init_user(void);
|
void matrix_init_user(void);
|
||||||
void matrix_scan_user(void);
|
void matrix_scan_user(void);
|
||||||
uint16_t get_record_keycode(keyrecord_t *record);
|
uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache);
|
||||||
uint16_t get_event_keycode(keyevent_t event);
|
uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache);
|
||||||
bool process_action_kb(keyrecord_t *record);
|
bool process_action_kb(keyrecord_t *record);
|
||||||
bool process_record_kb(uint16_t keycode, keyrecord_t *record);
|
bool process_record_kb(uint16_t keycode, keyrecord_t *record);
|
||||||
bool process_record_user(uint16_t keycode, keyrecord_t *record);
|
bool process_record_user(uint16_t keycode, keyrecord_t *record);
|
||||||
|
|
|
@ -324,7 +324,7 @@ void process_action(keyrecord_t *record, action_t action) {
|
||||||
# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY)
|
# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY)
|
||||||
if (
|
if (
|
||||||
# ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
|
# ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
|
||||||
!get_ignore_mod_tap_interrupt(get_event_keycode(record->event)) &&
|
!get_ignore_mod_tap_interrupt(get_event_keycode(record->event, false)) &&
|
||||||
# endif
|
# endif
|
||||||
record->tap.interrupted) {
|
record->tap.interrupted) {
|
||||||
dprint("mods_tap: tap: cancel: add_mods\n");
|
dprint("mods_tap: tap: cancel: add_mods\n");
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
__attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode) { return TAPPING_TERM; }
|
__attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode) { return TAPPING_TERM; }
|
||||||
|
|
||||||
# ifdef TAPPING_TERM_PER_KEY
|
# ifdef TAPPING_TERM_PER_KEY
|
||||||
# define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < get_tapping_term(get_event_keycode(tapping_key.event)))
|
# define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < get_tapping_term(get_event_keycode(tapping_key.event, false)))
|
||||||
# else
|
# else
|
||||||
# define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM)
|
# define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM)
|
||||||
# endif
|
# endif
|
||||||
|
@ -122,10 +122,10 @@ bool process_tapping(keyrecord_t *keyp) {
|
||||||
# if defined(TAPPING_TERM_PER_KEY) || (TAPPING_TERM >= 500) || defined(PERMISSIVE_HOLD) || defined(PERMISSIVE_HOLD_PER_KEY)
|
# if defined(TAPPING_TERM_PER_KEY) || (TAPPING_TERM >= 500) || defined(PERMISSIVE_HOLD) || defined(PERMISSIVE_HOLD_PER_KEY)
|
||||||
else if (
|
else if (
|
||||||
# ifdef TAPPING_TERM_PER_KEY
|
# ifdef TAPPING_TERM_PER_KEY
|
||||||
(get_tapping_term(get_event_keycode(tapping_key.event)) >= 500) &&
|
(get_tapping_term(get_event_keycode(tapping_key.event, false)) >= 500) &&
|
||||||
# endif
|
# endif
|
||||||
# ifdef PERMISSIVE_HOLD_PER_KEY
|
# ifdef PERMISSIVE_HOLD_PER_KEY
|
||||||
!get_permissive_hold(get_event_keycode(tapping_key.event), keyp) &&
|
!get_permissive_hold(get_event_keycode(tapping_key.event, false), keyp) &&
|
||||||
# endif
|
# endif
|
||||||
IS_RELEASED(event) && waiting_buffer_typed(event)) {
|
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");
|
||||||
|
@ -246,7 +246,7 @@ bool process_tapping(keyrecord_t *keyp) {
|
||||||
# if !defined(TAPPING_FORCE_HOLD) || defined(TAPPING_FORCE_HOLD_PER_KEY)
|
# if !defined(TAPPING_FORCE_HOLD) || defined(TAPPING_FORCE_HOLD_PER_KEY)
|
||||||
if (
|
if (
|
||||||
# ifdef TAPPING_FORCE_HOLD_PER_KEY
|
# ifdef TAPPING_FORCE_HOLD_PER_KEY
|
||||||
!get_tapping_force_hold(get_event_keycode(tapping_key.event), keyp) &&
|
!get_tapping_force_hold(get_event_keycode(tapping_key.event, false), keyp) &&
|
||||||
# endif
|
# endif
|
||||||
!tapping_key.tap.interrupted && tapping_key.tap.count > 0) {
|
!tapping_key.tap.interrupted && tapping_key.tap.count > 0) {
|
||||||
// sequential tap.
|
// sequential tap.
|
||||||
|
|
|
@ -32,7 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define WAITING_BUFFER_SIZE 8
|
#define WAITING_BUFFER_SIZE 8
|
||||||
|
|
||||||
#ifndef NO_ACTION_TAPPING
|
#ifndef NO_ACTION_TAPPING
|
||||||
uint16_t get_event_keycode(keyevent_t event);
|
uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache);
|
||||||
uint16_t get_tapping_term(uint16_t keycode);
|
uint16_t get_tapping_term(uint16_t keycode);
|
||||||
void action_tapping_process(keyrecord_t record);
|
void action_tapping_process(keyrecord_t record);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue