I am writing Android remote app. When I touch and move on Android app, the cursor on server machine moves too but it delays for about a second.
My app simply are two threads: client sends coordinates, server receives them and that's all. My solution is just to pass dx, dy through ObjectInputStream and use Robot::mouseMove to move the cursor.
Can you give me some advices to prevent the cursor from delaying? (smoothly like RemoteDroid ^^)
My Sever:
public void run() {
..........
while(true) {
// get dx, dy from ObjectInputStream
........
moveMouseByDelta(dx, dy);
}
...........
}
private void moveMouseByDelta(int dx, int dy)
{
try {
Point p = MouseInfo.getPointerInfo().getLocation();
int currentX = p.x;
int currentY = p.y;
Robot robot = new Robot();
robot.mouseMove(currentX + dx, currentY + dy);
} catch (AWTException e) {
e.printStackTrace();
}
}
My Client (Android remote app):
private void touchTouchPad(MotionEvent event)
{
int x = (int)event.getX();
int y = (int)event.getY();
switch(event.getAction()) {
............
case MotionEvent.ACTION_MOVE:
if(leftMouseHold) {
if(clientThread != null) {
int dx = x - xMouse;
int dy = y - yMouse;
xMouse += dx;
yMouse += dy;
clientThread.sendDelta(dx, dy);
}
}
break;
..............
}
}
(This is not my homework, it is my study)
Edit: add more information
I speak only about Windows OS, this is nothing unusual, because RDP is limited to BW at 56-64Kb/per sec,
1 / freezing, slowdown and delay is caused by translation between resolution (in pixels between f.e. handy 480x320 and fullHD PC monitor) of both devices, if is the difference (in pixels) is greater, then the movement is more unnatural,
2 / freezing and delay is caused by fluctuations in the data connection
worst is when they are at the moment the two factors together, then it's decent fun
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With