hid_device: add HID_SUBEVENT_VIRTUAL_CABLE_UNPLUG, fix HID suspend events

This commit is contained in:
Milanka Ringwald 2020-12-01 11:52:46 +01:00 committed by Matthias Ringwald
parent 1ad99f3bd3
commit acfd7ed247
3 changed files with 30 additions and 8 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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);