1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

hid: fix response to HID descriptor

HID driver was incorrectly giving back the HID interface
descriptor when asked for the HID descriptor.  This should
let OP boards interact better with generic HID layer drivers
and also gives us nicer output in lsusb once the HID descriptor
is read.
This commit is contained in:
Stacey Sheldon 2012-03-04 19:43:56 -05:00
parent 61d59828dc
commit fdf54ab86c
5 changed files with 14 additions and 14 deletions

View File

@ -250,7 +250,7 @@ int32_t PIOS_USB_DESC_HID_CDC_Init(void)
PIOS_USBHOOK_RegisterDevice((uint8_t *)&device_desc, sizeof(device_desc));
PIOS_USB_HID_RegisterHidInterface((uint8_t *)&(config_hid_cdc.hid_if), sizeof(config_hid_cdc.hid_if));
PIOS_USB_HID_RegisterHidDescriptor((uint8_t *)&(config_hid_cdc.hid), sizeof(config_hid_cdc.hid));
PIOS_USB_HID_RegisterHidReport((uint8_t *)hid_report_desc, sizeof(hid_report_desc));
return 0;

View File

@ -158,7 +158,7 @@ int32_t PIOS_USB_DESC_HID_ONLY_Init(void)
PIOS_USBHOOK_RegisterDevice((uint8_t *)&device_desc, sizeof(device_desc));
PIOS_USB_HID_RegisterHidInterface((uint8_t *)&(config_hid_only.hid_if), sizeof(config_hid_only.hid_if));
PIOS_USB_HID_RegisterHidDescriptor((uint8_t *)&(config_hid_only.hid), sizeof(config_hid_only.hid));
PIOS_USB_HID_RegisterHidReport((uint8_t *)hid_report_desc, sizeof(hid_report_desc));
return 0;

View File

@ -65,12 +65,12 @@ void PIOS_USBHOOK_RegisterString(enum usb_string_desc string_id, const uint8_t *
}
}
static ONE_DESCRIPTOR Hid_Interface_Descriptor;
static ONE_DESCRIPTOR Hid_Descriptor;
void PIOS_USB_HID_RegisterHidInterface(const uint8_t * desc, uint16_t desc_size)
void PIOS_USB_HID_RegisterHidDescriptor(const uint8_t * desc, uint16_t desc_size)
{
Hid_Interface_Descriptor.Descriptor = desc;
Hid_Interface_Descriptor.Descriptor_Size = desc_size;
Hid_Descriptor.Descriptor = desc;
Hid_Descriptor.Descriptor_Size = desc_size;
}
static ONE_DESCRIPTOR Hid_Report_Descriptor;
@ -468,7 +468,7 @@ static const uint8_t *PIOS_USBHOOK_GetReportDescriptor(uint16_t Length)
*******************************************************************************/
static const uint8_t *PIOS_USBHOOK_GetHIDDescriptor(uint16_t Length)
{
return Standard_GetDescriptorData(Length, &Hid_Interface_Descriptor);
return Standard_GetDescriptorData(Length, &Hid_Descriptor);
}
/*******************************************************************************

View File

@ -150,12 +150,12 @@ out_fail:
}
static struct pios_usbhook_descriptor hid_if_desc;
static struct pios_usbhook_descriptor hid_desc;
void PIOS_USB_HID_RegisterHidInterface(const uint8_t * desc, uint16_t length)
void PIOS_USB_HID_RegisterHidDescriptor(const uint8_t * desc, uint16_t length)
{
hid_if_desc.descriptor = desc;
hid_if_desc.length = length;
hid_desc.descriptor = desc;
hid_desc.length = length;
}
static struct pios_usbhook_descriptor hid_report_desc;
@ -358,8 +358,8 @@ static bool PIOS_USB_HID_IF_Setup(uint32_t usb_hid_id, struct usb_setup_request
MIN(hid_report_desc.length, req->wLength));
break;
case USB_DESC_TYPE_HID:
PIOS_USBHOOK_CtrlTx(hid_if_desc.descriptor,
MIN(hid_if_desc.length, req->wLength));
PIOS_USBHOOK_CtrlTx(hid_desc.descriptor,
MIN(hid_desc.length, req->wLength));
break;
default:
/* Unhandled descriptor request */

View File

@ -35,7 +35,7 @@ extern int32_t PIOS_USB_HID_Reenumerate(void);
extern int32_t PIOS_USB_HID_ChangeConnectionState(uint32_t Connected);
extern bool PIOS_USB_HID_CheckAvailable(uint8_t id);
extern void PIOS_USB_HID_RegisterHidInterface(const uint8_t * desc, uint16_t length);
extern void PIOS_USB_HID_RegisterHidDescriptor(const uint8_t * desc, uint16_t length);
extern void PIOS_USB_HID_RegisterHidReport(const uint8_t * desc, uint16_t length);
#endif /* PIOS_USB_HID_H */