Permalink
Browse files

Android: Make ControllerMappingHelper methods static

This class has no state.
  • Loading branch information...
JosJuice committed Jul 11, 2018
1 parent 78cb1c2 commit 7f6be99ad93e090417d508575ce0827284bde7a9
@@ -23,7 +23,6 @@
{
// The selected input preference
private final InputBindingSetting setting;
private final ControllerMappingHelper mControllerMappingHelper;
private final ArrayList<Float> mPreviousValues = new ArrayList<>();
private int mPrevDeviceId = 0;
private boolean mWaitingForEvent = true;
@@ -39,7 +38,6 @@ public MotionAlertDialog(Context context, InputBindingSetting setting)
super(context);
this.setting = setting;
this.mControllerMappingHelper = new ControllerMappingHelper();
}
public boolean onKeyEvent(int keyCode, KeyEvent event)
@@ -48,7 +46,7 @@ public boolean onKeyEvent(int keyCode, KeyEvent event)
switch (event.getAction())
{
case KeyEvent.ACTION_DOWN:
if (!mControllerMappingHelper.shouldKeyBeIgnored(event.getDevice(), keyCode))
if (!ControllerMappingHelper.shouldKeyBeIgnored(event.getDevice(), keyCode))
{
saveKeyInput(event);
}
@@ -103,7 +101,7 @@ private boolean onMotionEvent(MotionEvent event)
InputDevice.MotionRange range = motionRanges.get(i);
int axis = range.getAxis();
float origValue = event.getAxisValue(axis);
float value = mControllerMappingHelper.scaleAxis(input, axis, origValue);
float value = ControllerMappingHelper.scaleAxis(input, axis, origValue);
if (firstEvent)
{
mPreviousValues.add(value);
@@ -8,7 +8,7 @@
public class ControllerMappingHelper
{
/** 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)) {
// The two analog triggers generate analog motion events as well as a keycode.
@@ -20,7 +20,7 @@ public boolean shouldKeyBeIgnored(InputDevice inputDevice, int keyCode)
}
/** 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))
{
@@ -43,13 +43,13 @@ else if (isXboxOneWireless(inputDevice))
return value;
}
private boolean isDualShock4(InputDevice inputDevice)
private static boolean isDualShock4(InputDevice inputDevice)
{
// Sony DualShock 4 controller
return inputDevice.getVendorId() == 0x54c && inputDevice.getProductId() == 0x9cc;
}
private boolean isXboxOneWireless(InputDevice inputDevice)
private static boolean isXboxOneWireless(InputDevice inputDevice)
{
// Microsoft Xbox One controller
return inputDevice.getVendorId() == 0x45e && inputDevice.getProductId() == 0x2e0;

0 comments on commit 7f6be99

Please sign in to comment.