-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Mouse.move positioning #1417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
FYI: My temporary workaround has a major flaw. It's 2.6x for the 100 distance mouse movement but it varies for other distances. I just tried a 10 distance and the factor was 1.3x. This extremely limits the usefulness of the workaround unless a formula can be worked out for mathematically determining the factor based on the distance. I'll wait for a better solution but if none is forthcoming I'll work on the formula. |
Mouseacceleration and mouse speed is your problem. It is a formula used
|
Thanks Iestofante I realized it was my problem, I just thought that I might've been unaware of some existing solution in the Arduino itself or in someone else's coding or that someone might know some way to have acceleration turned off for the Arduino mouse while leaving it on for the physical one. For your first suggestion I've already found the acceleration isn't linear (which would be a velocity) but changes exponentially with the distance moved (along the lines of y=mx*q where q varies from about 1 to 3 with distances in the 1 to 255 range of the Arduino) and is strangely unreliable. I've written a quick code snippet that I'll insert in my program to try your second suggestion but don't have the time for inserting or testing it right now. I'll report back with the results when I do try it. |
The Arduino Mouse emulation uses relative positioning. In theory you could change it to use absolute positioning by adding a new HID descriptor (+some code) in HID.cpp so the mouse emulation would work like a touchscreen. Would this help you? |
Hi nospam2000. Actually, Absolute positioning is what I was trying to do except that the Arduino Mouse emulation only had relative positioning available. My workaround was to Move the mouse to the Desktop 0,0 position then use the Arduino Mouse to move it "relatively" to the absolute position I needed. That's when I ran into the acceleration issues. What you suggest would, therefore, be the perfect solution! I'm not overly familiar with modifying cpp files properly so I searched for others who might've modified it. I found some but it appears they couldn't get the mouse to go further than about 100 pixels from the top-left corner of the screen. Can you direct me to a successful HID.cpp modification that allows absolute positioning anywhere on the screen (in my case 1920 x 1080)? |
… as requested in issue arduino#1417. all parameters have the range of -32768 to 32767 and must be scaled to screen pixels some examples: x=0, y=0 is the middle of the screen x=-32768, y=-32768 is the top left corner x=32767, y=-32768 is the top right corner x=32767, y=32767 is the bottom right corner x=-32768, y=32767 is the bottom left corner
In the patch from my previous posting you can see the changes which need to be done for an absolute mouse. It basically works, but some work has to be done for transforming the logical mouse coordinates (-32768 to 32767) to screen pixel coordinates (0..1920x0..1080). |
It worked perfectly. Much Appreciated Michael. I thought the following observations were worth passing along:
|
The "dead borders" I mentioned are an issue of the default Mac OSX mouse driver. There is always a border of 15% of the screen width and height around the visible area. More information can be found here:
The multi-monitor scenario you mentioned is a problem of the default Windows mouse driver. To position the mouse to any other than the first monitor, the flag MOUSE_VIRTUAL_DESKTOP must be set in the mouse driver. To do this, you need a filter driver. See the following links for more information:
You can see neither Mac OSX nor Windows are perfect :-) |
hello , i'm new to this site , and especially to arduino . can anyone help me ? |
i tried the 1.01 IDE and it works fine ... thanks for the code , i really appreciated. |
it's really strange , i've done some test sketches and the function worked well , i don't know what happened , what it could be... the basic Mouse.move function is still working well , moveAbs it's not working ....with 1.01 which before worked well...maybe could be a windows 8 problem !??!?!? :( i'm using the 1.01 ide with 1.05 usb drivers |
here's the test code , void setup() { void loop() { |
This is a bigtracer, not a place to request help. Use the forum Arduino.cc
|
Closing with #1803 |
Hi, I'm working on a Robot project with Arduino and I'm using a mouse as a positioning system to get x and y, the Arduino reads dx and dy not x and y so I add these values in a new variable after each reading. The problem is when the robot moves faster dy or dx become larger, I mean the relative value is obviously depending on the speed of movement. Is there any way to read dx and dy without speed effect? |
I know the reason for the problem I'm having with multiple move Mouse.move positioning being imprecise is due to Mouse Acceleration and/or Precise Pointer in Windows but my question is whether anyone has found a way to deal with this issue and get precise positioning. I don't consider this an Arduino hardware/software fault although it's possible a workaround could be added to it or even, unknown to me, already exist.
Example (test code section c/w commented actual results)
// 60 40 mouse initial position by movement of physical mouse
Mouse.move(100,100,0); // 160 140 for first movement which is correct
delay(10000);
Mouse.move(100,100,0) ; // 420 401 for second movement which is 260 & 261 (over 2 1/2 times)
Subsequent repeats of the command (w delay) continue to get over 2 1/2 times the desired movement. I've tried inserting other mouse commands including a Mouse.move(-1,-1,0) but none stop the acceleration.
I'm aware that I can adjust Mouse Acceleration & Precise Pointer to reduce the issue but then my regular mouse usage is less convenient.
My thought is that since the Leonardo mouse is a separate device from my regular mouse is that there might be a way, that someone is aware of, to remove Mouse Acceleration from it while leaving it in place for the hardware mouse. Possibly a Registry setting (that applies to Leo not hardware mouse) or some Arduino code that can be inserted before Mouse.move commands to trick Windows into thinking each move is the first (accurate one).
For Arduino hardware/software workarounds, an ability to set the speed that the mouse moves within each Mouse.move should reduce the problem significantly since the current near instant move from position to position is likely a major factor.
My temporary (reasonably successful) workaround is to assume a 2.6x acceleration on all but the first call and adjust the Mouse.move parameters to suit. Note to others who try this that the 2.6 value is for my PC & Windows settings and will probably be a different, though still consistant, value on yours.
Thanks in advance for any insights!
The text was updated successfully, but these errors were encountered: