mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Android: Make ControllerMappingHelper methods static
This class has no state.
This commit is contained in:
@ -23,7 +23,6 @@ public final class MotionAlertDialog extends AlertDialog
|
|||||||
{
|
{
|
||||||
// The selected input preference
|
// The selected input preference
|
||||||
private final InputBindingSetting setting;
|
private final InputBindingSetting setting;
|
||||||
private final ControllerMappingHelper mControllerMappingHelper;
|
|
||||||
private final ArrayList<Float> mPreviousValues = new ArrayList<>();
|
private final ArrayList<Float> mPreviousValues = new ArrayList<>();
|
||||||
private int mPrevDeviceId = 0;
|
private int mPrevDeviceId = 0;
|
||||||
private boolean mWaitingForEvent = true;
|
private boolean mWaitingForEvent = true;
|
||||||
@ -39,7 +38,6 @@ public final class MotionAlertDialog extends AlertDialog
|
|||||||
super(context);
|
super(context);
|
||||||
|
|
||||||
this.setting = setting;
|
this.setting = setting;
|
||||||
this.mControllerMappingHelper = new ControllerMappingHelper();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onKeyEvent(int keyCode, KeyEvent event)
|
public boolean onKeyEvent(int keyCode, KeyEvent event)
|
||||||
@ -48,7 +46,7 @@ public final class MotionAlertDialog extends AlertDialog
|
|||||||
switch (event.getAction())
|
switch (event.getAction())
|
||||||
{
|
{
|
||||||
case KeyEvent.ACTION_DOWN:
|
case KeyEvent.ACTION_DOWN:
|
||||||
if (!mControllerMappingHelper.shouldKeyBeIgnored(event.getDevice(), keyCode))
|
if (!ControllerMappingHelper.shouldKeyBeIgnored(event.getDevice(), keyCode))
|
||||||
{
|
{
|
||||||
saveKeyInput(event);
|
saveKeyInput(event);
|
||||||
}
|
}
|
||||||
@ -103,7 +101,7 @@ public final class MotionAlertDialog extends AlertDialog
|
|||||||
InputDevice.MotionRange range = motionRanges.get(i);
|
InputDevice.MotionRange range = motionRanges.get(i);
|
||||||
int axis = range.getAxis();
|
int axis = range.getAxis();
|
||||||
float origValue = event.getAxisValue(axis);
|
float origValue = event.getAxisValue(axis);
|
||||||
float value = mControllerMappingHelper.scaleAxis(input, axis, origValue);
|
float value = ControllerMappingHelper.scaleAxis(input, axis, origValue);
|
||||||
if (firstEvent)
|
if (firstEvent)
|
||||||
{
|
{
|
||||||
mPreviousValues.add(value);
|
mPreviousValues.add(value);
|
||||||
|
@ -8,7 +8,7 @@ import android.view.MotionEvent;
|
|||||||
public class ControllerMappingHelper
|
public class ControllerMappingHelper
|
||||||
{
|
{
|
||||||
/** Some controllers report extra button presses that can be ignored. */
|
/** Some controllers report extra button presses that can be ignored. */
|
||||||
public boolean shouldKeyBeIgnored(InputDevice inputDevice, int keyCode)
|
public static boolean shouldKeyBeIgnored(InputDevice inputDevice, int keyCode)
|
||||||
{
|
{
|
||||||
if (isDualShock4(inputDevice)) {
|
if (isDualShock4(inputDevice)) {
|
||||||
// The two analog triggers generate analog motion events as well as a keycode.
|
// The two analog triggers generate analog motion events as well as a keycode.
|
||||||
@ -20,7 +20,7 @@ public class ControllerMappingHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Scale an axis to be zero-centered with a proper range. */
|
/** Scale an axis to be zero-centered with a proper range. */
|
||||||
public float scaleAxis(InputDevice inputDevice, int axis, float value)
|
public static float scaleAxis(InputDevice inputDevice, int axis, float value)
|
||||||
{
|
{
|
||||||
if (isDualShock4(inputDevice))
|
if (isDualShock4(inputDevice))
|
||||||
{
|
{
|
||||||
@ -43,13 +43,13 @@ public class ControllerMappingHelper
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDualShock4(InputDevice inputDevice)
|
private static boolean isDualShock4(InputDevice inputDevice)
|
||||||
{
|
{
|
||||||
// Sony DualShock 4 controller
|
// Sony DualShock 4 controller
|
||||||
return inputDevice.getVendorId() == 0x54c && inputDevice.getProductId() == 0x9cc;
|
return inputDevice.getVendorId() == 0x54c && inputDevice.getProductId() == 0x9cc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isXboxOneWireless(InputDevice inputDevice)
|
private static boolean isXboxOneWireless(InputDevice inputDevice)
|
||||||
{
|
{
|
||||||
// Microsoft Xbox One controller
|
// Microsoft Xbox One controller
|
||||||
return inputDevice.getVendorId() == 0x45e && inputDevice.getProductId() == 0x2e0;
|
return inputDevice.getVendorId() == 0x45e && inputDevice.getProductId() == 0x2e0;
|
||||||
|
Reference in New Issue
Block a user