Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: Update Xbox controller ids #10795

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
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.
*/
Expand Down Expand Up @@ -40,7 +42,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)
Expand All @@ -57,9 +60,28 @@ 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());
}
}