Added SetInterface function

This might help use to set a different hid interface later via keyboard/mouse api
This commit is contained in:
NicoHood 2015-09-22 22:07:21 +02:00
parent 700ca71cf8
commit 85922c2860
2 changed files with 13 additions and 8 deletions

View file

@ -55,21 +55,25 @@ uint8_t HID_::_hid_idle = 1;
int HID_::HID_GetInterface(u8* interfaceNum) int HID_::HID_GetInterface(u8* interfaceNum)
{ {
interfaceNum[0] += 1; // uses 1 interfaceNum[0] += 1; // uses 1
_hidInterface = _hidInterface.hid =
{
#if defined(USE_BOOT_KEYBOARD_PROTOCOL) #if defined(USE_BOOT_KEYBOARD_PROTOCOL)
D_INTERFACE(HID_INTERFACE,1,3,1,1), D_INTERFACE(HID_INTERFACE,1,3,1,1);
#elif defined(USE_BOOT_MOUSE_PROTOCOL) #elif defined(USE_BOOT_MOUSE_PROTOCOL)
D_INTERFACE(HID_INTERFACE,1,3,1,2), D_INTERFACE(HID_INTERFACE,1,3,1,2);
#else #else
D_INTERFACE(HID_INTERFACE,1,3,0,0), D_INTERFACE(HID_INTERFACE,1,3,0,0);
#endif #endif
D_HIDREPORT(sizeof_hidReportDescriptor), _hidInterface.desc = D_HIDREPORT(sizeof_hidReportDescriptor);
D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,USB_EP_SIZE,0x01) _hidInterface.in = D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,USB_EP_SIZE,0x01);
};
return USB_SendControl(0,&_hidInterface,sizeof(_hidInterface)); return USB_SendControl(0,&_hidInterface,sizeof(_hidInterface));
} }
void HID_::SetInterface(InterfaceDescriptor interface)
{
// Change the HID Interface (required for BOOT protocol)
_hidInterface.hid = interface;
}
int HID_::HID_GetDescriptor(int8_t t) int HID_::HID_GetDescriptor(int8_t t)
{ {
if (HID_REPORT_DESCRIPTOR_TYPE == t) { if (HID_REPORT_DESCRIPTOR_TYPE == t) {

View file

@ -78,6 +78,7 @@ private:
int begin(void); int begin(void);
void SendReport(uint8_t id, const void* data, int len); void SendReport(uint8_t id, const void* data, int len);
void AppendDescriptor(HIDDevice* device); void AppendDescriptor(HIDDevice* device);
void SetInterface(InterfaceDescriptor interface);
// Static functions // Static functions
static int HID_GetInterface(u8* interfaceNum); static int HID_GetInterface(u8* interfaceNum);