How i can calibrate Leonardo mouse.move()

Hello,
I using Mouse.h library and arduino leonardo.
For example I want to move 5 pixel to the right and I run mouse.move(5,0,0) . but it goes 7 pixels to the right. How i can calibrate this.

Thank you.

Since the speed at which the cursor moves can be set by the OS side with respect to the amount of movement sent from the mouse, I think it is difficult to set it on the code side.
For example, if you set the mouse to fastest in your computer's control panel, you'll probably move the cursor farther with the same Arduino code...

1 Like

The approach I took when I ran into the same problem years ago was to experimentally determine the required correction factor (e.g., 0.714) to apply to the movement numbers. I found that I was able to get reliable distances by making the mouse moves in a series of small movements (e.g., 10).

To determine the correction factor, I used a sketch that makes a fixed mouse movement and then running it in combination with a program that shows the mouse pointer coordinates.

1 Like

thanks for your reply. I'm using the same method right now, but I was looking for a definitive method because I was wondering if it would work properly for the people I will give the software to.

I suspect that a different calibration may be required depending on the settings of the computer it is used with. It's definitely not an ideal thing for everyone to have go through that calibration process. I shared my obscure code with one friend and they had some trouble with that step.

Is your end goal relative movement or reaching absolute coordinates?

My end goal is relative movement. For an example i say arduino go right 500px from your current position.

OK. My project needed absolute coordinates and I did see there were some less crude ways to achieve that, but that wouldn't be of use to you. Unfortunately I don't know of a better way to get exact relative movement.

1 Like

Ok. Thank you again for replys.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.