Code depends on how much you want to do, and how much you want to steal borrow. Dual Strike (strike-devices.net) already exists, and is pretty decent. If you want to code the whole thing (my kind of attitude) then I recommend starting with Arduino. There are a lot of problems with the platform (hint: digitalRead(pin) is slow, use bitread(port,position)) but it’s super easy to learn. Give http://learn.adafruit.com/adafruit-arduino-lesson-1-blink/overview a look. This limits you to using Atmel AVR chips, but they’re pretty great so there ya go. For USB, you’ll probably want to use either an Arduino Leonardo/Atmega 32u4 or Teensy based board. Technically I just said the same thing three times there, but whatever. The teensy libraries are easy to use, and Leonardo is harder to make into a Joystick because the only decent library out there is lazily maintained. If you bypass Arduino for AVR-C then you’ll be using LUFA, which is still a box of magic to me so I can’t help you there yet. For an example, the Phreakmods Cerberus uses an Atmega32u4 and LUFA. The Cthulhu uses an Atmega XX8 series chip with (I THINK) V-USB.
So, to get general for a second, any USB HID Joystick will work on the PS3. I’ve got button mappings here: https://github.com/damurdock/PS2_USB/blob/master/Button%20Diagram.jpg (in that pic, start + sel = home). The problem comes along with the PS button. If you use Teensy, I’ve got a modified file that will work over at https://github.com/damurdock/Teensyduino-PS-Button-Mod . If you don’t use Teensy, you need to add
// Begin PS3 vendor page - Thanks UnoJoy!
0x75, 0x08, // Report Size (8)
0x06, 0x00, 0xff, // USAGE_PAGE (Vendor Specific)
0x09, 0x20, // Unknown
0x09, 0x21, // Unknown
0x09, 0x22, // Unknown
0x09, 0x23, // Unknown
0x09, 0x24, // Unknown
0x09, 0x25, // Unknown
0x09, 0x26, // Unknown
0x09, 0x27, // Unknown
0x09, 0x28, // Unknown
0x09, 0x29, // Unknown
0x09, 0x2a, // Unknown
0x09, 0x2b, // Unknown
0x95, 0x0c, // REPORT_COUNT (12)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x0a, 0x21, 0x26, // Unknown
0x95, 0x08, // REPORT_COUNT (8)
0xb1, 0x02, // FEATURE (Data,Var,Abs)*/
0xC0 // End Collection
to your report descriptor, then add something like
/*
* Series of bytes that appear in control packets right after the HID
* descriptor is sent to the host. They were discovered by tracing output
* from a Madcatz SF4 Joystick. Sending these bytes makes the PS button work.
*/
static const uint8_t PROGMEM magic_init_bytes[] = {
0x21, 0x26, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00
};
// End UnoJoy Code
where you declare variables. Then, at bmRequestType == 0xA1 and bRequest == HID_GET_REPORT send those magic bytes to the PS3. This will all make sense in due time. All of that was taken from my code and based off of UnoJoy, btw.I’m currently trying to figure out player leds, so if I find something I’ll let you know.
So, I hope that was helpful. If I didn’t explain something well or anything just let me know. Good luck!