2

I understand that Mouse.move move the mouse from its current position, example:

Mouse.move(100, 100);

Will move the mouse to 100 pixels right and 100 pixels down.

But in reality it will move to somehting like 150 pixels right and/or 150 pixels down..

I already tested without cursor precision/acceleration and it doesn't change a thing.

What unit does the function use ?

I know about the 127 -127 limit, and i respect it, but still... when i ask to move 100,100 it doesn't move 100,100.

0

1 Answer 1

2

The mouse coordinates are not pixels. They are a proportion of the physical minimum/maximum parameters of the report descriptor. Since those aren't specified in the report descriptor they are taken to be the same as the logical: -127 to 127.

So moving 100 "units" is moving 100/(127-(-127)) of 100%, which is about 40%.

But 40% of what?

Well, 40% of an inch. Or what your OS believes that an inch is on your current screen.

In the HID specification:

While Logical Minimum and Logical Maximum (extents) bound the values returned by a device, Physical Minimum and Physical Maximum give meaning to those bounds by allowing the report value to be offset and scaled. For example, a thermometer might have logical extents of 0 and 999 but physical extents of 32 and 212 degrees.The resolution can be determined with the following algorithm:

if ((Physical Maximum == UNDEFINED) || (Physical Minimum == UNDEFINED) || ((Physical Maximum == 0) && (Physical Minimum == 0))) {
    Physical Maximum = Logical Maximum;
    Physical Minimum = Logical Minimum;
}

If (Unit Exponent == UNDEFINED)
    Unit Exponent = 0;

Resolution = (Logical Maximum – Logical Minimum) / ((Physical Maximum – Physical Minimum) * (10^Unit Exponent)) 

1
  • it makes sense, thanks!
    – Owow
    Commented Apr 9, 2020 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.