Attempt at getting a Steam Controller to work as a gamepad on the PS3.
The reason this doesn't work out of the box is that the controller by default behaves like a keyboard and mouse ("Lizzard Mode" apparently).
Inspired by ps3xpad and the hid-steam Linux driver.
Reverse engineering notes
- PRX startup
- Start a PPU thread
- init_usb
- while running: wait on mutex for each connected controller, read_input check_pad_status unblock mutex
- on exit start stop_thread
- in stop_thread set running=false; join start_thread, stop thread, exit
- in start_thread detach all controllers, shutdown_usb, stop thread
EP0 control pipe
output pipe used by write_xpad not present on steam controller (endpoint 0x01 or 0x02)
used by:
- xpad(w)_set_led
- xpad(w)_set_rumble
called by xpad_attach
and get_endpoint_desc
(callbacks)
callback passed to CellUsbdLddOps
appears to be for wireless only part of usb descriptor callbacks
- init 2 mutexes
- init controller handles to -1
CellUsbdLddOps xpad_ops
set name to controller name (from xpad linux driver)cellUsbdRegisterExtraLdd
for each possible controller- same for wireless controllers
for each connected controller (pad):
read_input into xpad_data
read_input is a function pointer which differs for wired/wireless controllers.
xpad_read_input
for wired controllers:
block ring buffer mutex
# xpadbuf[0] == count
# xpadbuf[1] == size
memcpy ringbuf[2:] to p (new buffer)
cast p to XBOX360_IN_REPORT (HID report)
xpad_read_report
unblock ring buffer mutex
xpad_read_report
:
maps xbox360 controller HID report to virtual gamepad
CellPadData data;
# bunch of mapping logic. pretty self-explanatory
// send pad data to virtual pad
cellPadLddDataInsert
basically checks that PS3 virtual gamepads are alive sets LEDs appropriately