diff --git a/src/btstack_defines.h b/src/btstack_defines.h index ef04d5da0..7a2600fca 100644 --- a/src/btstack_defines.h +++ b/src/btstack_defines.h @@ -2892,17 +2892,25 @@ typedef uint8_t sm_key_t[16]; /** * @format 12 * @param subevent_code - * @param con_handle + * @param hid_cid */ #define HID_SUBEVENT_SUSPEND 0x04 /** * @format 12 * @param subevent_code - * @param con_handle + * @param hid_cid */ #define HID_SUBEVENT_EXIT_SUSPEND 0x05 +/** + * @format 12 + * @param subevent_code + * @param hid_cid +*/ +#define HID_SUBEVENT_VIRTUAL_CABLE_UNPLUG 0x06 + + // HIDS Meta Event Group diff --git a/src/btstack_event.h b/src/btstack_event.h index cb01b098d..f89308d39 100644 --- a/src/btstack_event.h +++ b/src/btstack_event.h @@ -8658,22 +8658,32 @@ static inline uint16_t hid_subevent_can_send_now_get_hid_cid(const uint8_t * eve } /** - * @brief Get field con_handle from event HID_SUBEVENT_SUSPEND + * @brief Get field hid_cid from event HID_SUBEVENT_SUSPEND * @param event packet - * @return con_handle + * @return hid_cid * @note: btstack_type 2 */ -static inline uint16_t hid_subevent_suspend_get_con_handle(const uint8_t * event){ +static inline uint16_t hid_subevent_suspend_get_hid_cid(const uint8_t * event){ return little_endian_read_16(event, 3); } /** - * @brief Get field con_handle from event HID_SUBEVENT_EXIT_SUSPEND + * @brief Get field hid_cid from event HID_SUBEVENT_EXIT_SUSPEND * @param event packet - * @return con_handle + * @return hid_cid * @note: btstack_type 2 */ -static inline uint16_t hid_subevent_exit_suspend_get_con_handle(const uint8_t * event){ +static inline uint16_t hid_subevent_exit_suspend_get_hid_cid(const uint8_t * event){ + return little_endian_read_16(event, 3); +} + +/** + * @brief Get field hid_cid from event HID_SUBEVENT_VIRTUAL_CABLE_UNPLUG + * @param event packet + * @return hid_cid + * @note: btstack_type 2 + */ +static inline uint16_t hid_subevent_virtual_cable_unplug_get_hid_cid(const uint8_t * event){ return little_endian_read_16(event, 3); } diff --git a/src/classic/hid_device.c b/src/classic/hid_device.c index 9effc54cf..b02a910e2 100644 --- a/src/classic/hid_device.c +++ b/src/classic/hid_device.c @@ -569,6 +569,10 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * pack case HID_CONTROL_PARAM_EXIT_SUSPEND: hid_device_emit_event(device, HID_SUBEVENT_EXIT_SUSPEND); break; + case HID_CONTROL_PARAM_VIRTUAL_CABLE_UNPLUG: + device->unplugged = true; + hid_device_emit_event(device, HID_SUBEVENT_VIRTUAL_CABLE_UNPLUG); + break; default: device->state = HID_DEVICE_W2_SEND_UNSUPPORTED_REQUEST; l2cap_request_can_send_now_event(device->control_cid);