LUFA: make send_report a boolean (#392)

This commit is contained in:
Drashna Jaelre
2024-07-04 23:12:21 -07:00
committed by GitHub
parent 0754cffbee
commit d03c020a9c
2 changed files with 7 additions and 5 deletions

View File

@@ -16,7 +16,8 @@ rawhid_state_t rawhid_state = {
uint8_t pairing_input_index = 0; uint8_t pairing_input_index = 0;
#if defined(PROTOCOL_LUFA) #if defined(PROTOCOL_LUFA)
void send_report(uint8_t endpoint, void *report, size_t size); bool send_report(uint8_t endpoint, void *report, size_t size);
#include "usb_descriptor.h"
# define RAW_EP_NAME RAW_IN_EPNUM # define RAW_EP_NAME RAW_IN_EPNUM
#elif defined(PROTOCOL_CHIBIOS) #elif defined(PROTOCOL_CHIBIOS)
# include "usb_endpoints.h" # include "usb_endpoints.h"

View File

@@ -87,10 +87,10 @@ static void send_mouse(report_mouse_t *report);
static void send_extra(report_extra_t *report); static void send_extra(report_extra_t *report);
host_driver_t lufa_driver = {keyboard_leds, send_keyboard, send_nkro, send_mouse, send_extra}; host_driver_t lufa_driver = {keyboard_leds, send_keyboard, send_nkro, send_mouse, send_extra};
void send_report(uint8_t endpoint, void *report, size_t size) { bool send_report(uint8_t endpoint, void *report, size_t size) {
uint8_t timeout = 255; uint8_t timeout = 255;
if (USB_DeviceState != DEVICE_STATE_Configured) return; if (USB_DeviceState != DEVICE_STATE_Configured) return false;
Endpoint_SelectEndpoint(endpoint); Endpoint_SelectEndpoint(endpoint);
@@ -98,10 +98,11 @@ void send_report(uint8_t endpoint, void *report, size_t size) {
while (timeout-- && !Endpoint_IsReadWriteAllowed()) { while (timeout-- && !Endpoint_IsReadWriteAllowed()) {
_delay_us(40); _delay_us(40);
} }
if (!Endpoint_IsReadWriteAllowed()) return; if (!Endpoint_IsReadWriteAllowed()) return false;
Endpoint_Write_Stream_LE(report, size, NULL); uint8_t report_status = Endpoint_Write_Stream_LE(report, size, NULL);
Endpoint_ClearIN(); Endpoint_ClearIN();
return (bool)report_status;
} }
#ifdef VIRTSER_ENABLE #ifdef VIRTSER_ENABLE