diff options
Diffstat (limited to 'app/include')
-rw-r--r-- | app/include/zmk/events/keycode_state_changed.h | 15 | ||||
-rw-r--r-- | app/include/zmk/hid.h | 2 |
2 files changed, 13 insertions, 4 deletions
diff --git a/app/include/zmk/events/keycode_state_changed.h b/app/include/zmk/events/keycode_state_changed.h index 031169d..466bbd7 100644 --- a/app/include/zmk/events/keycode_state_changed.h +++ b/app/include/zmk/events/keycode_state_changed.h @@ -7,8 +7,6 @@ #pragma once #include <zephyr.h> -#include <dt-bindings/zmk/modifiers.h> -#include <dt-bindings/zmk/hid_usage_pages.h> #include <zmk/event_manager.h> #include <zmk/keys.h> @@ -16,6 +14,7 @@ struct zmk_keycode_state_changed { uint16_t usage_page; uint32_t keycode; uint8_t implicit_modifiers; + uint8_t explicit_modifiers; bool state; int64_t timestamp; }; @@ -26,16 +25,24 @@ static inline struct zmk_keycode_state_changed_event * zmk_keycode_state_changed_from_encoded(uint32_t encoded, bool pressed, int64_t timestamp) { uint16_t page = HID_USAGE_PAGE(encoded) & 0xFF; uint16_t id = HID_USAGE_ID(encoded); - zmk_mod_flags_t implicit_mods = SELECT_MODS(encoded); + uint8_t implicit_modifiers = 0x00; + uint8_t explicit_modifiers = 0x00; if (!page) { page = HID_USAGE_KEY; } + if (is_mod(page, id)) { + explicit_modifiers = SELECT_MODS(encoded); + } else { + implicit_modifiers = SELECT_MODS(encoded); + } + return new_zmk_keycode_state_changed( (struct zmk_keycode_state_changed){.usage_page = page, .keycode = id, - .implicit_modifiers = implicit_mods, + .implicit_modifiers = implicit_modifiers, + .explicit_modifiers = explicit_modifiers, .state = pressed, .timestamp = timestamp}); } diff --git a/app/include/zmk/hid.h b/app/include/zmk/hid.h index aca3cc4..5aa004c 100644 --- a/app/include/zmk/hid.h +++ b/app/include/zmk/hid.h @@ -169,6 +169,8 @@ struct zmk_hid_consumer_report { zmk_mod_flags_t zmk_hid_get_explicit_mods(); int zmk_hid_register_mod(zmk_mod_t modifier); int zmk_hid_unregister_mod(zmk_mod_t modifier); +int zmk_hid_register_mods(zmk_mod_flags_t explicit_modifiers); +int zmk_hid_unregister_mods(zmk_mod_flags_t explicit_modifiers); int zmk_hid_implicit_modifiers_press(zmk_mod_flags_t implicit_modifiers); int zmk_hid_implicit_modifiers_release(); int zmk_hid_keyboard_press(zmk_key_t key); |