mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2026-04-24 03:27:12 -04:00
more accurate gamepad deadzone detection
This commit is contained in:
committed by
SerpentSpirale
parent
e77499778f
commit
ee00a737d4
@@ -592,7 +592,7 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
|
||||
if(Gamepad.isGamepadEvent(ev)){
|
||||
if(gamepad == null){
|
||||
gamepad = new Gamepad(this, Tools.grabFirstGamepad());
|
||||
gamepad = new Gamepad(this, ev.getDevice());
|
||||
}
|
||||
|
||||
gamepad.update(ev);
|
||||
@@ -644,7 +644,7 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
|
||||
if(Gamepad.isGamepadEvent(event)){
|
||||
if(gamepad == null){
|
||||
gamepad = new Gamepad(this, Tools.grabFirstGamepad());
|
||||
gamepad = new Gamepad(this, event.getDevice());
|
||||
}
|
||||
|
||||
gamepad.update(event);
|
||||
|
||||
@@ -872,22 +872,5 @@ public final class Tools {
|
||||
Tools.updateWindowSize(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
public static InputDevice grabFirstGamepad() {
|
||||
|
||||
int[] deviceIds = InputDevice.getDeviceIds();
|
||||
for (int deviceId : deviceIds) {
|
||||
InputDevice dev = InputDevice.getDevice(deviceId);
|
||||
int sources = dev.getSources();
|
||||
|
||||
// Verify that the device has gamepad buttons, control sticks, or both.
|
||||
if (((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
|
||||
|| ((sources & InputDevice.SOURCE_JOYSTICK)
|
||||
== InputDevice.SOURCE_JOYSTICK)) {
|
||||
// This device is a game controller. Store its device ID.
|
||||
return dev;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user