mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-15 07:39:00 -04:00
Feat[mouse]: scale touchpad mouse speed by 1dp
This commit is contained in:
parent
e302a467a2
commit
0a1adca2d3
@ -9,6 +9,7 @@ import androidx.annotation.RequiresApi;
|
|||||||
|
|
||||||
import net.kdt.pojavlaunch.MainActivity;
|
import net.kdt.pojavlaunch.MainActivity;
|
||||||
import net.kdt.pojavlaunch.MinecraftGLSurface;
|
import net.kdt.pojavlaunch.MinecraftGLSurface;
|
||||||
|
import net.kdt.pojavlaunch.Tools;
|
||||||
|
|
||||||
import org.lwjgl.glfw.CallbackBridge;
|
import org.lwjgl.glfw.CallbackBridge;
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ public class AndroidPointerCapture implements ViewTreeObserver.OnWindowFocusChan
|
|||||||
private final AbstractTouchpad mTouchpad;
|
private final AbstractTouchpad mTouchpad;
|
||||||
private final View mHostView;
|
private final View mHostView;
|
||||||
private final float mScaleFactor;
|
private final float mScaleFactor;
|
||||||
|
private final float mPointerPrescale = Tools.dpToPx(1);
|
||||||
|
|
||||||
public AndroidPointerCapture(AbstractTouchpad touchpad, View hostView, float scaleFactor) {
|
public AndroidPointerCapture(AbstractTouchpad touchpad, View hostView, float scaleFactor) {
|
||||||
this.mScaleFactor = scaleFactor;
|
this.mScaleFactor = scaleFactor;
|
||||||
@ -47,7 +49,7 @@ public class AndroidPointerCapture implements ViewTreeObserver.OnWindowFocusChan
|
|||||||
public boolean onCapturedPointer(View view, MotionEvent event) {
|
public boolean onCapturedPointer(View view, MotionEvent event) {
|
||||||
if(!CallbackBridge.isGrabbing()) {
|
if(!CallbackBridge.isGrabbing()) {
|
||||||
enableTouchpadIfNecessary();
|
enableTouchpadIfNecessary();
|
||||||
mTouchpad.applyMotionVector(event.getX(), event.getY());
|
mTouchpad.applyMotionVector(event.getX() * mPointerPrescale, event.getY() * mPointerPrescale);
|
||||||
} else {
|
} else {
|
||||||
// Position is updated by many events, hence it is send regardless of the event value
|
// Position is updated by many events, hence it is send regardless of the event value
|
||||||
CallbackBridge.mouseX += (event.getX() * mScaleFactor);
|
CallbackBridge.mouseX += (event.getX() * mScaleFactor);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user