pranavjp / premotedroid

Automatically exported from code.google.com/p/premotedroid
0 stars 0 forks source link

Mouse moves off edge of screen #78

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Connect your phone to your Mac.
2. Try moving the mouse off the top (or bottom or sides) of the screen
3. Observe that the mouse disappears, and to get it back you need to move the 
same amount in the opposite direction.

What is the expected output? What do you see instead?
I want the mouse to stop when it hits the edge of the screen. Instead, it moves 
into areas I can't see.

What version of the product are you using? On what operating system?
I've got version 1.0 of the PremoteDroidServer app. I'm not sure what version 
of the Android app I have, but it's whatever was available in early December. I 
have a Mac Mini running OS X Snow Leopard, and a Nexus One running FroYo. I'm 
using bluetooth to link one to the other.

Please provide any additional information below.
This is a great program. Thanks for creating it!

Original issue reported on code.google.com by alan.dav...@gmail.com on 4 Dec 2010 at 10:31

GoogleCodeExporter commented 8 years ago
I got it to work; here are the necessary changes for anyone else who is 
interested:

At the top of PRemoteDroidServerConnection.java, you need to import two new 
things:

import java.awt.Dimension;
import java.awt.Toolkit;

Then, in that same file, in the moveMouse function, add this in after x and y 
are defined but before having the robot use them:

if (x < 0)
{
    x = 0;
}
if (y < 0)
{
    y = 0;
}
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension dim = toolkit.getScreenSize();
if (x >= dim.width)
{
    x = dim.width - 1;
}
if (y >= dim.height)
{
    y = dim.height - 1;
}

and that's it! The mouse now stays on the screen no matter what.

Original comment by alan.dav...@gmail.com on 6 Dec 2010 at 6:32