mirror of
https://github.com/mon/PocketVoltex.git
synced 2026-10-11 00:28:11 +03:00
Fix config comunication 🙏
Turns out using 6 endpoints when you only support 5 is a recipe for disaster
This commit is contained in:
@@ -34,43 +34,28 @@ typedef struct
|
||||
} LED_Report_t;
|
||||
|
||||
/** Buffer to hold the previously generated Keyboard HID report, for comparison purposes inside the HID class driver. */
|
||||
static uint8_t PrevKeyboardHIDReportBuffer[sizeof(Keyboard_Report_t)];
|
||||
static uint8_t PrevMouseHIDReportBuffer[sizeof(USB_MouseReport_Data_t)];
|
||||
static uint8_t PrevInputsHIDReportBuffer[MAX(sizeof(Keyboard_Report_t), sizeof(USB_MouseReport_Data_t))];
|
||||
static uint8_t PrevLEDHIDReportBuffer[sizeof(LED_Report_t)];
|
||||
|
||||
static uint8_t sendKeyboard = 0;
|
||||
|
||||
/** LUFA HID Class driver interface configuration and state information. This structure is
|
||||
* passed to all HID Class driver functions, so that multiple instances of the same class
|
||||
* within a device can be differentiated from one another.
|
||||
*/
|
||||
USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
|
||||
USB_ClassInfo_HID_Device_t Inputs_HID_Interface =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.InterfaceNumber = INTERFACE_ID_Keyboard,
|
||||
.InterfaceNumber = INTERFACE_ID_Inputs,
|
||||
.ReportINEndpoint =
|
||||
{
|
||||
.Address = KEYBOARD_EPADDR,
|
||||
.Size = KEYBOARD_EPSIZE,
|
||||
.Address = INPUTS_EPADDR,
|
||||
.Size = INPUTS_EPSIZE,
|
||||
.Banks = 1,
|
||||
},
|
||||
.PrevReportINBuffer = PrevKeyboardHIDReportBuffer,
|
||||
.PrevReportINBufferSize = sizeof(PrevKeyboardHIDReportBuffer),
|
||||
},
|
||||
};
|
||||
|
||||
USB_ClassInfo_HID_Device_t Mouse_HID_Interface =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.InterfaceNumber = INTERFACE_ID_Mouse,
|
||||
.ReportINEndpoint =
|
||||
{
|
||||
.Address = MOUSE_IN_EPADDR,
|
||||
.Size = MOUSE_EPSIZE,
|
||||
.Banks = 1,
|
||||
},
|
||||
.PrevReportINBuffer = PrevMouseHIDReportBuffer,
|
||||
.PrevReportINBufferSize = sizeof(PrevMouseHIDReportBuffer),
|
||||
.PrevReportINBuffer = PrevInputsHIDReportBuffer,
|
||||
.PrevReportINBufferSize = sizeof(PrevInputsHIDReportBuffer),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -170,8 +155,7 @@ int main(void)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
HID_Device_USBTask(&Keyboard_HID_Interface);
|
||||
HID_Device_USBTask(&Mouse_HID_Interface);
|
||||
HID_Device_USBTask(&Inputs_HID_Interface);
|
||||
HID_Device_USBTask(&LED_HID_Interface);
|
||||
USB_USBTask();
|
||||
|
||||
@@ -253,11 +237,12 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
||||
void* ReportData,
|
||||
uint16_t* const ReportSize)
|
||||
{
|
||||
if(ReportType != HID_REPORT_ITEM_In) {
|
||||
if(ReportType != HID_REPORT_ITEM_In || HIDInterfaceInfo != &Inputs_HID_Interface) {
|
||||
*ReportSize = 0;
|
||||
return false;
|
||||
}
|
||||
if (HIDInterfaceInfo == &Keyboard_HID_Interface) {
|
||||
sendKeyboard ^= 1;
|
||||
if (sendKeyboard) {
|
||||
Keyboard_Report_t* KeyboardReport = (Keyboard_Report_t*)ReportData;
|
||||
|
||||
// Only the first 4 bytes are read by bemanitools, so let's use the first
|
||||
@@ -282,11 +267,11 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
||||
}
|
||||
}
|
||||
|
||||
*ReportID = HID_REPORTID_KeyboardReport;
|
||||
*ReportSize = sizeof(Keyboard_Report_t);
|
||||
|
||||
switchesChanged = 0;
|
||||
return true;
|
||||
} else if(HIDInterfaceInfo == &Mouse_HID_Interface) {
|
||||
} else {
|
||||
USB_MouseReport_Data_t* MouseReport = (USB_MouseReport_Data_t*)ReportData;
|
||||
|
||||
MouseReport->X = encoder_get(0);
|
||||
@@ -297,11 +282,10 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
||||
encoder_set(0, 0);
|
||||
encoder_set(1, 0);
|
||||
|
||||
*ReportID = HID_REPORTID_MouseReport;
|
||||
*ReportSize = sizeof(USB_MouseReport_Data_t);
|
||||
return true;
|
||||
}
|
||||
*ReportSize = 0;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/** HID class driver callback function for the processing of HID reports from the host.
|
||||
@@ -356,10 +340,9 @@ void EVENT_USB_Device_Disconnect(void)
|
||||
/** Event handler for the library USB Configuration Changed event. */
|
||||
void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
{
|
||||
Endpoint_ConfigureEndpoint(CONFIG_IN_EPADDR, EP_TYPE_BULK, CONFIG_EPSIZE, 1);
|
||||
Endpoint_ConfigureEndpoint(CONFIG_OUT_EPADDR, EP_TYPE_BULK, CONFIG_EPSIZE, 1);
|
||||
HID_Device_ConfigureEndpoints(&Keyboard_HID_Interface);
|
||||
HID_Device_ConfigureEndpoints(&Mouse_HID_Interface);
|
||||
Endpoint_ConfigureEndpoint(CONFIG_IN_EPADDR, EP_TYPE_BULK, CONFIG_EPSIZE, 1);
|
||||
HID_Device_ConfigureEndpoints(&Inputs_HID_Interface);
|
||||
HID_Device_ConfigureEndpoints(&LED_HID_Interface);
|
||||
|
||||
USB_Device_EnableSOFEvents();
|
||||
@@ -369,16 +352,14 @@ void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
void EVENT_USB_Device_ControlRequest(void)
|
||||
{
|
||||
USB_Process_BOS();
|
||||
HID_Device_ProcessControlRequest(&Keyboard_HID_Interface);
|
||||
HID_Device_ProcessControlRequest(&Mouse_HID_Interface);
|
||||
HID_Device_ProcessControlRequest(&Inputs_HID_Interface);
|
||||
HID_Device_ProcessControlRequest(&LED_HID_Interface);
|
||||
}
|
||||
|
||||
/** Event handler for the USB device Start Of Frame event. */
|
||||
void EVENT_USB_Device_StartOfFrame(void)
|
||||
{
|
||||
HID_Device_MillisecondElapsed(&Keyboard_HID_Interface);
|
||||
HID_Device_MillisecondElapsed(&Mouse_HID_Interface);
|
||||
HID_Device_MillisecondElapsed(&Inputs_HID_Interface);
|
||||
HID_Device_MillisecondElapsed(&LED_HID_Interface);
|
||||
|
||||
if(hidTimeout > HID_LED_TIMEOUT) {
|
||||
|
||||
Reference in New Issue
Block a user