Skip to content

Commit c8e8b59

Browse files
committed
Add scroll wheel status and middle mouse button click
1 parent ab03c2e commit c8e8b59

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/peripherals/usb/host/hid/main/hid_host_example.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -329,16 +329,19 @@ static void hid_host_mouse_report_callback(const uint8_t *const data, const int
329329

330330
static int x_pos = 0;
331331
static int y_pos = 0;
332+
static int wheel_pos = 0;
332333

333334
// Calculate absolute position from displacement
334335
x_pos += mouse_report->x_displacement;
335336
y_pos += mouse_report->y_displacement;
337+
wheel_pos += mouse_report->scrollwheel;
336338

337339
hid_print_new_device_report_header(HID_PROTOCOL_MOUSE);
338340

339-
printf("X: %06d\tY: %06d\t|%c|%c|\r",
340-
x_pos, y_pos,
341+
printf("X: %06d\tY: %06d\tWheel: %06d\t|%c|%c|%c|\r",
342+
x_pos, y_pos, wheel_pos,
341343
(mouse_report->buttons.button1 ? 'o' : ' '),
344+
(mouse_report->buttons.button3 ? 'o' : ' '),
342345
(mouse_report->buttons.button2 ? 'o' : ' '));
343346
fflush(stdout);
344347
}

0 commit comments

Comments
 (0)