|
|
@ -21,21 +21,10 @@ static int hid_listener_keycode_pressed(const struct zmk_keycode_state_changed * |
|
|
|
|
|
|
|
|
|
|
|
LOG_DBG("usage_page 0x%02X keycode 0x%02X implicit_mods 0x%02X explicit_mods 0x%02X", |
|
|
|
LOG_DBG("usage_page 0x%02X keycode 0x%02X implicit_mods 0x%02X explicit_mods 0x%02X", |
|
|
|
ev->usage_page, ev->keycode, ev->implicit_modifiers, ev->explicit_modifiers); |
|
|
|
ev->usage_page, ev->keycode, ev->implicit_modifiers, ev->explicit_modifiers); |
|
|
|
switch (ev->usage_page) { |
|
|
|
err = zmk_hid_press(ZMK_HID_USAGE(ev->usage_page, ev->keycode)); |
|
|
|
case HID_USAGE_KEY: |
|
|
|
if (err < 0) { |
|
|
|
err = zmk_hid_keyboard_press(ev->keycode); |
|
|
|
LOG_DBG("Unable to press keycode"); |
|
|
|
if (err < 0) { |
|
|
|
return err; |
|
|
|
LOG_ERR("Unable to press keycode"); |
|
|
|
|
|
|
|
return err; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case HID_USAGE_CONSUMER: |
|
|
|
|
|
|
|
err = zmk_hid_consumer_press(ev->keycode); |
|
|
|
|
|
|
|
if (err < 0) { |
|
|
|
|
|
|
|
LOG_ERR("Unable to press keycode"); |
|
|
|
|
|
|
|
return err; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
explicit_mods_changed = zmk_hid_register_mods(ev->explicit_modifiers); |
|
|
|
explicit_mods_changed = zmk_hid_register_mods(ev->explicit_modifiers); |
|
|
|
implicit_mods_changed = zmk_hid_implicit_modifiers_press(ev->implicit_modifiers); |
|
|
|
implicit_mods_changed = zmk_hid_implicit_modifiers_press(ev->implicit_modifiers); |
|
|
@ -56,20 +45,10 @@ static int hid_listener_keycode_released(const struct zmk_keycode_state_changed |
|
|
|
|
|
|
|
|
|
|
|
LOG_DBG("usage_page 0x%02X keycode 0x%02X implicit_mods 0x%02X explicit_mods 0x%02X", |
|
|
|
LOG_DBG("usage_page 0x%02X keycode 0x%02X implicit_mods 0x%02X explicit_mods 0x%02X", |
|
|
|
ev->usage_page, ev->keycode, ev->implicit_modifiers, ev->explicit_modifiers); |
|
|
|
ev->usage_page, ev->keycode, ev->implicit_modifiers, ev->explicit_modifiers); |
|
|
|
switch (ev->usage_page) { |
|
|
|
err = zmk_hid_release(ZMK_HID_USAGE(ev->usage_page, ev->keycode)); |
|
|
|
case HID_USAGE_KEY: |
|
|
|
if (err < 0) { |
|
|
|
err = zmk_hid_keyboard_release(ev->keycode); |
|
|
|
LOG_DBG("Unable to release keycode"); |
|
|
|
if (err < 0) { |
|
|
|
return err; |
|
|
|
LOG_ERR("Unable to release keycode"); |
|
|
|
|
|
|
|
return err; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case HID_USAGE_CONSUMER: |
|
|
|
|
|
|
|
err = zmk_hid_consumer_release(ev->keycode); |
|
|
|
|
|
|
|
if (err < 0) { |
|
|
|
|
|
|
|
LOG_ERR("Unable to release keycode"); |
|
|
|
|
|
|
|
return err; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
explicit_mods_changed = zmk_hid_unregister_mods(ev->explicit_modifiers); |
|
|
|
explicit_mods_changed = zmk_hid_unregister_mods(ev->explicit_modifiers); |
|
|
@ -104,4 +83,4 @@ int hid_listener(const zmk_event_t *eh) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ZMK_LISTENER(hid_listener, hid_listener); |
|
|
|
ZMK_LISTENER(hid_listener, hid_listener); |
|
|
|
ZMK_SUBSCRIPTION(hid_listener, zmk_keycode_state_changed); |
|
|
|
ZMK_SUBSCRIPTION(hid_listener, zmk_keycode_state_changed); |
|
|
|