Explorar o código

Manually enable acquiring the Apex 5 controller if necessary

The FlyDigi Space Station app isn't available on non-Windows platforms, so we need to manually enable acquiring the controller on those platforms.
Sam Lantinga hai 4 meses
pai
achega
28849fd789
Modificáronse 1 ficheiros con 14 adicións e 0 borrados
  1. 14 0
      src/joystick/hidapi/SDL_hidapi_flydigi.c

+ 14 - 0
src/joystick/hidapi/SDL_hidapi_flydigi.c

@@ -268,8 +268,22 @@ static bool HIDAPI_DriverFlydigi_InitControllerV2(SDL_HIDAPI_Device *device)
         return SDL_SetError("Couldn't get controller status");
     }
     if (data[10] != 1) {
+#ifdef SDL_PLATFORM_WINDOWS
         // Click "Allow third-party apps to take over mappings" in the FlyDigi Space Station app
         return SDL_SetError("Controller acquiring is disabled");
+#else
+        // The FlyDigi Space Station app isn't available, we need to enable this ourselves
+        Uint8 enable_acquire[32] = {
+            FLYDIGI_V2_CMD_REPORT_ID,
+            FLYDIGI_V2_MAGIC1,
+            FLYDIGI_V2_MAGIC2,
+            FLYDIGI_V2_SET_STATUS_COMMAND,
+            0x07, 0xff, 0xff, 0xff, 0xff, 0x01, 0x15
+        };
+        if (SDL_hid_write(device->dev, enable_acquire, sizeof(enable_acquire)) < 0) {
+            return SDL_SetError("Couldn't set controller status");
+        }
+#endif // SDL_PLATFORM_WINDOWS
     }
     return true;
 }