Просмотр исходного кода

Correctly support OG Steam Controller when connected via USB on Android (#15561)

Rachel Blackman 16 часов назад
Родитель
Сommit
e4a327709d

+ 9 - 2
android-project/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java

@@ -132,8 +132,10 @@ class HIDDeviceUSB implements HIDDevice {
             }
         }
 
-        // Make sure the required endpoints were present
-        if (mInputEndpoint == null || mOutputEndpoint == null) {
+        // Make sure the required endpoints were present. The original Steam Controller and the wireless dongle for it do NOT
+        // actually have -- or require -- output endpoints, so we need to accept only an input one for them or else we'll fall
+        // back to the Android system gamepad functionality (and lose our paddles et al).
+        if (mInputEndpoint == null) {
             Log.w(TAG, "Missing required endpoint on USB device " + getDeviceName());
             close();
             return false;
@@ -185,6 +187,11 @@ class HIDDeviceUSB implements HIDDevice {
             }
             return length;
         } else {
+            if (mOutputEndpoint == null)
+            {
+                Log.e(TAG, "Tried to write an output report to an interface with no output endpoint!");
+                return -1;
+            }
             int res = mConnection.bulkTransfer(mOutputEndpoint, report, report.length, 1000);
             if (res != report.length) {
                 Log.w(TAG, "writeOutputReport() returned " + res + " on device " + getDeviceName());