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 "vendorrequests.h"
|
||||||
#include "xc_ptr.h"
|
#include "xc_ptr.h"
|
||||||
#include "xua_ep0_uacreqs.h"
|
#include "xua_ep0_uacreqs.h"
|
||||||
|
|
||||||
#if( 0 < HID_CONTROLS )
|
#if( 0 < HID_CONTROLS )
|
||||||
#include "hid.h"
|
#include "hid.h"
|
||||||
|
#include "xua_hid.h"
|
||||||
|
#include "xua_hid_report_descriptor.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DSD_CHANS_DAC > 0
|
#if DSD_CHANS_DAC > 0
|
||||||
#include "dsd_support.h"
|
#include "dsd_support.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEBUG_UNIT XUA_EP0
|
#define DEBUG_UNIT XUA_EP0
|
||||||
|
|
||||||
#ifndef DEBUG_PRINT_ENABLE_XUA_EP0
|
#ifndef DEBUG_PRINT_ENABLE_XUA_EP0
|
||||||
#define DEBUG_PRINT_ENABLE_XUA_EP0 0
|
#define DEBUG_PRINT_ENABLE_XUA_EP0 0
|
||||||
#endif // DEBUG_PRINT_ENABLE_XUA_EP0
|
#endif // DEBUG_PRINT_ENABLE_XUA_EP0
|
||||||
#include "debug_print.h"
|
|
||||||
|
|
||||||
|
#include "debug_print.h"
|
||||||
#include "xua_usb_params_funcs.h"
|
#include "xua_usb_params_funcs.h"
|
||||||
|
|
||||||
#ifndef __XC__
|
#ifndef __XC__
|
||||||
@@ -51,7 +57,7 @@
|
|||||||
#if ((AUDIO_CLASS == 1) || (AUDIO_CLASS_FALLBACK)) && defined(DFU)
|
#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
|
#warning DFU will not be enabled in AUDIO 1.0 mode due to Windows requesting driver
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif // FORCE_UAC1_DFU
|
||||||
|
|
||||||
/* MIDI not supported in Audio 1.0 mode */
|
/* MIDI not supported in Audio 1.0 mode */
|
||||||
#if ((AUDIO_CLASS == 1) || (AUDIO_CLASS_FALLBACK)) && defined(MIDI)
|
#if ((AUDIO_CLASS == 1) || (AUDIO_CLASS_FALLBACK)) && defined(MIDI)
|
||||||
@@ -85,9 +91,6 @@ extern void device_reboot(void);
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if( 0 < HID_CONTROLS )
|
|
||||||
#include "xua_hid.h"
|
|
||||||
#endif
|
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||||
#endif
|
#endif
|
||||||
@@ -518,6 +521,22 @@ void XUA_Endpoint0_init(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioCont
|
|||||||
|
|
||||||
#endif
|
#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,
|
void XUA_Endpoint0_loop(XUD_Result_t result, USB_SetupPacket_t sp, chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
||||||
@@ -729,14 +748,21 @@ void XUA_Endpoint0_loop(XUD_Result_t result, USB_SetupPacket_t sp, chanend c_ep0
|
|||||||
switch (descriptorType)
|
switch (descriptorType)
|
||||||
{
|
{
|
||||||
case HID_HID:
|
case HID_HID:
|
||||||
|
{
|
||||||
/* Return HID Descriptor */
|
/* Return HID Descriptor */
|
||||||
result = XUD_DoGetRequest(ep0_out, ep0_in, hidDescriptor,
|
result = XUD_DoGetRequest(ep0_out, ep0_in, hidDescriptor,
|
||||||
sizeof(hidDescriptor), sp.wLength);
|
sizeof(hidDescriptor), sp.wLength);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case HID_REPORT:
|
case HID_REPORT:
|
||||||
|
{
|
||||||
/* Return HID report descriptor */
|
/* Return HID report descriptor */
|
||||||
result = XUD_DoGetRequest(ep0_out, ep0_in, hidReportDescriptor,
|
unsigned char* hidReportDescriptorPtr;
|
||||||
sizeof(hidReportDescriptor), sp.wLength);
|
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