lufa: Fix system/consumer report in Boot mouse

Cannot send system/consumer report while mouse is set
in boot protocol. Mouse, system and consumer report shares
one interface using different report IDs. In boot protocol
only mouse can report without report ID. If a report ID is
sent while in boot protocol it will be recognized as mosue
button state incorrectly by host.

A user reported that Mac ejects disc drive at startup when
using NeXT converter. Keeping mouse button pressed while
bootup forces Mac to eject disc.
This commit is contained in:
tmk 2023-03-05 14:30:51 +09:00
parent b5f2bfce08
commit 0090098141

View file

@ -488,7 +488,6 @@ void EVENT_USB_Device_ControlRequest(void)
Endpoint_ClearStatusStage();
keyboard_protocol = (USB_ControlRequest.wValue & 0xFF);
clear_keyboard();
#ifdef TMK_LUFA_DEBUG
xprintf("[P%d %04X]", USB_ControlRequest.wIndex, USB_ControlRequest.wValue);
#endif
@ -500,7 +499,9 @@ void EVENT_USB_Device_ControlRequest(void)
Endpoint_ClearStatusStage();
mouse_protocol = (USB_ControlRequest.wValue & 0xFF);
clear_keyboard();
#ifdef TMK_LUFA_DEBUG
xprintf("[P%d %04X]", USB_ControlRequest.wIndex, USB_ControlRequest.wValue);
#endif
}
#endif
}
@ -632,6 +633,12 @@ static void send_system(uint16_t data)
if (USB_DeviceState != DEVICE_STATE_Configured)
return;
#ifdef MOUSE_ENABLE
// Not send while mouse is set to Boot Protocol
if (mouse_protocol == 0)
return;
#endif
report_extra_t r = { .report_id = REPORT_ID_SYSTEM };
if (data < SYSTEM_POWER_DOWN) {
r.usage = 0;
@ -657,6 +664,12 @@ static void send_consumer(uint16_t data)
if (USB_DeviceState != DEVICE_STATE_Configured)
return;
#ifdef MOUSE_ENABLE
// Not send while mouse is set to Boot Protocol
if (mouse_protocol == 0)
return;
#endif
report_extra_t r = {
.report_id = REPORT_ID_CONSUMER,
.usage = data