Curiousinventor wrote a nice technical guide to working with ps2 controllers –
Despite the large number of guides already out there that describe how to communicate with a play station controller (or guitar hero), most do not cover all the details, or do so sparsely. We consolidated and tested all the info we could find in our new ps2 interface guide, including wiring connections, low and high level communication protocol. Also, MPLAB c source code for a PIC18f4550 is provided that demonstrates how to read all analog buttons (joysticks and button pressures) and control the vibration motors (works with the guitar hero controller, too). Most of the research was done while developing our MIDIATOR kit.
Related: PS2 controller -> MIDI converter kit