marcriera / ddgo-controller-docs

Collection of technical information regarding controllers for the Densha de GO! series.
https://marcriera.github.io/ddgo-controller-docs
16 stars 2 forks source link

Add descriptors for PS2 controllers #5

Open marcriera opened 2 years ago

marcriera commented 2 years ago

Currently, the documentation focuses on the data sent by/to the controllers, but technical details are missing.

sonik-br commented 1 year ago

Hi, First, thank you for all the work done do document all those controller types!

I'm trying to do an adapter for the Type2 PS2 controller. I can send data to the device and enable it's rumble and light, thanks for the "output" info presented on this page. But I can't read data from it. Any idea how it works?

marcriera commented 1 year ago

I'm glad that it's useful!

The PS2 controllers, like the USB controllers for PC and Nintendo Switch, are HID gamepads. However, they don't provide the HID descriptor nor the HID report descriptor during enumeration, which means that there's no way for the host to configure the controller automatically. In other words, they don't internally describe how many buttons and axes they have and how they work.

That doesn't mean you can't get the input data, but the device isn't assigned to the HID driver and you'll have to read and parse the raw USB data manually. For the Type 2, you'll have to read 6 bytes from the device's IN endpoint and you'll get what's described in the documentation.

I hope it helps!

sonik-br commented 1 year ago

Thanks. I was trying to read it using the control endpoint as it's used to send data to the device. I'm struggling with how to setup the transfer command for the input endpoint. This is all new to me. But thanks! I will keep looking for some sample code on how to setup the tinyusb lib to read an endpoint.

marcriera commented 1 year ago

Usually, the control endpoint (also called endpoint 0) is used for device enumeration and descriptors. Once the host knows about the device, data transfers are moved to dedicated endpoints. HID devices have a mandatory IN endpoint (device->host) and, optionally, an OUT endpoint (host->device). The PS2 controllers don't have the OUT endpoint and data from the host to the device (rumble and door lamp) are sent via control transfer.

Unfortunately I don't know about tinyusb, but there should be a way to poll the IN endpoint. You'll have to read data from there in a loop to get the bytes and the input.

sonik-br commented 1 year ago

Nice! Thanks for the explanation.

I think I'm in the right direction but I might have hit a bug on the library. Too many "layers"... Using a tinyusb that was ported to Arduino platform, then ported to the Pico board. Even the official hid sample code is not working to read from the IN endpoint. But I can read all the descriptors and send data via control transfer. I will keep on this journey :)

sonik-br commented 1 year ago

Got it working! I had to modify the tinyusb library and add an "class driver" to handle this device. Now I can output it as common HID. I might try to do native ps1 and saturn output in the future. Thanks again. Your documentation was essential to get it working. :)