place the client driver goes to between report requests.
The connection state of the DualShock 3 is also checked
here. If the DualShock 3’s USB motor stops running, the
state machine is reset to the DEVICE_NOT_CONNECTED
state.
This state is exited under control of the Timer4
interrupt handler:
case READY_TO_TX_RX_REPORT:
if(!USBHostHIDDeviceDetect(1))
{
PS3State = DEVICE_NOT_CONNECTED;
}
break;
The button report generated by the DualShock 3 is
49 bytes long. We use the USB stack’s USBHostHIDRead
function to stuff the incoming 49-byte report data packet
into the ps3ReportBuf. The USBHostHIDRead parameters
are defined in this way in their order of appearance:
BYTE deviceAddress
- Device address = 0x01
BYTE reportid
- Report ID of the requested report = 0x01
BYTE interface
- Interface number = 0x00
BYTE size
- Byte size of the data buffer = 0x31
BYTE *data
- Pointer to the data buffer = ps3ReportBuf
Once the 49 bytes are deposited into the
ps3ReportBuf buffer, we send them out along the
115200 bps UART pipe to a terminal emulator. The
reports stream very quickly, and you can see changes in
the streaming data made by button presses, accelerometer
readings, and joystick movement. You can see what I
mean by examining Screenshot 9:
BYTE ps3ReportBuf[64];
case GET_INPUT_REPORT:
error = USBHostHIDRead(0x01,0x01,
0x00,0x31,ps3ReportBuf);
for(i=0;i<0x32;++i)
{
printf(“%0X”,ps3ReportBuf[i]);
}
printf(“\r\n”);
PS3State = READY_TO_TX_RX_REPORT;
break;
default:
break;
}
}while(1);
HOUSTON, WE HAVE CLEARED
THE TOWER
We are on our way. Next time, we’ll go wireless with
our DualShock 3. NV
■ SCREENSHOT 9.
Most of the
PlayStation
DualShock 3's
buttons are pressure
sensitive, as well as
digitally sensitive.
You can see where I
started to depress
the button and the
changes it made in
the DualShock 3
report data packets.
60
June 2013