From 8534e4cc7d00a8db19f36d5053b3b5d9c24530ae Mon Sep 17 00:00:00 2001 From: Aditya Bhargava Date: Thu, 18 Sep 2025 18:02:28 -0400 Subject: [PATCH] Initialize `usbMouseFeatBuffer` globally When waking from sleep, a Linux host will communicate with the device such that `kUSB_DeviceEventSetConfiguration` is triggered, but won't send `SetReport` like it does when first initializing the device upon connection. This broke scrolling when waking from sleep since the `usbMouseFeatBuffer` got re-initialized to `0` but never got the `SetReport` that would set it back to `1`, resulting in the device thinking it should operate in low-res scrolling mode while the host continues to expect high-resolution scrolling. To fix this, I've removed the initialization of `usbMouseFeatBuffer` from `kUSB_DeviceEventSetConfiguration` and instead initialize it globally, when it's declared. Fixes #1261. --- right/src/usb_interfaces/usb_interface_mouse.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/right/src/usb_interfaces/usb_interface_mouse.c b/right/src/usb_interfaces/usb_interface_mouse.c index 2adaf9d9c..d8795ed8c 100644 --- a/right/src/usb_interfaces/usb_interface_mouse.c +++ b/right/src/usb_interfaces/usb_interface_mouse.c @@ -36,7 +36,7 @@ static void SwitchActiveUsbMouseReport(void) #ifndef __ZEPHYR__ -static uint8_t usbMouseFeatBuffer[USB_MOUSE_FEAT_REPORT_LENGTH]; +static uint8_t usbMouseFeatBuffer[USB_MOUSE_FEAT_REPORT_LENGTH] = {0}; usb_hid_protocol_t UsbMouseGetProtocol(void) { @@ -80,7 +80,6 @@ usb_status_t UsbMouseCallback(class_handle_t handle, uint32_t event, void *param switch (event) { case ((uint32_t)-kUSB_DeviceEventSetConfiguration): - usbMouseFeatBuffer[0] = 0; error = kStatus_USB_Success; break; case ((uint32_t)-kUSB_DeviceEventSetInterface):