From 0c30b49063c79be2416453f4544795922efad74f Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Fri, 22 Jan 2021 15:45:51 +0100 Subject: refactor(modifiers): define is_mods function --- app/src/behaviors/behavior_hold_tap.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'app/src/behaviors') diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index de35633..fcb4c5b 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -8,8 +8,8 @@ #include #include +#include #include -#include #include #include #include @@ -17,7 +17,6 @@ #include #include #include -#include #include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); @@ -428,11 +427,6 @@ static int position_state_changed_listener(const zmk_event_t *eh) { return ZMK_EV_EVENT_CAPTURED; } -static inline bool only_mods(struct zmk_keycode_state_changed *ev) { - return ev->usage_page == HID_USAGE_KEY && ev->keycode >= HID_USAGE_KEY_KEYBOARD_LEFTCONTROL && - ev->keycode <= HID_USAGE_KEY_KEYBOARD_RIGHT_GUI; -} - static int keycode_state_changed_listener(const zmk_event_t *eh) { // we want to catch layer-up events too... how? struct zmk_keycode_state_changed *ev = as_zmk_keycode_state_changed(eh); @@ -442,7 +436,7 @@ static int keycode_state_changed_listener(const zmk_event_t *eh) { return ZMK_EV_EVENT_BUBBLE; } - if (!only_mods(ev)) { + if (!is_mod(ev->usage_page, ev->keycode)) { // LOG_DBG("0x%02X bubble (not a mod)", ev->keycode); return ZMK_EV_EVENT_BUBBLE; } -- cgit v1.2.3