X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=common%2Faction.c;h=ec8eeae7bc8b7bfb6f8e372ce9acc097b4351948;hb=75a59e4d12a13efc03cacd85b394fcf1204aad76;hp=c7c8f71f2ccafa346cd6cfd77625d244e7a814b9;hpb=ff2d276b193632136c785d92ed01df48aea8461f;p=max%2Ftmk_keyboard.git
diff --git a/common/action.c b/common/action.c
index c7c8f71f..ec8eeae7 100644
--- a/common/action.c
+++ b/common/action.c
@@ -20,10 +20,11 @@ along with this program. If not, see .
#include "mousekey.h"
#include "command.h"
#include "led.h"
+#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
@@ -78,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();
}
}
}
@@ -99,47 +100,45 @@ void process_action(keyrecord_t *record)
action.key.mods<<4;
switch (action.layer_tap.code) {
#ifndef NO_ACTION_ONESHOT
- case 0x00:
+ case MODS_ONESHOT:
// Oneshot modifier
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);
- }
- else if (tap_count == TAPPING_TOGGLE) {
- dprint("MODS_TAP: Oneshot: toggle\n");
- oneshot_toggle();
+ set_oneshot_mods(mods);
}
else {
- dprint("MODS_TAP: Oneshot: cancel&add_mods\n");
- // double tap cancels oneshot and works as normal modifier.
- oneshot_cancel();
- add_mods(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);
+ // Retain Oneshot mods
}
else {
- dprint("MODS_TAP: Oneshot: del_mods\n");
- // cancel Mods
- del_mods(mods);
+ clear_oneshot_mods();
+ unregister_mods(mods);
}
}
break;
#endif
+ case MODS_TAP_TOGGLE:
+ if (event.pressed) {
+ if (tap_count <= TAPPING_TOGGLE) {
+ register_mods(mods);
+ }
+ } else {
+ if (tap_count < TAPPING_TOGGLE) {
+ unregister_mods(mods);
+ }
+ }
+ break;
default:
if (event.pressed) {
if (tap_count > 0) {
@@ -147,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) {
@@ -162,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;
@@ -236,8 +235,18 @@ void process_action(keyrecord_t *record)
break;
#ifndef NO_ACTION_TAPPING
case ACT_LAYER_TAP:
- case ACT_LAYER_TAP1:
+ case ACT_LAYER_TAP_EXT:
switch (action.layer_tap.code) {
+ case 0xe0 ... 0xef:
+ /* layer On/Off with modifiers(left only) */
+ if (event.pressed) {
+ layer_on(action.layer_tap.val);
+ register_mods(action.layer_tap.code & 0x0f);
+ } else {
+ layer_off(action.layer_tap.val);
+ unregister_mods(action.layer_tap.code & 0x0f);
+ }
+ break;
case OP_TAP_TOGGLE:
/* tap toggle */
if (event.pressed) {
@@ -291,6 +300,29 @@ void process_action(keyrecord_t *record)
case ACT_MACRO:
action_macro_play(action_get_macro(record, action.func.id, action.func.opt));
break;
+#endif
+#ifdef BACKLIGHT_ENABLE
+ case ACT_BACKLIGHT:
+ if (!event.pressed) {
+ switch (action.backlight.opt) {
+ case BACKLIGHT_INCREASE:
+ backlight_increase();
+ break;
+ case BACKLIGHT_DECREASE:
+ backlight_decrease();
+ break;
+ case BACKLIGHT_TOGGLE:
+ backlight_toggle();
+ break;
+ case BACKLIGHT_STEP:
+ backlight_step();
+ break;
+ case BACKLIGHT_LEVEL:
+ backlight_level(action.backlight.level);
+ break;
+ }
+ }
+ break;
#endif
case ACT_COMMAND:
break;
@@ -315,42 +347,73 @@ void register_code(uint8_t code)
if (code == KC_NO) {
return;
}
-#ifdef CAPSLOCK_LOCKING_ENABLE
+
+#ifdef LOCKING_SUPPORT_ENABLE
else if (KC_LOCKING_CAPS == code) {
-#ifdef CAPSLOCK_LOCKING_RESYNC_ENABLE
+#ifdef LOCKING_RESYNC_ENABLE
// Resync: ignore if caps lock already is on
if (host_keyboard_leds() & (1<