From 22e282c63f9aaa32fcaa6854df3b3d7e7b4dad81 Mon Sep 17 00:00:00 2001 From: Karel Tucek Date: Thu, 6 Mar 2025 15:51:58 +0100 Subject: [PATCH 1/3] Add some logs for scrolling. --- right/src/macros/commands.c | 5 +++++ right/src/usb_interfaces/usb_interface_mouse.c | 5 +++++ right/src/usb_interfaces/usb_interface_mouse.h | 1 + 3 files changed, 11 insertions(+) diff --git a/right/src/macros/commands.c b/right/src/macros/commands.c index df1b8e79d..bfc4de08f 100644 --- a/right/src/macros/commands.c +++ b/right/src/macros/commands.c @@ -2295,6 +2295,11 @@ static macro_result_t processCommand(parser_context_t* ctx) else if (ConsumeToken(ctx, "statsRuntime")) { return Macros_ProcessStatsRuntimeCommand(); } + else if (ConsumeToken(ctx, "statsScroll")) { + ReportScrolls(); + + return MacroResult_Finished; + } else if (ConsumeToken(ctx, "statsRecordKeyTiming")) { return Macros_ProcessStatsRecordKeyTimingCommand(); } diff --git a/right/src/usb_interfaces/usb_interface_mouse.c b/right/src/usb_interfaces/usb_interface_mouse.c index 22f0c0e76..ccc817a67 100644 --- a/right/src/usb_interfaces/usb_interface_mouse.c +++ b/right/src/usb_interfaces/usb_interface_mouse.c @@ -3,6 +3,7 @@ #include #include "event_scheduler.h" #include "attributes.h" +#include "macros/status_buffer.h" #ifdef __ZEPHYR__ #include "usb/usb_compatibility.h" @@ -71,6 +72,10 @@ float HorizontalScrollMultiplier(void) return usbMouseFeatBuffer[0] & 0x01 ? USB_MOUSE_REPORT_DESCRIPTOR_MAX_RESOLUTION_MULTIPLIER_PHYSICAL_VALUE : USB_MOUSE_REPORT_DESCRIPTOR_MIN_RESOLUTION_MULTIPLIER_PHYSICAL_VALUE; } +void ReportScrolls(void) { + Macros_ReportPrintf(NULL, "Mouse feat buffer: %d (%d %d).", usbMouseFeatBuffer[0], USB_MOUSE_REPORT_DESCRIPTOR_MAX_RESOLUTION_MULTIPLIER_PHYSICAL_VALUE , USB_MOUSE_REPORT_DESCRIPTOR_MIN_RESOLUTION_MULTIPLIER_PHYSICAL_VALUE); +} + usb_status_t UsbMouseCallback(class_handle_t handle, uint32_t event, void *param) { usb_device_hid_struct_t *hidHandle = (usb_device_hid_struct_t *)handle; diff --git a/right/src/usb_interfaces/usb_interface_mouse.h b/right/src/usb_interfaces/usb_interface_mouse.h index eba52a35a..b0088ea18 100644 --- a/right/src/usb_interfaces/usb_interface_mouse.h +++ b/right/src/usb_interfaces/usb_interface_mouse.h @@ -49,6 +49,7 @@ usb_hid_protocol_t UsbMouseGetProtocol(void); #endif + void ReportScrolls(void); float VerticalScrollMultiplier(void); float HorizontalScrollMultiplier(void); void UsbMouseResetActiveReport(void); From e0cf37b3ac42c1deb83b5e2d8a728414d0d76a81 Mon Sep 17 00:00:00 2001 From: Karel Tucek Date: Sat, 8 Mar 2025 21:48:47 +0100 Subject: [PATCH 2/3] Log on both models. --- right/src/macros/commands.c | 4 ++++ right/src/usb_interfaces/usb_interface_mouse.c | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/right/src/macros/commands.c b/right/src/macros/commands.c index bfc4de08f..3bfc8567b 100644 --- a/right/src/macros/commands.c +++ b/right/src/macros/commands.c @@ -1771,6 +1771,10 @@ static macro_result_t processSwitchHostCommand(parser_context_t* ctx) return MacroResult_Finished; } +void ReportScrolls(void) { + Macros_ReportPrintf(NULL, "Scroll multipliers %d %d", (int)(VerticalScrollMultiplier()), (int)(HorizontalScrollMultiplier())); +} + static macro_result_t processCommand(parser_context_t* ctx) { if (*ctx->at == '$') { diff --git a/right/src/usb_interfaces/usb_interface_mouse.c b/right/src/usb_interfaces/usb_interface_mouse.c index ccc817a67..e1cde79a4 100644 --- a/right/src/usb_interfaces/usb_interface_mouse.c +++ b/right/src/usb_interfaces/usb_interface_mouse.c @@ -72,10 +72,6 @@ float HorizontalScrollMultiplier(void) return usbMouseFeatBuffer[0] & 0x01 ? USB_MOUSE_REPORT_DESCRIPTOR_MAX_RESOLUTION_MULTIPLIER_PHYSICAL_VALUE : USB_MOUSE_REPORT_DESCRIPTOR_MIN_RESOLUTION_MULTIPLIER_PHYSICAL_VALUE; } -void ReportScrolls(void) { - Macros_ReportPrintf(NULL, "Mouse feat buffer: %d (%d %d).", usbMouseFeatBuffer[0], USB_MOUSE_REPORT_DESCRIPTOR_MAX_RESOLUTION_MULTIPLIER_PHYSICAL_VALUE , USB_MOUSE_REPORT_DESCRIPTOR_MIN_RESOLUTION_MULTIPLIER_PHYSICAL_VALUE); -} - usb_status_t UsbMouseCallback(class_handle_t handle, uint32_t event, void *param) { usb_device_hid_struct_t *hidHandle = (usb_device_hid_struct_t *)handle; From 434f2615431b94a1b75a735dabd826b8e6d96621 Mon Sep 17 00:00:00 2001 From: Karel Tucek Date: Mon, 10 Mar 2025 10:44:49 +0100 Subject: [PATCH 3/3] Add some more logs. --- right/src/usb_composite_device.c | 3 +++ right/src/usb_interfaces/usb_interface_mouse.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/right/src/usb_composite_device.c b/right/src/usb_composite_device.c index 4cc4afb07..a61b61a24 100644 --- a/right/src/usb_composite_device.c +++ b/right/src/usb_composite_device.c @@ -202,11 +202,13 @@ static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event, break; case kUSB_DeviceEventSuspend: if (UsbCompositeDevice.attach) { + Macros_ReportPrintf(NULL, "USB suspended"); PowerMode_ActivateMode(PowerMode_Uhk60Sleep, false); status = kStatus_USB_Success; } break; case kUSB_DeviceEventResume: + Macros_ReportPrintf(NULL, "USB resumed"); PowerMode_ActivateMode(PowerMode_Awake, false); status = kStatus_USB_Success; break; @@ -214,6 +216,7 @@ static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event, uint8_t interface; UsbCompositeDevice.attach = 1; PowerMode_ActivateMode(PowerMode_Awake, false); + Macros_ReportPrintf(NULL, "Awake -> set configuration"); for (interface = 0; interface < USB_DEVICE_CONFIG_HID; ++interface) { usb_device_class_config_struct_t *intf = &UsbDeviceCompositeConfigList.config[interface]; diff --git a/right/src/usb_interfaces/usb_interface_mouse.c b/right/src/usb_interfaces/usb_interface_mouse.c index e1cde79a4..5d041a800 100644 --- a/right/src/usb_interfaces/usb_interface_mouse.c +++ b/right/src/usb_interfaces/usb_interface_mouse.c @@ -79,6 +79,7 @@ usb_status_t UsbMouseCallback(class_handle_t handle, uint32_t event, void *param switch (event) { case ((uint32_t)-kUSB_DeviceEventSetConfiguration): + Macros_ReportPrintf(NULL, "USB Mouse: Set Configuration -> 0"); usbMouseFeatBuffer[0] = 0; error = kStatus_USB_Success; break; @@ -139,6 +140,8 @@ usb_status_t UsbMouseCallback(class_handle_t handle, uint32_t event, void *param // all; but it only sends this report when it detects the // resolution multiplier, and the intention is to activate the // feature, so turn high-res mode on here. + + Macros_ReportPrintf(NULL, "USB Mouse: Request Report Buffer -> 1"); report->reportBuffer = usbMouseFeatBuffer; usbMouseFeatBuffer[0] = 0x1; error = kStatus_USB_Success;