Re: ConfigFS, FunctionFS, and MS XInput

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 4/19/2018 7:16 PM, Daniel Hefti wrote:
On 4/17/2018 8:56 AM, Krzysztof Opasiak wrote:


On 04/17/2018 04:03 AM, Daniel Hefti wrote:
Hey guys,

I've been banging my head against the wall for a couple of days trying to get a Raspberry Pi 0W to talk to Windows (8.1/10) as an XInput game controller using ConfigFS and FunctionFS, having little success.  I've tried to build both a generic XInput device and one that attempts to emulate an X360 controller.  The X360 controller seems to get "further", in that Windows says it recognizes the device and the drivers are working.  Whatever that means.  The generic version just shows up as an unrecognized device (with the name I've given it). Neither are getting or able to send any data from/to their respective endpoints.  The X360 version, I tested locally via loopback/dummy UDC, and the xboxdrv driver can detect and read controller state messages/reports I send it, so at least that much works.  Not sure what I could possibly be missing.

I can say I've successfully created HID USB game controller devices. Those are accessible from Windows, but, unfortunately, many Windows games don't support HID particularly well, and I'm trying to avoid someone having to use something like XOutput as a workaround to get this device to work.

I do have Wireshark with USBPCap installed, so I can at least capture some of the data, which I did, but  it wasn't really leading me anywhere, possibly due to my lack of knowledge in this particular subject.  Unfortunately, I didn't save my pcap results.  I'll likely end up doing it again once I've given my head some time to heal.

Any insights?  References?  Something you think could help guide me in the right direction?  There's plenty of documentation and example implementations out there for HID devices, but not so much for XInput devices and functionfs in general, so any help would be greatly appreciated!

Did you check that you provided all drivers that a physical device does?
Maybe windows requires correct OS descriptors for that device?
That's just some guesses...

> Thanks for your feedback!  I think I'm beginning to better understand
> what's going on. When I originally got the X360-emulated device working
> on the loopback interface, I left out several class descriptors and an
> interface with no endpoints (but has a vendor-specific descriptor
> following it).  Reason being, whenever I attempted to add those
> descriptors (either by pushing the bytes manually or creating a
> descriptor-like struct and pushing that (effectively the same thing)) to
> endpoint 0, I would get: OSError 22: Invalid Argument.
>
> Here's the 4 class & vendor descriptors in question:
>
> 1: [17,33,0,1,1,37,129,20,0,0,0,0,19,2,8,0,0,]
> 2: [27,33,0,1,1,1,131,64,1,4,32,22,133,0,0,0,0,0,0,22,5,0,0,0,0,0,0,]
> 3: [9,33,0,1,1,34,134,7,0,]
> 4: [6,65,0,1,1,3]
>
> They're all after an interface descriptor and before their endpoint
> descriptors.
>
> So, that's my current roadblock.  I don't know how to send those.  Can
> you/someone help describe to me how (or where I can find out how) I can
> do so?  (Sending class/vendor descriptors and interfaces with no
> endpoints.)  Is that something I can do with FunctionFS?
>
> Meantime, I'm going to be looking over the generic XInput device
> again, but I may end up running into the same problem there.
>

I've investigated further into the generic XInput device a little more. It also has a class-specific descriptor:

10 21 10 01 24 81 14 03 00 03 13 02 00 03 00

(My apologies from jumping from ints to hex between posts.)

I stumbled across the xusb example in the libusb source code. Compiled it, then got my first look at some os descriptors! The generic device does indeed have some:

Reading Extended Compat ID OS Feature Descriptor (wIndex = 0x0004):

  00000000  28 00 00 00 00 01 04 00 01 00 00 00 00 00 00 00
  00000010  00 01 58 55 53 42 31 30 00 00 00 00 00 00 00 00
  00000020  00 00 00 00 00 00 00 00

Reading Extended Properties OS Feature Descriptor (wIndex = 0x0005):

  00000000  28 00 00 00 00 01 04 00 01 00 00 00 00 00 00 00
  00000010  00 01 58 55 53 42 31 30 00 00 00 00 00 00 00 00
  00000020  00 00 00 00 00 00 00 00

They seem to be referencing an XUSB10 feature. The x360 device does not appear to have these descriptors, or xusb doesn't see/report them, at least. If I could get those working, that'd be great! The problem I'm running into now is that, although I can send a Compat descriptor to functionfs, and it accepts it, when xusb attempts to read it, it returns with a response: Failed: Pipe error. It seems like Windows 10 behaves similarly. Not sure what's causing that. In GadgetFS, I'm using the following os descriptor settings:

os_desc/use: 1
os_desc/b_vendor_code: 0x90 (same as generic device)
os_desc/qw_sign: MSFT100

Any ideas?  (Also, sorry for top-posting previously.  :)  )

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux