..:: PCSX2 Forums ::..

Full Version: XInput Wrapper for DS3 and Play.com USB Dual DS2 Controller
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
Regarding DualShock 3 Controllers compatibility with Vista / 7.

DS3 Controllers do send a correctly formed HID Descriptor and it is correctly recognised by the OS as a game-controller. You can view it in Devices and Printers, and it displays properly in Game Controllers.

[Image: attachment.php?aid=29681]
[Note the Dual PSX-USB Adaptor displays in Devices and Printers, but not in Game Controllers]

There is one issue with it though, it requires a Start command to be sent to wake it up before it will start issuing Reports. This is a well known issue, Linux has had a kernel quirk for it for a long time.

The Start command is a Set Feature Report with Report ID 0xF4, the problem is this Feature Report is not in the HID Descriptor. So it is not accessible from a user application. The HidUsb driver will refuse any Report ID that is not included in the HID Descriptor.

To get around this it is possible to write a Lower Filter driver which can issue the Set Feature Report. The following is code from a filter driver which modifies the Report ID and TransferBuffer contents, of a User application issued Set Feature Report with Report ID 0xEE (valid in HID Descriptor), to issue the Start Command.

Code:
/** Startup  Filter for DualShock 3 **/

    DebugPrint(("FilterPass %d - %d \n", irpStack->MajorFunction, irpStack->MinorFunction));

    if (irpStack->MajorFunction == IRP_MJ_INTERNAL_DEVICE_CONTROL)
    {
        DebugPrint(("IoControlCode %d\n", irpStack->Parameters.DeviceIoControl.IoControlCode));

        if(irpStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_INTERNAL_USB_SUBMIT_URB)
        {
            PURB pHxp = (PURB) irpStack->Parameters.Others.Argument1;

            DebugPrint(("Report [%d] - [%d]\n", (int) pHxp->UrbHeader.Length, (int) pHxp->UrbHeader.Function));

            if (pHxp->UrbHeader.Function == URB_FUNCTION_CLASS_INTERFACE)
            {
                UCHAR* Buffer = (UCHAR*) pHxp->UrbControlVendorClassRequest.TransferBuffer;

                DebugPrint(("Flags [0x%04X] Length [0x%04X]\n",
                    pHxp->UrbControlVendorClassRequest.TransferFlags,
                    pHxp->UrbControlVendorClassRequest.TransferBufferLength));

                DebugPrint(("Request [0x%02X] Value [0x%04X] Index [0x%04X]\n",
                    (int) pHxp->UrbControlVendorClassRequest.Request,
                    (int) pHxp->UrbControlVendorClassRequest.Value,
                    (int) pHxp->UrbControlVendorClassRequest.Index));

                if ((pHxp->UrbControlVendorClassRequest.Value == 0x3EE)
                &&  (USBD_TRANSFER_DIRECTION_FLAG(pHxp->UrbControlVendorClassRequest.TransferFlags) == USBD_TRANSFER_DIRECTION_OUT)
                &&  (Buffer[0] == (UCHAR) 0xEE))
                {
                    if(Buffer[1] == (UCHAR) 0x01)
                    {
                        pHxp->UrbControlVendorClassRequest.Value = 0x3F4;
                        pHxp->UrbControlVendorClassRequest.TransferBufferLength = 4;

                        Buffer[0] = 0x42;
                        Buffer[1] = 0x0C;
                        Buffer[2] = 0x00;
                        Buffer[3] = 0x00;
                    }
                }
            }
        }
    }

/** END - Startup Filter **/

This code would be inserted into the one of the DDK Samples (general\toaster\wdm\filter) in the FilterPass function, and built as a Kernel Mode Device Lower Filter. Code could be modified and used on the return of a Query Descriptor request if automatic start was required.

This in essence what the MotionInJoy drivers do for you, with a few extra features (setting the LEDs etc).

I've used this on XP, DS3 starts properly and is usable in games. Again for Vista / 7 the Driver must be signed, so as a general solution it's not recommended.
wow, thats awesome xD.

now if only someone as cluey as you was working with me and truthunknown to improve XBCD >Laugh

Though, it shouldn't be impossible to send the start command as a usermode driver. the device is already being spoken to properly.
I didn't mean to imply that this was the only way to write a filter to send the Start command, it was just the way I did it and was presenting it as a 'known working' solution.

I wrote it a few years ago when I came across the the Linux kernel quirk by chance. I knew it was doable on Windows since the MotioInJoy drivers worked, so I set about finding out how it could be done. My origional intention was to rewrite the HID Descriptor to expose the Report ID and pass it up on a Query Descriptor request, this was a proof of concept before attempting anything more involved.

I had a lot of work on at the time, and I was quite happy using my DualShock 2 controllers (code was much more hacky than the version posted here - but it worked well enough). So this got shelved and I never got back to it. I only looked at it again when I was rewriting the XInput wrapper to post here and thought it might be of some interest.

Glad that you found it interesting.

-- Added updated version, see first post for details.
Added a DualShock 3 Filter + XInput Wrapper, see first post.
Updated DualShock 3 Filter + XInput Wrapper, see first post.

If there is any interest in this I'll look in to BlueTooth support and getting it Signed for use in Vista / 7.

Also tested on SixAxis Controller, works as per DualShock 3, w/o Rumble support.

I've been testing the Rumble functionality in the Play.com adaptor, seems it has a few problems. Under heavy use of Rumble (testing with SSX Tricky), the adaptor can drop out which hangs the driver. Also the device does not support fully overlapped operation. Currently looking for a workaround, I may have to remove the Rumble support.
I would just like to personally thank you scarlet crush! The only thing on the internet to make that dammed play.com thing work on pcsx2 without crashing dreadfully. You sir saved me £5 on buying a cheap joypad Smile
Added version which includes support for both DS2 and DS3 pads - XInput-Wrapper-DS2-DS3-2.0.0.50.7z.

DS3 initialisation support added via libusb-win32-1.2.6.0 (installed as a filter driver)

Tested DS3 with PCSX2 0.98 (FFX-2, SSX Tricky), Batman AA, Batman AC on Windows 7 x64.
Posted new version.

- Signed Filter Driver
- Added Speedlink Strike FX
Oh my, this is great! And with source. Laugh

I've been thinking about DS2/3 native support (and also about using the big X in the X360 controller under Windows) so this seems like an excellent source of info.

Have you thought about making an API for DualShock controllers? Ye know, the ScarletInput API or something.

Now where did I put that DualShock2...

#EDIT/PS: How about googlecode?
Added modified Lilypad from r5350 source to support DS3 native mode using the Filter Driver in XInput-Wrapper-DS2-DS3-2.0.0.51.

[Basically just removed the Libusb dependancy.]

[attachment=39825][attachment=39826][attachment=39827][attachment=39828]
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510