From dd480149e7c77d6a472b17695f3268bb0d7585ed Mon Sep 17 00:00:00 2001 From: Anthony R Date: Wed, 29 Jun 2022 21:05:35 -0400 Subject: [PATCH 1/2] Android: Xbox controller ids added --- .../utils/ControllerMappingHelper.java | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/ControllerMappingHelper.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/ControllerMappingHelper.java index 9e31a46a96e8..d77eedb31dc4 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/ControllerMappingHelper.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/ControllerMappingHelper.java @@ -5,6 +5,7 @@ import android.view.InputDevice; import android.view.KeyEvent; import android.view.MotionEvent; +import java.util.Arrays; /** * Some controllers have incorrect mappings. This class has special-case fixes for them. @@ -40,7 +41,8 @@ public static float scaleAxis(InputDevice inputDevice, int axis, float value) return (value + 1) / 2.0f; } } - else if (isXboxOneWireless(inputDevice)) + // 0x0b20 is Firmware > 5.1 where the scaling is correct. + else if (isXboxOneWireless(inputDevice) && inputDevice.getProductId() != 0x0b20) { // Same as the DualShock 4, the mappings are missing. if (axis == MotionEvent.AXIS_Z || axis == MotionEvent.AXIS_RZ) @@ -57,9 +59,27 @@ private static boolean isDualShock4(InputDevice inputDevice) return inputDevice.getVendorId() == 0x54c && inputDevice.getProductId() == 0x9cc; } + private static final int[] XboxProductIDs = { + // Xbox One (Rev. 1) + 0x2d1, + // Xbox One (Rev. 2) + 0x2dd, + // Xbox One (Rev. 3) + 0x2e0, + // Xbox One Elite (Wired) + 0x2e3, + // Xbox One S Controller + 0x2ea, + // Xbox One S Controller (Bluetooth) + 0x2fd, + // Xbox One Wireless Controller (model 1914) + 0x0b12, + // Xbox One Wireless Controller (Firmware > 5.1) + 0x0b20 + }; + private static boolean isXboxOneWireless(InputDevice inputDevice) { - // Microsoft Xbox One controller - return inputDevice.getVendorId() == 0x45e && inputDevice.getProductId() == 0x2e0; + return inputDevice.getVendorId() == 0x45e && Arrays.asList(XboxProductIDs).contains(inputDevice.getProductId()); } } From 3e547acf7c7c72885ff4c1af7767b0296a01f653 Mon Sep 17 00:00:00 2001 From: Anthony R Date: Thu, 30 Jun 2022 18:26:27 -0400 Subject: [PATCH 2/2] Fixed incorrect lint --- .../utils/ControllerMappingHelper.java | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/ControllerMappingHelper.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/ControllerMappingHelper.java index d77eedb31dc4..64cf8245cf96 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/ControllerMappingHelper.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/ControllerMappingHelper.java @@ -5,6 +5,7 @@ import android.view.InputDevice; import android.view.KeyEvent; import android.view.MotionEvent; + import java.util.Arrays; /** @@ -60,26 +61,27 @@ private static boolean isDualShock4(InputDevice inputDevice) } private static final int[] XboxProductIDs = { - // Xbox One (Rev. 1) - 0x2d1, - // Xbox One (Rev. 2) - 0x2dd, - // Xbox One (Rev. 3) - 0x2e0, - // Xbox One Elite (Wired) - 0x2e3, - // Xbox One S Controller - 0x2ea, - // Xbox One S Controller (Bluetooth) - 0x2fd, - // Xbox One Wireless Controller (model 1914) - 0x0b12, - // Xbox One Wireless Controller (Firmware > 5.1) - 0x0b20 + // Xbox One (Rev. 1) + 0x2d1, + // Xbox One (Rev. 2) + 0x2dd, + // Xbox One (Rev. 3) + 0x2e0, + // Xbox One Elite (Wired) + 0x2e3, + // Xbox One S Controller + 0x2ea, + // Xbox One S Controller (Bluetooth) + 0x2fd, + // Xbox One Wireless Controller (model 1914) + 0x0b12, + // Xbox One Wireless Controller (Firmware > 5.1) + 0x0b20 }; private static boolean isXboxOneWireless(InputDevice inputDevice) { - return inputDevice.getVendorId() == 0x45e && Arrays.asList(XboxProductIDs).contains(inputDevice.getProductId()); + return inputDevice.getVendorId() == 0x45e && + Arrays.asList(XboxProductIDs).contains(inputDevice.getProductId()); } }