mirror of https://github.com/libsdl-org/SDL
Fixed the Xbox Series X controller showing up twice on Android
This commit is contained in:
parent
14f977348d
commit
cdd397118f
|
@ -353,9 +353,18 @@ public class HIDDeviceManager {
|
||||||
|
|
||||||
private void connectHIDDeviceUSB(UsbDevice usbDevice) {
|
private void connectHIDDeviceUSB(UsbDevice usbDevice) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
int interface_mask = 0;
|
||||||
for (int interface_index = 0; interface_index < usbDevice.getInterfaceCount(); interface_index++) {
|
for (int interface_index = 0; interface_index < usbDevice.getInterfaceCount(); interface_index++) {
|
||||||
UsbInterface usbInterface = usbDevice.getInterface(interface_index);
|
UsbInterface usbInterface = usbDevice.getInterface(interface_index);
|
||||||
if (isHIDDeviceInterface(usbDevice, usbInterface)) {
|
if (isHIDDeviceInterface(usbDevice, usbInterface)) {
|
||||||
|
// Check to see if we've already added this interface
|
||||||
|
// This happens with the Xbox Series X controller which has a duplicate interface 0, which is inactive
|
||||||
|
int interface_id = usbInterface.getId();
|
||||||
|
if ((interface_mask & (1 << interface_id)) != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
interface_mask |= (1 << interface_id);
|
||||||
|
|
||||||
HIDDeviceUSB device = new HIDDeviceUSB(this, usbDevice, interface_index);
|
HIDDeviceUSB device = new HIDDeviceUSB(this, usbDevice, interface_index);
|
||||||
int id = device.getId();
|
int id = device.getId();
|
||||||
mDevicesById.put(id, device);
|
mDevicesById.put(id, device);
|
||||||
|
|
Loading…
Reference in New Issue