From d52d554360d3bf06189bfd4f386fa99348d8a0a8 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 4 Oct 2013 03:30:09 +0900 Subject: Fix mod stuck of MODS_KEY when leaving layer #62 - Add action_util.c and remove action_oneshot.c - Add oneshot_mods for MODS_ONESHOT - Add weak_mods for MODS_KEY and MACRO - weak_mods is cleared when layer switching --- common/action.c | 138 +++++++++++++++++++++++++++----------------------------- 1 file changed, 67 insertions(+), 71 deletions(-) (limited to 'common/action.c') diff --git a/common/action.c b/common/action.c index 59c6f252dc..ecd5a7e94f 100644 --- a/common/action.c +++ b/common/action.c @@ -23,8 +23,8 @@ along with this program. If not, see . #include "backlight.h" #include "action_layer.h" #include "action_tapping.h" -#include "action_oneshot.h" #include "action_macro.h" +#include "action_util.h" #include "action.h" #ifdef DEBUG_ACTION @@ -79,15 +79,15 @@ void process_action(keyrecord_t *record) action.key.mods<<4; if (event.pressed) { if (mods) { - host_add_mods(mods); - host_send_keyboard_report(); + add_weak_mods(mods); + send_keyboard_report(); } register_code(action.key.code); } else { unregister_code(action.key.code); if (mods) { - host_del_mods(mods); - host_send_keyboard_report(); + del_weak_mods(mods); + send_keyboard_report(); } } } @@ -105,11 +105,11 @@ void process_action(keyrecord_t *record) if (event.pressed) { if (tap_count == 0) { dprint("MODS_TAP: Oneshot: add_mods\n"); - add_mods(mods); + register_mods(mods); } else if (tap_count == 1) { dprint("MODS_TAP: Oneshot: start\n"); - oneshot_start(mods); + set_oneshot_mods(mods); } else if (tap_count == TAPPING_TOGGLE) { dprint("MODS_TAP: Oneshot: toggle\n"); @@ -118,25 +118,23 @@ void process_action(keyrecord_t *record) else { dprint("MODS_TAP: Oneshot: cancel&add_mods\n"); // double tap cancels oneshot and works as normal modifier. - oneshot_cancel(); - add_mods(mods); + clear_oneshot_mods(); + register_mods(mods); } } else { if (tap_count == 0) { dprint("MODS_TAP: Oneshot: cancel/del_mods\n"); // cancel oneshot on hold - oneshot_cancel(); - del_mods(mods); + clear_oneshot_mods(); + unregister_mods(mods); } else if (tap_count == 1) { - dprint("MODS_TAP: Oneshot: del_mods\n"); - // retain Oneshot - del_mods(mods); + // Oneshot } else { dprint("MODS_TAP: Oneshot: del_mods\n"); // cancel Mods - del_mods(mods); + unregister_mods(mods); } } break; @@ -148,14 +146,14 @@ void process_action(keyrecord_t *record) dprint("MODS_TAP: Tap: Cancel: add_mods\n"); // ad hoc: set 0 to cancel tap record->tap.count = 0; - add_mods(mods); + register_mods(mods); } else { dprint("MODS_TAP: Tap: register_code\n"); register_code(action.key.code); } } else { dprint("MODS_TAP: No tap: add_mods\n"); - add_mods(mods); + register_mods(mods); } } else { if (tap_count > 0) { @@ -163,7 +161,7 @@ void process_action(keyrecord_t *record) unregister_code(action.key.code); } else { dprint("MODS_TAP: No tap: add_mods\n"); - del_mods(mods); + unregister_mods(mods); } } break; @@ -343,30 +341,30 @@ void register_code(uint8_t code) // Resync: ignore if caps lock already is on if (host_keyboard_leds() & (1<