소스 검색

Fixed rumble after Xbox controller initialization
When we initialize the controller it has an internal rumble sequence number, and if our rumble sequence number doesn't match that, rumble won't happen. To fix that we cycle through the range of sequence numbers, and at some point we'll match up with the controller's sequence number and it'll roll forward until it matches our next rumble sequence number.

Sam Lantinga 5 년 전
부모
커밋
82d2c357c3
1개의 변경된 파일12개의 추가작업 그리고 2개의 파일을 삭제
  1. 12 2
      src/joystick/hidapi/SDL_hidapi_xboxone.c

+ 12 - 2
src/joystick/hidapi/SDL_hidapi_xboxone.c

@@ -192,7 +192,7 @@ SendControllerInit(hid_device *dev, SDL_DriverXboxOne_Context *ctx)
     Uint16 product_id = ctx->product_id;
 
     if (!IsBluetoothXboxOneController(vendor_id, product_id)) {
-        int i;
+        int i, j;
         Uint8 init_packet[USB_PACKET_LENGTH];
 
         for (i = 0; i < SDL_arraysize(xboxone_init_packets); ++i) {
@@ -212,6 +212,16 @@ SendControllerInit(hid_device *dev, SDL_DriverXboxOne_Context *ctx)
                 SDL_SetError("Couldn't write Xbox One initialization packet");
                 return SDL_FALSE;
             }
+
+            /* After the init we need to sync up the rumble sequence */
+            if (packet->data == xboxone_fw2015_init) {
+                for (j = 0; j < 255; ++j) {
+                    if (hid_write(dev, xboxone_rumbleend_init, sizeof(xboxone_rumbleend_init)) != sizeof(xboxone_rumbleend_init)) {
+                        SDL_SetError("Couldn't write Xbox One initialization packet");
+                        return SDL_FALSE;
+                    }
+                }
+            }
         }
     }
     return SDL_TRUE;
@@ -227,7 +237,7 @@ HIDAPI_DriverXboxOne_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint
         return SDL_FALSE;
     }
     if (vendor_id == 0x24c6 && product_id == 0x541a) {
-        /* The PowerA Mini controller blocks while writing feature reports */
+        /* The PowerA Mini controller, model 1240245-01, blocks while writing feature reports */
         return SDL_FALSE;
     }
 #endif