From 03f8528315fa46c95991a34f3325d7b33ae5538c Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Sat, 02 May 2020 21:48:36 +0000
Subject: [PATCH] Update source to SDL2 2.0.12
---
source/android-project/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java | 35 ++++++++++++++++-------------------
1 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/source/android-project/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java b/source/android-project/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java
index c9fc58e..33816e3 100644
--- a/source/android-project/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java
+++ b/source/android-project/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java
@@ -11,6 +11,7 @@
protected HIDDeviceManager mManager;
protected UsbDevice mDevice;
+ protected int mInterfaceIndex;
protected int mInterface;
protected int mDeviceId;
protected UsbDeviceConnection mConnection;
@@ -20,16 +21,17 @@
protected boolean mRunning;
protected boolean mFrozen;
- public HIDDeviceUSB(HIDDeviceManager manager, UsbDevice usbDevice, int interface_number) {
+ public HIDDeviceUSB(HIDDeviceManager manager, UsbDevice usbDevice, int interface_index) {
mManager = manager;
mDevice = usbDevice;
- mInterface = interface_number;
+ mInterfaceIndex = interface_index;
+ mInterface = mDevice.getInterface(mInterfaceIndex).getId();
mDeviceId = manager.getDeviceIDForIdentifier(getIdentifier());
mRunning = false;
}
public String getIdentifier() {
- return String.format("%s/%x/%x", mDevice.getDeviceName(), mDevice.getVendorId(), mDevice.getProductId());
+ return String.format("%s/%x/%x/%d", mDevice.getDeviceName(), mDevice.getVendorId(), mDevice.getProductId(), mInterfaceIndex);
}
@Override
@@ -88,6 +90,7 @@
return result;
}
+ @Override
public UsbDevice getDevice() {
return mDevice;
}
@@ -104,19 +107,15 @@
return false;
}
- // Force claim all interfaces
- for (int i = 0; i < mDevice.getInterfaceCount(); i++) {
- UsbInterface iface = mDevice.getInterface(i);
-
- if (!mConnection.claimInterface(iface, true)) {
- Log.w(TAG, "Failed to claim interfaces on USB device " + getDeviceName());
- close();
- return false;
- }
+ // Force claim our interface
+ UsbInterface iface = mDevice.getInterface(mInterfaceIndex);
+ if (!mConnection.claimInterface(iface, true)) {
+ Log.w(TAG, "Failed to claim interfaces on USB device " + getDeviceName());
+ close();
+ return false;
}
// Find the endpoints
- UsbInterface iface = mDevice.getInterface(mInterface);
for (int j = 0; j < iface.getEndpointCount(); j++) {
UsbEndpoint endpt = iface.getEndpoint(j);
switch (endpt.getDirection()) {
@@ -166,7 +165,7 @@
UsbConstants.USB_TYPE_CLASS | 0x01 /*RECIPIENT_INTERFACE*/ | UsbConstants.USB_DIR_OUT,
0x09/*HID set_report*/,
(3/*HID feature*/ << 8) | report_number,
- 0,
+ mInterface,
report, offset, length,
1000/*timeout millis*/);
@@ -210,7 +209,7 @@
UsbConstants.USB_TYPE_CLASS | 0x01 /*RECIPIENT_INTERFACE*/ | UsbConstants.USB_DIR_IN,
0x01/*HID get_report*/,
(3/*HID feature*/ << 8) | report_number,
- 0,
+ mInterface,
report, offset, length,
1000/*timeout millis*/);
@@ -250,10 +249,8 @@
mInputThread = null;
}
if (mConnection != null) {
- for (int i = 0; i < mDevice.getInterfaceCount(); i++) {
- UsbInterface iface = mDevice.getInterface(i);
- mConnection.releaseInterface(iface);
- }
+ UsbInterface iface = mDevice.getInterface(mInterfaceIndex);
+ mConnection.releaseInterface(iface);
mConnection.close();
mConnection = null;
}
--
Gitblit v1.9.3