From 15ca74c8ad027df7664fddf79fce89b2c97dc0f3 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 14 Jul 2021 23:39:10 +0900 Subject: [PATCH] lufa: Fix system control --- tmk_core/protocol/lufa/lufa.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index e5077dfb..7a5bd746 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -603,10 +603,12 @@ static void send_system(uint16_t data) if (USB_DeviceState != DEVICE_STATE_Configured) return; - report_extra_t r = { - .report_id = REPORT_ID_SYSTEM, - .usage = data - SYSTEM_POWER_DOWN + 1 - }; + report_extra_t r = { .report_id = REPORT_ID_SYSTEM }; + if (data < SYSTEM_POWER_DOWN) { + r.usage = 0; + } else { + r.usage = data - SYSTEM_POWER_DOWN + 1; + } Endpoint_SelectEndpoint(MOUSE_IN_EPNUM); /* Check if write ready for a polling interval around 10ms */