Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3882

General • TinyUSB Host question

$
0
0
Hi Guys,

I now have TinyUSB integrated in to my project and it's working great. I am able to detect mouse clicks and relative movement.

The problem I am facing is, when mouse movement stops, TinyUSB doesn't seem to report back the x and y should now be zero. It only seems to report back it's last values.

Clicking the mouse buttons, updates the report and X & Y reset back to zero if there is no movement. But under normal operation the main program loop is of the impression that the mouse is still moving when its not.

Code:

Mouse process_mouse_report(hid_mouse_report_t const * report){      static hid_mouse_report_t prev_report = { 0 };      report->buttons ^ prev_report.buttons;      mouse.left = report->buttons & MOUSE_BUTTON_LEFT ? 1 : 0;      mouse.middle = report->buttons & MOUSE_BUTTON_MIDDLE ? 1 : 0;      mouse.right = report->buttons & MOUSE_BUTTON_RIGHT ? 1 : 0;      mouse.x = report->x;      mouse.y = report->y;      mouse.z = report->wheel;      return mouse;}
Above is my code, which is only slightly modified from the Pico examples folder.

Is there a manual way to poll the mouse state as opposed to have TinyUSB 'react' to movement? Or am I just going about reading the non-movement state of the mouse the wrong way?

I thought of the option of making movement equal zero, if the last value equals the current value, but that is prone to issues, where the mouse might be moving at a precise rate and would return a false positive.

Any advice would be greatly appreciated.

Statistics: Posted by Lonewolff — Wed Sep 04, 2024 2:31 am



Viewing all articles
Browse latest Browse all 3882

Trending Articles