This commit is contained in:
Jorgen Bilander 2024-09-25 18:55:47 +02:00 committed by GitHub
commit 02fe8b6850
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -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 input data starts with the word "Mouse" and has the following structure.
``` ```
Mouse Mouse
X: -00343 Y: 000183 | |o| X: -00343 Y: 000183 Wheel: 000004 | |o| |
| | | | | | | | | +- Right mouse button pressed status ("o" - pressed, " " - not pressed)
| | | +- 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) | | | +--- Left mouse button pressed status ("o" - pressed, " " - not pressed)
| | +---------- Mouse wheel scroll status
| +---------- Y relative coordinate of the cursor | +---------- Y relative coordinate of the cursor
+----------------------- X relative coordinate of the cursor +----------------------- X relative coordinate of the cursor
``` ```

View File

@ -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 x_pos = 0;
static int y_pos = 0; static int y_pos = 0;
static int wheel_pos = 0;
// Calculate absolute position from displacement // Calculate absolute position from displacement
x_pos += mouse_report->x_displacement; x_pos += mouse_report->x_displacement;
y_pos += mouse_report->y_displacement; y_pos += mouse_report->y_displacement;
wheel_pos += mouse_report->scrollwheel;
hid_print_new_device_report_header(HID_PROTOCOL_MOUSE); hid_print_new_device_report_header(HID_PROTOCOL_MOUSE);
printf("X: %06d\tY: %06d\t|%c|%c|\r", printf("X: %06d\tY: %06d\tWheel: %06d\t|%c|%c|%c|\r",
x_pos, y_pos, x_pos, y_pos, wheel_pos,
(mouse_report->buttons.button1 ? 'o' : ' '), (mouse_report->buttons.button1 ? 'o' : ' '),
(mouse_report->buttons.button3 ? 'o' : ' '),
(mouse_report->buttons.button2 ? 'o' : ' ')); (mouse_report->buttons.button2 ? 'o' : ' '));
fflush(stdout); fflush(stdout);
} }