mouse library and absolute mouse position

Hello,

This is a question regarding Arduino keystrokes and mouse movements. I’m writing a program in which when you make contact with a capacitive touch sensor, the mouse moves a specific distance across the screen. This is done using an Arduino Leonardo.

The problem I’m experiencing, however, is that the mouse move command can be pretty erratic in terms of the mouse’s position. I was wondering, is there a way to make the mouse position absolute, rather than relative to where it initially was in my program?

Here’s the code I have that deals with the sensor and mouse movements:

  if(total1 > 200 && var != 1) {
    Mouse.begin();
    Mouse.move(100, 0, 0);
    Mouse.end();
    var = 1;
  }

  if(total1 <= 200 && var == 1) {
    Mouse.begin();
    Mouse.move(-100, 0, 0);
    Mouse.end();
    var = 0;
  }

No. Standard mice don't work that way. The mouse input consists of a sequence of movement events and the PC decides where the mouse starts and then adjusts the position according to the movements. There is no way for a mouse to supply an absolute position.

PeterH:
No. Standard mice don't work that way. The mouse input consists of a sequence of movement events and the PC decides where the mouse starts and then adjusts the position according to the movements. There is no way for a mouse to supply an absolute position.

I was also hoping there was a way round that. Graphics tablets obviously give an absolute address but they use a different driver to the mouse hid driver. Has anyone managed to emulate a graphics tablet with the due or Leonardo yet?

So what happens if you move it off the screen? Does it have a boundary? Could you move it WAYYYY up into the upper left corner, and then move relative to that?

TanHadron:
So what happens if you move it off the screen? Does it have a boundary? Could you move it WAYYYY up into the upper left corner, and then move relative to that?

moving it to the bottom left might be the way to reset it. I am working on some other bits first but I'll be getting to that before long..... I need to work out doing the opposite first though ie read a USB mouse and USB keyboard. I can read a serial mouse and PS2 keyboard which would be ok but they are all bluetooth or USB nowadays.

I tried moving it very far left and it seemed to wrap.

Perhaps if you could tell where the mouse actually was and zero that out with negative movement (actually 1 it out according to one reference I found)