Browse Source

refactor(hid): add mask to HID_USAGE_PAGE macro

xmkb
Okke Formsma 4 years ago committed by Pete Johanson
parent
commit
c5922fae56
  1. 2
      app/include/dt-bindings/zmk/hid_usage_pages.h
  2. 2
      app/include/zmk/events/keycode_state_changed.h
  3. 2
      app/src/behaviors/behavior_caps_word.c
  4. 2
      app/src/behaviors/behavior_sticky_key.c

2
app/include/dt-bindings/zmk/hid_usage_pages.h

@ -12,7 +12,7 @@
#define ZMK_HID_USAGE(page, id) ((page << 16) | id) #define ZMK_HID_USAGE(page, id) ((page << 16) | id)
#define ZMK_HID_USAGE_ID(usage) (usage & 0xFFFF) #define ZMK_HID_USAGE_ID(usage) (usage & 0xFFFF)
#define ZMK_HID_USAGE_PAGE(usage) (usage >> 16) #define ZMK_HID_USAGE_PAGE(usage) ((usage >> 16) & 0xFF)
/* WARNING: DEPRECATED from dt-bindings/zmk/keys.h */ /* WARNING: DEPRECATED from dt-bindings/zmk/keys.h */
#define USAGE_KEYPAD (0x07) // WARNING: DEPRECATED (DO NOT USE) #define USAGE_KEYPAD (0x07) // WARNING: DEPRECATED (DO NOT USE)

2
app/include/zmk/events/keycode_state_changed.h

@ -23,7 +23,7 @@ ZMK_EVENT_DECLARE(zmk_keycode_state_changed);
static inline struct zmk_keycode_state_changed_event * static inline struct zmk_keycode_state_changed_event *
zmk_keycode_state_changed_from_encoded(uint32_t encoded, bool pressed, int64_t timestamp) { zmk_keycode_state_changed_from_encoded(uint32_t encoded, bool pressed, int64_t timestamp) {
uint16_t page = ZMK_HID_USAGE_PAGE(encoded) & 0xFF; uint16_t page = ZMK_HID_USAGE_PAGE(encoded);
uint16_t id = ZMK_HID_USAGE_ID(encoded); uint16_t id = ZMK_HID_USAGE_ID(encoded);
uint8_t implicit_modifiers = 0x00; uint8_t implicit_modifiers = 0x00;
uint8_t explicit_modifiers = 0x00; uint8_t explicit_modifiers = 0x00;

2
app/src/behaviors/behavior_caps_word.c

@ -162,7 +162,7 @@ static int behavior_caps_word_init(const struct device *dev) {
#define CAPS_WORD_LABEL(i, _n) DT_INST_LABEL(i) #define CAPS_WORD_LABEL(i, _n) DT_INST_LABEL(i)
#define PARSE_BREAK(i) \ #define PARSE_BREAK(i) \
{.page = (ZMK_HID_USAGE_PAGE(i) & 0xFF), \ {.page = ZMK_HID_USAGE_PAGE(i), \
.id = ZMK_HID_USAGE_ID(i), \ .id = ZMK_HID_USAGE_ID(i), \
.implicit_modifiers = SELECT_MODS(i)}, .implicit_modifiers = SELECT_MODS(i)},

2
app/src/behaviors/behavior_sticky_key.c

@ -199,7 +199,7 @@ static int sticky_key_keycode_state_changed_listener(const zmk_event_t *eh) {
if (strcmp(sticky_key->config->behavior.behavior_dev, "KEY_PRESS") == 0 && if (strcmp(sticky_key->config->behavior.behavior_dev, "KEY_PRESS") == 0 &&
ZMK_HID_USAGE_ID(sticky_key->param1) == ev->keycode && ZMK_HID_USAGE_ID(sticky_key->param1) == ev->keycode &&
(ZMK_HID_USAGE_PAGE(sticky_key->param1) & 0xFF) == ev->usage_page && ZMK_HID_USAGE_PAGE(sticky_key->param1) == ev->usage_page &&
SELECT_MODS(sticky_key->param1) == ev->implicit_modifiers) { SELECT_MODS(sticky_key->param1) == ev->implicit_modifiers) {
// don't catch key down events generated by the sticky key behavior itself // don't catch key down events generated by the sticky key behavior itself
continue; continue;

Loading…
Cancel
Save