mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-16 16:16:04 -04:00
Revert "light optimisation of motion events on Gamepad.java"
This reverts commit 5c010ef076a34ff304b6b47317f53a027b96d431. Conflicts: app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/gamepad/Gamepad.java
This commit is contained in:
parent
ef05b9c955
commit
284d0f207d
@ -7,7 +7,6 @@ import android.view.MotionEvent;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.core.math.MathUtils;
|
import androidx.core.math.MathUtils;
|
||||||
|
|
||||||
@ -55,7 +54,6 @@ public class Gamepad {
|
|||||||
private GamepadMap currentMap = gameMap;
|
private GamepadMap currentMap = gameMap;
|
||||||
|
|
||||||
private boolean lastGrabbingState = true;
|
private boolean lastGrabbingState = true;
|
||||||
private MotionEvent lastMotionEvent = null;
|
|
||||||
|
|
||||||
|
|
||||||
private final Thread mouseThread;
|
private final Thread mouseThread;
|
||||||
@ -63,8 +61,6 @@ public class Gamepad {
|
|||||||
private final Runnable switchStateRunnable;
|
private final Runnable switchStateRunnable;
|
||||||
|
|
||||||
public Gamepad(BaseMainActivity gameActivity, InputDevice inputDevice){
|
public Gamepad(BaseMainActivity gameActivity, InputDevice inputDevice){
|
||||||
Toast.makeText(gameActivity.getApplicationContext(),"GAMEPAD CREATED", Toast.LENGTH_LONG).show();
|
|
||||||
|
|
||||||
leftJoystick = new GamepadJoystick(MotionEvent.AXIS_X, MotionEvent.AXIS_Y, inputDevice);
|
leftJoystick = new GamepadJoystick(MotionEvent.AXIS_X, MotionEvent.AXIS_Y, inputDevice);
|
||||||
rightJoystick = new GamepadJoystick(MotionEvent.AXIS_Z, MotionEvent.AXIS_RZ, inputDevice);
|
rightJoystick = new GamepadJoystick(MotionEvent.AXIS_Z, MotionEvent.AXIS_RZ, inputDevice);
|
||||||
|
|
||||||
@ -107,12 +103,6 @@ public class Gamepad {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void tick(){
|
private void tick(){
|
||||||
if(lastMotionEvent != null){
|
|
||||||
updateDirectionalJoystick(lastMotionEvent);
|
|
||||||
updateMouseJoystick(lastMotionEvent);
|
|
||||||
updateAnalogTriggers(lastMotionEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(lastHorizontalValue != 0 || lastVerticalValue != 0){
|
if(lastHorizontalValue != 0 || lastVerticalValue != 0){
|
||||||
GamepadJoystick currentJoystick = CallbackBridge.isGrabbing() ? leftJoystick : rightJoystick;
|
GamepadJoystick currentJoystick = CallbackBridge.isGrabbing() ? leftJoystick : rightJoystick;
|
||||||
|
|
||||||
@ -244,9 +234,10 @@ public class Gamepad {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void update(MotionEvent event){
|
public void update(MotionEvent event){
|
||||||
lastMotionEvent = event;
|
gamepadDpad.update(event);
|
||||||
if(gamepadDpad.update(event) != -1) return;
|
updateDirectionalJoystick(event);
|
||||||
//The rest of events are now sent each 1/60 second.
|
updateMouseJoystick(event);
|
||||||
|
updateAnalogTriggers(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMouseJoystick(MotionEvent event){
|
private void updateMouseJoystick(MotionEvent event){
|
||||||
@ -410,12 +401,12 @@ public class Gamepad {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT:
|
case LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT:
|
||||||
//CallbackBridge.putMouseEventWithCoords(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, isDown?1:0, CallbackBridge.mouseX, CallbackBridge.mouseY);
|
CallbackBridge.putMouseEventWithCoords(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, isDown?1:0, CallbackBridge.mouseX, CallbackBridge.mouseY);
|
||||||
MainActivity.sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, isDown);
|
//MainActivity.sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, isDown);
|
||||||
break;
|
break;
|
||||||
case LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT:
|
case LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT:
|
||||||
//CallbackBridge.putMouseEventWithCoords(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT, isDown?1:0, CallbackBridge.mouseX, CallbackBridge.mouseY);
|
CallbackBridge.putMouseEventWithCoords(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT, isDown?1:0, CallbackBridge.mouseX, CallbackBridge.mouseY);
|
||||||
MainActivity.sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT, isDown);
|
//MainActivity.sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT, isDown);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user