I am currently modifying the XBOXController class from the projects section to create a PS3controller class. I have been using the guide here for the PS3 controller on the arduino host shield which has been really helpful.
http://www.circuitsathome.com/mcu/programming/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-2
I have written all the code to decode the messages received from the controller.
public enum Button
{
// byte location | bit location
// these need to be confirmed
SELECT = (3 << 8) | 0x01,
L3 = (3 << 8) | 0x02,
R3 = (3 << 8) | 0x04,
START = (3 << 8) | 0x08,
UP = (3 << 8) | 0x10,
RIGHT = (3 << 8) | 0x20,
DOWN = (3 << 8) | 0x40,
LEFT = (3 << 8) | 0x80,
L2 = (4 << 8) | 0x01,
R2 = (4 << 8) | 0x02,
L1 = (4 << 8) | 0x04,
R1 = (4 << 8) | 0x08,
TRIANGLE = (4 << 8) | 0x10,
CIRCLE = (4 << 8) | 0x20,
CROSS = (4 << 8) | 0x40,
SQUARE = (4 << 8) | 0x80,
PS = (5 <> 8] & ((byte)b & 0xff)) > 0)
return true;
}
return false;
}
public byte GetAnalogButton(AnalogButton a)
{
if (PS3_joystickData == null)
return 0;
lock (PS3_joystickData)
{
return (byte)(PS3_joystickData[(uint)a]);
}
}
public byte GetAnalogHat(AnalogHat a)
{
if (PS3_joystickData == null)
return 0;
lock (PS3_joystickData)
{
return (byte)(PS3_joystickData[(uint)a]);
}
}
public short GetSensor(Sensor a)
{
if (PS3_joystickData == null)
return 0;
lock (PS3_joystickData)
{
return (short)((PS3_joystickData[(uint)a+1] << 8) | PS3_joystickData[(uint)a]);
}
}
but i am now currently stuck and am searching for some help with the connection of the device (sounds like the most important part, yep its fairly crucial).
from reading the guide i highlighted earlier it seems i need to connect to 2 additional endpoints.
also with this i need to send the configuration as described in the guide here
[quote]Between the setting of the configuration and the receipt of data on the input pipe , there are two commands sent to the PS3 game controller. The first sets the game controller to send 01 type reports to the input pipe whenever any changes occur on the controller.
SetupPacket:
0000: 21 09 f4 03 00 00 04 00
bmRequestType: 21
DIR: Host-To-Device
TYPE: Class
RECIPIENT: Interface
bRequest: 09
TransferBuffer: 0×00000004 (4) length
0000: 42 0c 00 00[/quote]
i guess this could be achieved using the sendsetuptransfer as below but when i try i always has a choke.
// set configuration
byte[] buf = new byte[] {0x42, 0x0c, 0x00, 0x00};
PS3_Joystick.SendSetupTransfer(0x21, 0x09, 0x01, 0x00, buf, 0x00, 0x04);
i know its a fair bit to take in at once but if anyone has some pointer for me that would be great.
cheers jc