@satishgn, as I’m attempting my first stabs at the USB HID Mouse feature I just came across a minor point.
In your declaration of MouseReport
and therefore in the related methods you declared x, y and wheel as uint8_t but should they not be int8_t since they can be positive or negative?
typedef struct
{
uint8_t buttons;
uint8_t x;
uint8_t y;
uint8_t wheel;
} MouseReport;
I know it doesn’t make any difference in functionalty, but just to avoid confusion, why the mouse moves in the wrong direction, when you pass a value greater than 127.
An even more puzzling behaviour I got, when I tried to go ahead with my cloud connected mouse project.
Since it didn’t behave as I expected, I whipped up this little test function and called it via Spark API Helper
int mouseTest(String command)
{
// move to 0/0
Mouse.move(-127,-127,0);
delay(REPEAT_DELAY);
Mouse.move(-127,-127,0);
delay(REPEAT_DELAY);
Mouse.move(-127,-127,0);
delay(REPEAT_DELAY);
Mouse.move(-127,-127,0);
delay(REPEAT_DELAY);
Mouse.move(-127,-127,0);
delay(REPEAT_DELAY);
// move to 545/305
Mouse.move(127,127,0);
delay(REPEAT_DELAY);
Mouse.move(127,127,0);
delay(REPEAT_DELAY);
Mouse.move(127,51,0);
delay(REPEAT_DELAY);
Mouse.move(127,0,0);
delay(REPEAT_DELAY);
Mouse.move(37,0,0);
delay(REPEAT_DELAY);
return 1;
}
For testing I set REPEAT_DELAY to 500ms, where I would normally have no more than 50ms. But when I watch the mouse movement I see that the Mouse.move(-127,-127,0) calls do move the mouse diagonally, but the calls with positive coordinates do not. I get the downward movement first and then the horizontal, but only the ones zero Y coordinates.
I got the problem on a Win 8.1 tablet - I’ve not yet been able to test in on my Win 8.x PCs (could have to do with the left edge system gesture or the Win 8.x HID drivers)
Under Win XP, Win 7 and Linux it works as expected.