From c8e8b59e86ee7f86d9b39ceb7c1065a3422803a0 Mon Sep 17 00:00:00 2001 From: jbilander Date: Thu, 30 Nov 2023 10:48:51 +0100 Subject: [PATCH 1/2] Add scroll wheel status and middle mouse button click --- examples/peripherals/usb/host/hid/main/hid_host_example.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/peripherals/usb/host/hid/main/hid_host_example.c b/examples/peripherals/usb/host/hid/main/hid_host_example.c index ca8783f0b2..e5a91afacb 100644 --- a/examples/peripherals/usb/host/hid/main/hid_host_example.c +++ b/examples/peripherals/usb/host/hid/main/hid_host_example.c @@ -329,16 +329,19 @@ static void hid_host_mouse_report_callback(const uint8_t *const data, const int static int x_pos = 0; static int y_pos = 0; + static int wheel_pos = 0; // Calculate absolute position from displacement x_pos += mouse_report->x_displacement; y_pos += mouse_report->y_displacement; + wheel_pos += mouse_report->scrollwheel; hid_print_new_device_report_header(HID_PROTOCOL_MOUSE); - printf("X: %06d\tY: %06d\t|%c|%c|\r", - x_pos, y_pos, + printf("X: %06d\tY: %06d\tWheel: %06d\t|%c|%c|%c|\r", + x_pos, y_pos, wheel_pos, (mouse_report->buttons.button1 ? 'o' : ' '), + (mouse_report->buttons.button3 ? 'o' : ' '), (mouse_report->buttons.button2 ? 'o' : ' ')); fflush(stdout); } From f310ab6f6f18003f34b07691bac1c74bbb241428 Mon Sep 17 00:00:00 2001 From: Jorgen Bilander Date: Thu, 30 Nov 2023 11:03:20 +0100 Subject: [PATCH 2/2] Update README.md Updated Mouse with scroll wheel status and middle mouse button click status. --- examples/peripherals/usb/host/hid/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/peripherals/usb/host/hid/README.md b/examples/peripherals/usb/host/hid/README.md index 182ad685b9..b08362b4d9 100644 --- a/examples/peripherals/usb/host/hid/README.md +++ b/examples/peripherals/usb/host/hid/README.md @@ -63,10 +63,11 @@ Hello, ESP32 USB HID Keyboard is here! Mouse input data starts with the word "Mouse" and has the following structure. ``` Mouse -X: -00343 Y: 000183 | |o| - | | | | - | | | +- Right mouse button pressed status ("o" - pressed, " " - not pressed) - | | +--- Left mouse button pressed status ("o" - pressed, " " - not pressed) +X: -00343 Y: 000183 Wheel: 000004 | |o| | + | | | | | +- Right mouse button pressed status ("o" - pressed, " " - not pressed) + | | | | +- Middle mouse button pressed status ("o" - pressed, " " - not pressed) + | | | +--- Left mouse button pressed status ("o" - pressed, " " - not pressed) + | | +---------- Mouse wheel scroll status | +---------- Y relative coordinate of the cursor +----------------------- X relative coordinate of the cursor ```