forked from PAWPAW-Mirror/lib_xua
Add support for boot-time creation of the HID Report descriptor
This commit is contained in:
@@ -23,18 +23,24 @@
|
||||
#include "vendorrequests.h"
|
||||
#include "xc_ptr.h"
|
||||
#include "xua_ep0_uacreqs.h"
|
||||
|
||||
#if( 0 < HID_CONTROLS )
|
||||
#include "hid.h"
|
||||
#include "xua_hid.h"
|
||||
#include "xua_hid_report_descriptor.h"
|
||||
#endif
|
||||
|
||||
#if DSD_CHANS_DAC > 0
|
||||
#include "dsd_support.h"
|
||||
#endif
|
||||
|
||||
#define DEBUG_UNIT XUA_EP0
|
||||
|
||||
#ifndef DEBUG_PRINT_ENABLE_XUA_EP0
|
||||
#define DEBUG_PRINT_ENABLE_XUA_EP0 0
|
||||
#endif // DEBUG_PRINT_ENABLE_XUA_EP0
|
||||
#include "debug_print.h"
|
||||
|
||||
#include "debug_print.h"
|
||||
#include "xua_usb_params_funcs.h"
|
||||
|
||||
#ifndef __XC__
|
||||
@@ -51,7 +57,7 @@
|
||||
#if ((AUDIO_CLASS == 1) || (AUDIO_CLASS_FALLBACK)) && defined(DFU)
|
||||
#warning DFU will not be enabled in AUDIO 1.0 mode due to Windows requesting driver
|
||||
#endif
|
||||
#endif
|
||||
#endif // FORCE_UAC1_DFU
|
||||
|
||||
/* MIDI not supported in Audio 1.0 mode */
|
||||
#if ((AUDIO_CLASS == 1) || (AUDIO_CLASS_FALLBACK)) && defined(MIDI)
|
||||
@@ -85,9 +91,6 @@ extern void device_reboot(void);
|
||||
|
||||
#endif
|
||||
|
||||
#if( 0 < HID_CONTROLS )
|
||||
#include "xua_hid.h"
|
||||
#endif
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#endif
|
||||
@@ -518,6 +521,22 @@ void XUA_Endpoint0_init(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioCont
|
||||
|
||||
#endif
|
||||
|
||||
#if( 0 < HID_CONTROLS )
|
||||
hidPrepareReportDescriptor();
|
||||
|
||||
size_t hidReportDescriptorLength = hidGetReportDescriptorLength();
|
||||
unsigned char hidReportDescriptorLengthLo = hidReportDescriptorLength & 0xFF;
|
||||
unsigned char hidReportDescriptorLengthHi = (hidReportDescriptorLength & 0xFF00) >> 8;
|
||||
|
||||
#if( AUDIO_CLASS == 1 )
|
||||
cfgDesc_Audio1[USB_HID_DESCRIPTOR_OFFSET + HID_DESCRIPTOR_LENGTH_FIELD_OFFSET ] = hidReportDescriptorLengthLo;
|
||||
cfgDesc_Audio1[USB_HID_DESCRIPTOR_OFFSET + HID_DESCRIPTOR_LENGTH_FIELD_OFFSET + 1] = hidReportDescriptorLengthHi;
|
||||
#endif
|
||||
|
||||
hidDescriptor[HID_DESCRIPTOR_LENGTH_FIELD_OFFSET ] = hidReportDescriptorLengthLo;
|
||||
hidDescriptor[HID_DESCRIPTOR_LENGTH_FIELD_OFFSET + 1] = hidReportDescriptorLengthHi;
|
||||
#endif // 0 < HID_CONTROLS
|
||||
|
||||
}
|
||||
|
||||
void XUA_Endpoint0_loop(XUD_Result_t result, USB_SetupPacket_t sp, chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
||||
@@ -729,15 +748,22 @@ void XUA_Endpoint0_loop(XUD_Result_t result, USB_SetupPacket_t sp, chanend c_ep0
|
||||
switch (descriptorType)
|
||||
{
|
||||
case HID_HID:
|
||||
/* Return HID Descriptor */
|
||||
result = XUD_DoGetRequest(ep0_out, ep0_in, hidDescriptor,
|
||||
sizeof(hidDescriptor), sp.wLength);
|
||||
{
|
||||
/* Return HID Descriptor */
|
||||
result = XUD_DoGetRequest(ep0_out, ep0_in, hidDescriptor,
|
||||
sizeof(hidDescriptor), sp.wLength);
|
||||
}
|
||||
break;
|
||||
case HID_REPORT:
|
||||
/* Return HID report descriptor */
|
||||
result = XUD_DoGetRequest(ep0_out, ep0_in, hidReportDescriptor,
|
||||
sizeof(hidReportDescriptor), sp.wLength);
|
||||
break;
|
||||
{
|
||||
/* Return HID report descriptor */
|
||||
unsigned char* hidReportDescriptorPtr;
|
||||
hidReportDescriptorPtr = hidGetReportDescriptor();
|
||||
size_t hidReportDescriptorLength = hidGetReportDescriptorLength();
|
||||
result = XUD_DoGetRequest(ep0_out, ep0_in, hidReportDescriptorPtr,
|
||||
hidReportDescriptorLength, sp.wLength);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user