android: fix touchscreen coords when view is scaled

Samsung phones/tablets can scale down the emulator view to improve
performance. In this case, getPointerCoords() returns screen, not view
coordinates. Use MotionEvent.getX/Y() instead.
This commit is contained in:
Flyinghead 2024-08-16 13:12:27 +02:00
parent 6679cb2f31
commit 8ea12443d3
1 changed files with 5 additions and 9 deletions

View File

@ -342,10 +342,8 @@ public class VirtualJoystickDelegate {
}
else
{
MotionEvent.PointerCoords pointerCoords = new MotionEvent.PointerCoords();
event.getPointerCoords(0, pointerCoords);
mouse_pos[0] = Math.round(pointerCoords.x);
mouse_pos[1] = Math.round(pointerCoords.y);
mouse_pos[0] = Math.round(event.getX());
mouse_pos[1] = Math.round(event.getY());
mouse_btns = MotionEvent.BUTTON_PRIMARY; // Mouse left button down
}
break;
@ -353,10 +351,8 @@ public class VirtualJoystickDelegate {
case MotionEvent.ACTION_MOVE:
if (event.getPointerCount() == 1)
{
MotionEvent.PointerCoords pointerCoords = new MotionEvent.PointerCoords();
event.getPointerCoords(0, pointerCoords);
mouse_pos[0] = Math.round(pointerCoords.x);
mouse_pos[1] = Math.round(pointerCoords.y);
mouse_pos[0] = Math.round(event.getX());
mouse_pos[1] = Math.round(event.getY());
}
break;
}