mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 03:23:07 +00:00
Make the cursor on the target track more true to the client input by scaling based on screen resolution
This commit is contained in:
parent
0d42beca93
commit
f744c7d9c4
@ -14,9 +14,11 @@ import android.annotation.SuppressLint;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Point;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.Display;
|
||||||
import android.view.InputDevice;
|
import android.view.InputDevice;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
@ -45,6 +47,10 @@ public class Game extends Activity implements OnGenericMotionListener, OnTouchLi
|
|||||||
private int lastTouchY = 0;
|
private int lastTouchY = 0;
|
||||||
private boolean hasMoved = false;
|
private boolean hasMoved = false;
|
||||||
|
|
||||||
|
private int height;
|
||||||
|
private int width;
|
||||||
|
private Point screenSize = new Point(0, 0);
|
||||||
|
|
||||||
private NvConnection conn;
|
private NvConnection conn;
|
||||||
private SpinnerDialog spinner;
|
private SpinnerDialog spinner;
|
||||||
private boolean displayedFailureDialog = false;
|
private boolean displayedFailureDialog = false;
|
||||||
@ -109,11 +115,14 @@ public class Game extends Activity implements OnGenericMotionListener, OnTouchLi
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int width, height, refreshRate;
|
int refreshRate;
|
||||||
width = prefs.getInt(WIDTH_PREF_STRING, DEFAULT_WIDTH);
|
width = prefs.getInt(WIDTH_PREF_STRING, DEFAULT_WIDTH);
|
||||||
height = prefs.getInt(HEIGHT_PREF_STRING, DEFAULT_HEIGHT);
|
height = prefs.getInt(HEIGHT_PREF_STRING, DEFAULT_HEIGHT);
|
||||||
refreshRate = prefs.getInt(REFRESH_RATE_PREF_STRING, DEFAULT_REFRESH_RATE);
|
refreshRate = prefs.getInt(REFRESH_RATE_PREF_STRING, DEFAULT_REFRESH_RATE);
|
||||||
sh.setFixedSize(width, height);
|
sh.setFixedSize(width, height);
|
||||||
|
|
||||||
|
Display display = getWindowManager().getDefaultDisplay();
|
||||||
|
display.getSize(screenSize);
|
||||||
|
|
||||||
// Warn the user if they're on a metered connection
|
// Warn the user if they're on a metered connection
|
||||||
checkDataConnection();
|
checkDataConnection();
|
||||||
@ -509,8 +518,15 @@ public class Game extends Activity implements OnGenericMotionListener, OnTouchLi
|
|||||||
lastMouseY != Integer.MIN_VALUE &&
|
lastMouseY != Integer.MIN_VALUE &&
|
||||||
!(lastMouseX == eventX && lastMouseY == eventY))
|
!(lastMouseX == eventX && lastMouseY == eventY))
|
||||||
{
|
{
|
||||||
conn.sendMouseMove((short)(eventX - lastMouseX),
|
int deltaX = eventX - lastMouseX;
|
||||||
(short)(eventY - lastMouseY));
|
int deltaY = eventY - lastMouseY;
|
||||||
|
|
||||||
|
// Scale the deltas if the device resolution is different
|
||||||
|
// than the stream resolution
|
||||||
|
deltaX = (int)Math.round((double)deltaX * ((double)width / (double)screenSize.x));
|
||||||
|
deltaY = (int)Math.round((double)deltaY * ((double)height / (double)screenSize.y));
|
||||||
|
|
||||||
|
conn.sendMouseMove((short)deltaX, (short)deltaY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update pointer location for delta calculation next time
|
// Update pointer location for delta calculation next time
|
||||||
|
Loading…
x
Reference in New Issue
Block a user