User(s) browsing this thread: 33 Guest(s)

Post Reply 
 
Thread Rating:
  • 44 Vote(s) - 4.8 Average
  • 1
  • 2
  • 3
  • 4
  • 5
XInput Wrapper for DS3 and Play.com USB Dual DS2 Controller
Author Message
Scarlet.Crush Offline
Senior Member
***

Posts: 574
Joined: Jun 2011
Location:
Reputation: 89
Post: #11
RE: XInput Wrapper for Play.com USB Dual DS2 Controller
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.


Attached File(s) Thumbnail(s)
   
08-26-2011 05:15 PM
Find all posts by this user Quote this message in a reply

Sponsored links

Squall Leonhart Offline
Jarrett Killer.
****

Posts: 3.555
Joined: Jul 2010
Location: Australia
Reputation: 62
Post: #12
RE: XInput Wrapper for Play.com USB Dual DS2 Controller
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.

(This post was last modified: 08-27-2011 01:43 AM by Squall Leonhart.)
08-27-2011 01:41 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Scarlet.Crush Offline
Senior Member
***

Posts: 574
Joined: Jun 2011
Location:
Reputation: 89
Post: #13
RE: XInput Wrapper for Play.com USB Dual DS2 Controller
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.
(This post was last modified: 08-27-2011 11:06 PM by Scarlet.Crush.)
08-27-2011 12:18 PM
Find all posts by this user Quote this message in a reply
Scarlet.Crush Offline
Senior Member
***

Posts: 574
Joined: Jun 2011
Location:
Reputation: 89
Post: #14
RE: XInput Wrapper for Play.com USB Dual DS2 Controller
Added a DualShock 3 Filter + XInput Wrapper, see first post.
08-31-2011 07:25 PM
Find all posts by this user Quote this message in a reply
Scarlet.Crush Offline
Senior Member
***

Posts: 574
Joined: Jun 2011
Location:
Reputation: 89
Post: #15
RE: XInput Wrapper for Play.com USB Dual DS2 Controller
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.
09-05-2011 09:52 PM
Find all posts by this user Quote this message in a reply
surfr Offline
Newbie

Posts: 1
Joined: Mar 2012
Location:
Reputation: 0
Post: #16
RE: XInput Wrapper for Play.com USB Dual DS2 Controller
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
03-30-2012 02:53 PM
Find all posts by this user Quote this message in a reply
Scarlet.Crush Offline
Senior Member
***

Posts: 574
Joined: Jun 2011
Location:
Reputation: 89
Post: #17
RE: XInput Wrapper for Play.com USB Dual DS2 Controller
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.
07-29-2012 09:44 PM
Find all posts by this user Quote this message in a reply
Scarlet.Crush Offline
Senior Member
***

Posts: 574
Joined: Jun 2011
Location:
Reputation: 89
Post: #18
RE: XInput Wrapper for DS3 and Play.com USB Dual DS2 Controller
Posted new version.

- Signed Filter Driver
- Added Speedlink Strike FX
08-21-2012 12:58 AM
Find all posts by this user Quote this message in a reply
KrossX Offline
クロスエックス
*****

Posts: 879
Joined: Jan 2012
Location: Argentina
Reputation: 45
Post: #19
RE: XInput Wrapper for DS3 and Play.com USB Dual DS2 Controller
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?

[Image: nbKSK.jpg]
(This post was last modified: 08-21-2012 02:45 AM by KrossX.)
08-21-2012 02:44 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Scarlet.Crush Offline
Senior Member
***

Posts: 574
Joined: Jun 2011
Location:
Reputation: 89
Post: #20
RE: XInput Wrapper for DS3 and Play.com USB Dual DS2 Controller
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.]

               
08-21-2012 09:46 PM
Find all posts by this user Quote this message in a reply
Post Reply 





Current time: 12-19-2014, 05:08 PM