Re: atmega8+V-USB to emulate PS3 joypad
Postby CRP » Wed Feb 09, 2011 7:46 pm
In the meantime I have looked a bit at the work done by Mephisto & co (Project Dualstrike). Basically with the patch that they have applied to the usb driver (what this patch actually does is beyond me), they apparently are able to send a 16 byte long hid descriptor in one go. I have tried taking their code and sending longer descriptors, but it won't work. So right now I have adapted the hid descriptor to my needs in order to have all the controls I need, and I barely made it
Basically, according to my limited understanding of the whole issue, in order to get the PS3 to recognize a controller as if it was an official one (which means working PS button and working analog buttons) the following must be satisfied:
1) the hid descriptor must include 13 buttons, one hat switch, 2 analog sticks (2 axes each), 12 analog buttons (these are via the weird custom items at the end of the hid report descriptor)
2) the report must be sent in a single try (ie it is impossible with stock v-usb, which allows max 8 bytes per interrupt; the trick of stacking them will not work, in the sense that by doing so the controller is recognized by the PS3, but the PS button and analog buttons will not work); here mephisto's patch comes into play, since it allows to send up to 16 bytes on interrupt endpoint 3 (can this be extended to more than 16 bytes? I have been unable to do so)
3) the usual magic bytes (0x21, 0x26,...) must be sent via the setup function
In my case, I was able to make a NegCon adapter with the following hid content:
1 byte for left stick axis (wheel)
3 x 2 bits for the remaining three axes (which are unused but must be present)
1 x 4 bits for the hat switch
13 x 1 bits for the digital buttons (button 13 is PS)
1 padding bit
12 x 8 bytes for the analog buttons (the last two are L2 and R2 trigger buttons, mapped to NegCon L and I-II)