Merge pull request #20 from TKJElectronics/master

The largest change is that the syntax for the move controller is now the same as the other controllers
This commit is contained in:
Oleg Mazurov 2012-05-28 13:46:02 -07:00
commit dc9da41fa5
6 changed files with 123 additions and 111 deletions

View file

@ -441,10 +441,17 @@ bool PS3BT::getButton(Button b)
{ {
if (l2capinbuf == NULL) if (l2capinbuf == NULL)
return false; return false;
if ((l2capinbuf[(uint16_t)b >> 8] & ((uint8_t)b & 0xff)) > 0) if(PS3MoveConnected) {
return true; if((l2capinbuf[((uint16_t)b >> 8)-1] & ((uint8_t)b & 0xff))) // All the buttons locations are shifted one back on the Move controller
else return true;
return false; else
return false;
} else {
if((l2capinbuf[(uint16_t)b >> 8] & ((uint8_t)b & 0xff)))
return true;
else
return false;
}
} }
uint8_t PS3BT::getAnalogButton(AnalogButton a) uint8_t PS3BT::getAnalogButton(AnalogButton a)
{ {
@ -464,25 +471,25 @@ int32_t PS3BT::getSensor(Sensor a)
return 0; return 0;
if (a == aX || a == aY || a == aZ || a == gZ) if (a == aX || a == aY || a == aZ || a == gZ)
return ((l2capinbuf[(uint16_t)a] << 8) | l2capinbuf[(uint16_t)a + 1]); return ((l2capinbuf[(uint16_t)a] << 8) | l2capinbuf[(uint16_t)a + 1]);
else if (a == mXmove || a == mYmove || a == mZmove) else if (a == mXmove || a == mYmove || a == mZmove) // These are all 12-bits long
{ {
// Might not be correct, haven't tested it yet // Might not be correct, haven't tested it yet
if (a == mXmove) /*if (a == mXmove)
return ((l2capinbuf[(uint16_t)a + 1] << 0x04) | (l2capinbuf[(uint16_t)a] << 0x0C)); return ((l2capinbuf[(uint16_t)a + 1] << 0x04) | (l2capinbuf[(uint16_t)a] << 0x0C));
//return (((unsigned char)l2capinbuf[(unsigned int)a + 1]) | (((unsigned char)l2capinbuf[(unsigned int)a] & 0x0F)) << 8);
else if (a == mYmove) else if (a == mYmove)
return ((l2capinbuf[(uint16_t)a + 1] & 0xF0) | (l2capinbuf[(uint16_t)a] << 0x08)); return ((l2capinbuf[(uint16_t)a + 1] & 0xF0) | (l2capinbuf[(uint16_t)a] << 0x08));
//return (((unsigned char)l2capinbuf[(unsigned int)a + 1]) | (((unsigned char)l2capinbuf[(unsigned int)a] & 0x0F)) << 8);
else if (a == mZmove) else if (a == mZmove)
return ((l2capinbuf[(uint16_t)a + 1] << 0x0F) | (l2capinbuf[(uint16_t)a] << 0x0C)); return ((l2capinbuf[(uint16_t)a + 1] << 0x0F) | (l2capinbuf[(uint16_t)a] << 0x0C));
//return ((((unsigned char)l2capinbuf[(unsigned int)a + 1] & 0xF0) >> 4) | ((unsigned char)l2capinbuf[(unsigned int)a] << 4)); */
else if (a == mXmove || a == mYmove)
return 0; return (((l2capinbuf[(uint16_t)a] & 0x0F) << 8) | (l2capinbuf[(uint16_t)a + 1]));
else // mZmove
return ((l2capinbuf[(uint16_t)a] << 4) | (l2capinbuf[(uint16_t)a + 1] >> 4));
} }
else if (a == tempMove) else if (a == tempMove) // The tempearature is 12 bits long too
return (((l2capinbuf[(uint16_t)a + 1] & 0xF0) >> 4) | (l2capinbuf[(uint16_t)a] << 4)); return ((l2capinbuf[(uint16_t)a] << 4) | ((l2capinbuf[(uint16_t)a + 1] & 0xF0) >> 4));
else // aXmove, aYmove, aZmove, gXmove, gYmove and gZmove else // aXmove, aYmove, aZmove, gXmove, gYmove and gZmove
return ((l2capinbuf[(uint16_t)a + 1] << 8) | l2capinbuf[(uint16_t)a]); return (l2capinbuf[(uint16_t)a] | (l2capinbuf[(uint16_t)a + 1] << 8));
} }
double PS3BT::getAngle(Angle a) { double PS3BT::getAngle(Angle a) {
double accXval; double accXval;
@ -946,14 +953,14 @@ void PS3BT::ACL_event_task()
Notify(PSTR(" Identifier: ")); Notify(PSTR(" Identifier: "));
PrintHex<uint8_t>(l2capinbuf[9]); PrintHex<uint8_t>(l2capinbuf[9]);
*/ */
if ((l2capinbuf[13] | l2capinbuf[12]) == L2CAP_PSM_HID_CTRL) if ((l2capinbuf[12] | (l2capinbuf[13] << 8)) == L2CAP_PSM_HID_CTRL)
{ {
identifier = l2capinbuf[9]; identifier = l2capinbuf[9];
control_scid[0] = l2capinbuf[14]; control_scid[0] = l2capinbuf[14];
control_scid[1] = l2capinbuf[15]; control_scid[1] = l2capinbuf[15];
l2cap_event_flag |= L2CAP_EV_CONTROL_CONNECTION_REQUEST; l2cap_event_flag |= L2CAP_EV_CONTROL_CONNECTION_REQUEST;
} }
else if ((l2capinbuf[13] | l2capinbuf[12]) == L2CAP_PSM_HID_INTR) else if ((l2capinbuf[12] | (l2capinbuf[13] << 8)) == L2CAP_PSM_HID_INTR)
{ {
identifier = l2capinbuf[9]; identifier = l2capinbuf[9];
interrupt_scid[0] = l2capinbuf[14]; interrupt_scid[0] = l2capinbuf[14];
@ -1000,7 +1007,7 @@ void PS3BT::ACL_event_task()
if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1])
{ {
#ifdef DEBUG #ifdef DEBUG
Notify(PSTR("\r\nDisconnected Request: Disconnected Control")); Notify(PSTR("\r\nDisconnect Request: Control Channel"));
#endif #endif
identifier = l2capinbuf[9]; identifier = l2capinbuf[9];
l2cap_disconnection_response(identifier,control_dcid,control_scid); l2cap_disconnection_response(identifier,control_dcid,control_scid);
@ -1008,7 +1015,7 @@ void PS3BT::ACL_event_task()
else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1])
{ {
#ifdef DEBUG #ifdef DEBUG
Notify(PSTR("\r\nDisconnected Request: Disconnected Interrupt")); Notify(PSTR("\r\nDisconnect Request: Interrupt Channel"));
#endif #endif
identifier = l2capinbuf[9]; identifier = l2capinbuf[9];
l2cap_disconnection_response(identifier,interrupt_dcid,interrupt_scid); l2cap_disconnection_response(identifier,interrupt_dcid,interrupt_scid);
@ -1018,13 +1025,13 @@ void PS3BT::ACL_event_task()
{ {
if (l2capinbuf[12] == control_scid[0] && l2capinbuf[13] == control_scid[1]) if (l2capinbuf[12] == control_scid[0] && l2capinbuf[13] == control_scid[1])
{ {
//Serial.print("\r\nDisconnected Response: Disconnected Control"); //Serial.print("\r\nDisconnect Response: Control Channel");
identifier = l2capinbuf[9]; identifier = l2capinbuf[9];
l2cap_event_flag |= L2CAP_EV_CONTROL_DISCONNECT_RESPONSE; l2cap_event_flag |= L2CAP_EV_CONTROL_DISCONNECT_RESPONSE;
} }
else if (l2capinbuf[12] == interrupt_scid[0] && l2capinbuf[13] == interrupt_scid[1]) else if (l2capinbuf[12] == interrupt_scid[0] && l2capinbuf[13] == interrupt_scid[1])
{ {
//Serial.print("\r\nDisconnected Response: Disconnected Interrupt"); //Serial.print("\r\nDisconnect Response: Interrupt Channel");
identifier = l2capinbuf[9]; identifier = l2capinbuf[9];
l2cap_event_flag |= L2CAP_EV_INTERRUPT_DISCONNECT_RESPONSE; l2cap_event_flag |= L2CAP_EV_INTERRUPT_DISCONNECT_RESPONSE;
} }

37
PS3BT.h
View file

@ -179,24 +179,24 @@ enum LED
}; };
enum Colors enum Colors
{ {
//Used to set the colors of the move controller // Used to set the colors of the move controller
Red = 0xFF0000,//((255 << 16) | (0 << 8) | 0); Red = 0xFF0000, // r = 255, g = 0, b = 0
Green = 0xFF00,//((0 << 16) | (255 << 8) | 0); Green = 0xFF00, // r = 0, g = 255, b = 0
Blue = 0xFF,//((0 << 16) | (0 << 8) | 255); Blue = 0xFF, // r = 0, g = 0, b = 255
Yellow = 0xFFEB04,//((255 << 16) | (235 << 8) | 4); Yellow = 0xFFEB04, // r = 255, g = 235, b = 4
Lightblue = 0xFFFF,//((0 << 16) | (255 << 8) | 255); Lightblue = 0xFFFF, // r = 0, g = 255, b = 255
Purble = 0xFF00FF,//((255 << 16) | (0 << 8) | 255); Purble = 0xFF00FF, // r = 255, g = 0, b = 255
White = 0xFFFFFF,//((255 << 16) | (255 << 8) | 255); White = 0xFFFFFF, // r = 255, g = 255, b = 255
Off = 0x00,//((0 << 16) | (0 << 8) | 0); Off = 0x00, // r = 0, g = 0, b = 0
}; };
enum Button enum Button
{ {
// byte location | bit location // byte location | bit location
//Sixaxis Dualshcock 3 & Navigation controller // Sixaxis Dualshcock 3 & Navigation controller
SELECT = (11 << 8) | 0x01, SELECT = (11 << 8) | 0x01,
L3 = (11 << 8) | 0x02, L3 = (11 << 8) | 0x02,
R3 = (11 << 8) | 0x04, R3 = (11 << 8) | 0x04,
@ -217,7 +217,13 @@ enum Button
PS = (13 << 8) | 0x01, PS = (13 << 8) | 0x01,
//Playstation Move Controller MOVE = (13/*12*/ << 8) | 0x08, // covers 12 bits - we only need to read the top 8
T = (13/*12*/ << 8) | 0x10, // covers 12 bits - we only need to read the top 8
// These are the true locations for the Move controller, but to make the same syntax for all controllers, it is handled by getButton()
/*
// Playstation Move Controller
SELECT_MOVE = (10 << 8) | 0x01, SELECT_MOVE = (10 << 8) | 0x01,
START_MOVE = (10 << 8) | 0x08, START_MOVE = (10 << 8) | 0x08,
@ -227,8 +233,9 @@ enum Button
SQUARE_MOVE = (11 << 8) | 0x80, SQUARE_MOVE = (11 << 8) | 0x80,
PS_MOVE = (12 << 8) | 0x01, PS_MOVE = (12 << 8) | 0x01,
MOVE_MOVE = (12 << 8) | 0x08,//covers 12 bits - we only need to read the top 8 MOVE_MOVE = (12 << 8) | 0x08, // covers 12 bits - we only need to read the top 8
T_MOVE = (12 << 8) | 0x10,//covers 12 bits - we only need to read the top 8 T_MOVE = (12 << 8) | 0x10, // covers 12 bits - we only need to read the top 8
*/
}; };
enum AnalogButton enum AnalogButton
{ {
@ -248,7 +255,7 @@ enum AnalogButton
SQUARE_ANALOG = 34, SQUARE_ANALOG = 34,
//Playstation Move Controller //Playstation Move Controller
T_MOVE_ANALOG = 15,//Both at byte 14 (last reading) and byte 15 (current reading) T_ANALOG = 15, // Both at byte 14 (last reading) and byte 15 (current reading)
}; };
enum AnalogHat enum AnalogHat
{ {
@ -413,7 +420,7 @@ private:
uint32_t timerHID;// timer used see if there has to be a delay before a new HID command uint32_t timerHID;// timer used see if there has to be a delay before a new HID command
uint32_t timerBulbRumble;// used to continuously set PS3 Move controller Bulb and rumble values uint32_t timerBulbRumble;// used to continuously set PS3 Move controller Bulb and rumble values
uint8_t my_bdaddr[6]; //Change to your dongles Bluetooth address in PS3BT.cpp uint8_t my_bdaddr[6]; // Change to your dongles Bluetooth address in the constructor
uint8_t hcibuf[BULK_MAXPKTSIZE];//General purpose buffer for hci data uint8_t hcibuf[BULK_MAXPKTSIZE];//General purpose buffer for hci data
uint8_t l2capinbuf[BULK_MAXPKTSIZE];//General purpose buffer for l2cap in data uint8_t l2capinbuf[BULK_MAXPKTSIZE];//General purpose buffer for l2cap in data
uint8_t l2capoutbuf[BULK_MAXPKTSIZE];//General purpose buffer for l2cap out data uint8_t l2capoutbuf[BULK_MAXPKTSIZE];//General purpose buffer for l2cap out data

View file

@ -74,7 +74,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed)
// get memory address of USB device address pool // get memory address of USB device address pool
AddressPool &addrPool = pUsb->GetAddressPool(); AddressPool &addrPool = pUsb->GetAddressPool();
#ifdef EXTRADEBUG #ifdef EXTRADEBUG
Notify(PSTR("\r\nPS3BT Init")); Notify(PSTR("\r\nPS3USB Init"));
#endif #endif
// check if address has already been assigned to an instance // check if address has already been assigned to an instance
if (bAddress) if (bAddress)
@ -209,6 +209,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed)
/* Set internal bluetooth address and request for data */ /* Set internal bluetooth address and request for data */
setBdaddr(my_bdaddr); setBdaddr(my_bdaddr);
enable_sixaxis(); enable_sixaxis();
setLedOn(LED1);
// Needed for PS3 Dualshock and Navigation commands to work // Needed for PS3 Dualshock and Navigation commands to work
for (uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++) for (uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++)
@ -216,10 +217,6 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed)
for (uint8_t i = 6; i < 10; i++) for (uint8_t i = 6; i < 10; i++)
readBuf[i] = 0x7F; // Set the analog joystick values to center position readBuf[i] = 0x7F; // Set the analog joystick values to center position
setLedOn(LED1);
timer = millis();
} }
else // must be a Motion controller else // must be a Motion controller
{ {
@ -233,8 +230,6 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed)
// Needed for Move commands to work // Needed for Move commands to work
for (uint8_t i = 0; i < MOVE_REPORT_BUFFER_SIZE; i++) for (uint8_t i = 0; i < MOVE_REPORT_BUFFER_SIZE; i++)
writeBuf[i] = pgm_read_byte(&MOVE_REPORT_BUFFER[i]); writeBuf[i] = pgm_read_byte(&MOVE_REPORT_BUFFER[i]);
timer = millis();
} }
} }
else else
@ -242,6 +237,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed)
bPollEnable = true; bPollEnable = true;
Notify(PSTR("\r\n")); Notify(PSTR("\r\n"));
timer = millis();
return 0; // successful configuration return 0; // successful configuration
/* diagnostic messages */ /* diagnostic messages */
@ -377,34 +373,37 @@ uint8_t PS3USB::getAnalogHat(AnalogHat a)
return 0; return 0;
return (uint8_t)(readBuf[(uint16_t)a]); return (uint8_t)(readBuf[(uint16_t)a]);
} }
int32_t PS3USB::getSensor(Sensor a) uint16_t PS3USB::getSensor(Sensor a)
{ {
if (readBuf == NULL) if (readBuf == NULL)
return 0; return 0;
return ((readBuf[(uint16_t)a] << 8) | readBuf[(uint16_t)a + 1]); return ((readBuf[(uint16_t)a] << 8) | readBuf[(uint16_t)a + 1]);
} }
double PS3USB::getAngle(Angle a) { double PS3USB::getAngle(Angle a) {
double accXval;
double accYval;
double accZval;
if(PS3Connected) { if(PS3Connected) {
double accXval;
double accYval;
double accZval;
// Data for the Kionix KXPC4 used in the DualShock 3 // Data for the Kionix KXPC4 used in the DualShock 3
const double zeroG = 511.5; // 1.65/3.3*1023 (1,65V) const double zeroG = 511.5; // 1.65/3.3*1023 (1,65V)
accXval = -((double)getSensor(aX)-zeroG); accXval = -((double)getSensor(aX)-zeroG);
accYval = -((double)getSensor(aY)-zeroG); accYval = -((double)getSensor(aY)-zeroG);
accZval = -((double)getSensor(aZ)-zeroG); accZval = -((double)getSensor(aZ)-zeroG);
}
// Convert to 360 degrees resolution // Convert to 360 degrees resolution
// atan2 outputs the value of -π to π (radians) // atan2 outputs the value of -π to π (radians)
// We are then converting it to 0 to 2π and then to degrees // We are then converting it to 0 to 2π and then to degrees
if (a == Pitch) { if (a == Pitch) {
double angle = (atan2(accYval,accZval)+PI)*RAD_TO_DEG; double angle = (atan2(accYval,accZval)+PI)*RAD_TO_DEG;
return angle; return angle;
} else { } else {
double angle = (atan2(accXval,accZval)+PI)*RAD_TO_DEG; double angle = (atan2(accXval,accZval)+PI)*RAD_TO_DEG;
return angle; return angle;
} }
} else
return 0;
} }
bool PS3USB::getStatus(Status c) bool PS3USB::getStatus(Status c)
{ {
@ -428,6 +427,7 @@ String PS3USB::getStatusString()
strcat(statusOutput," - PowerRating: "); strcat(statusOutput," - PowerRating: ");
if (getStatus(Charging)) strcat(statusOutput,"Charging"); if (getStatus(Charging)) strcat(statusOutput,"Charging");
else if (getStatus(NotCharging)) strcat(statusOutput,"Not Charging"); else if (getStatus(NotCharging)) strcat(statusOutput,"Not Charging");
else if (getStatus(Shutdown)) strcat(statusOutput,"Shutdown"); else if (getStatus(Shutdown)) strcat(statusOutput,"Shutdown");

View file

@ -46,9 +46,6 @@
#define PS3_REPORT_BUFFER_SIZE 48 // Size of the output report buffer for the Dualshock and Navigation controllers #define PS3_REPORT_BUFFER_SIZE 48 // Size of the output report buffer for the Dualshock and Navigation controllers
#define MOVE_REPORT_BUFFER_SIZE 7 // Size of the output report buffer for the Move Controller #define MOVE_REPORT_BUFFER_SIZE 7 // Size of the output report buffer for the Move Controller
// used in control endpoint header for HCI Commands
#define bmREQ_HCI_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE
// used in control endpoint header for HID Commands // used in control endpoint header for HID Commands
#define bmREQ_HID_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE #define bmREQ_HID_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
#define HID_REQUEST_SET_REPORT 0x09 #define HID_REQUEST_SET_REPORT 0x09
@ -71,24 +68,24 @@ enum LED
}; };
enum Colors enum Colors
{ {
//Used to set the colors of the move controller // Used to set the colors of the move controller
Red = 0xFF0000,//((255 << 16) | (0 << 8) | 0); Red = 0xFF0000, // r = 255, g = 0, b = 0
Green = 0xFF00,//((0 << 16) | (255 << 8) | 0); Green = 0xFF00, // r = 0, g = 255, b = 0
Blue = 0xFF,//((0 << 16) | (0 << 8) | 255); Blue = 0xFF, // r = 0, g = 0, b = 255
Yellow = 0xFFEB04,//((255 << 16) | (235 << 8) | 4); Yellow = 0xFFEB04, // r = 255, g = 235, b = 4
Lightblue = 0xFFFF,//((0 << 16) | (255 << 8) | 255); Lightblue = 0xFFFF, // r = 0, g = 255, b = 255
Purble = 0xFF00FF,//((255 << 16) | (0 << 8) | 255); Purble = 0xFF00FF, // r = 255, g = 0, b = 255
White = 0xFFFFFF,//((255 << 16) | (255 << 8) | 255); White = 0xFFFFFF, // r = 255, g = 255, b = 255
Off = 0x00,//((0 << 16) | (0 << 8) | 0); Off = 0x00, // r = 0, g = 0, b = 0
}; };
enum Button enum Button
{ {
// byte location | bit location // byte location | bit location
//Sixaxis Dualshcock 3 & Navigation controller // Sixaxis Dualshcock 3 & Navigation controller
SELECT = (2 << 8) | 0x01, SELECT = (2 << 8) | 0x01,
L3 = (2 << 8) | 0x02, L3 = (2 << 8) | 0x02,
R3 = (2 << 8) | 0x04, R3 = (2 << 8) | 0x04,
@ -111,7 +108,7 @@ enum Button
}; };
enum AnalogButton enum AnalogButton
{ {
//Sixaxis Dualshcock 3 & Navigation controller // Sixaxis Dualshcock 3 & Navigation controller
UP_ANALOG = 14, UP_ANALOG = 14,
RIGHT_ANALOG = 15, RIGHT_ANALOG = 15,
DOWN_ANALOG = 16, DOWN_ANALOG = 16,
@ -163,7 +160,7 @@ enum Status
CableRumble = (31 << 8) | 0x10, // Opperating by USB and rumble is turned on CableRumble = (31 << 8) | 0x10, // Opperating by USB and rumble is turned on
Cable = (31 << 8) | 0x12, // Opperating by USB and rumble is turned off Cable = (31 << 8) | 0x12, // Opperating by USB and rumble is turned off
BluetoothRumble = (31 << 8) | 0x14, // Opperating by bluetooth and rumble is turned on BluetoothRumble = (31 << 8) | 0x14, // Opperating by bluetooth and rumble is turned on
Bluetooth = (30 << 8) | 0x16, // Opperating by bluetooth and rumble is turned off Bluetooth = (31 << 8) | 0x16, // Opperating by bluetooth and rumble is turned off
}; };
enum Rumble enum Rumble
{ {
@ -190,7 +187,7 @@ public:
bool getButton(Button b); bool getButton(Button b);
uint8_t getAnalogButton(AnalogButton a); uint8_t getAnalogButton(AnalogButton a);
uint8_t getAnalogHat(AnalogHat a); uint8_t getAnalogHat(AnalogHat a);
int32_t getSensor(Sensor a); uint16_t getSensor(Sensor a);
double getAngle(Angle a); double getAngle(Angle a);
bool getStatus(Status c); bool getStatus(Status c);
String getStatusString(); String getStatusString();
@ -229,7 +226,7 @@ private:
uint32_t ButtonState; uint32_t ButtonState;
uint32_t OldButtonState; uint32_t OldButtonState;
uint8_t my_bdaddr[6]; // Change to your dongles Bluetooth address in PS3BT.cpp uint8_t my_bdaddr[6]; // Change to your dongles Bluetooth address in the constructor
uint8_t readBuf[EP_MAXPKTSIZE]; // General purpose buffer for input data uint8_t readBuf[EP_MAXPKTSIZE]; // General purpose buffer for input data
uint8_t writeBuf[EP_MAXPKTSIZE]; // General purpose buffer for output data uint8_t writeBuf[EP_MAXPKTSIZE]; // General purpose buffer for output data

View file

@ -80,20 +80,28 @@ void loop()
if(PS3.getButton(UP)) { if(PS3.getButton(UP)) {
Serial.print(F(" - Up")); Serial.print(F(" - Up"));
PS3.setAllOff(); if(PS3.PS3Connected) {
PS3.setLedOn(LED4); PS3.setAllOff();
PS3.setLedOn(LED4);
}
} if(PS3.getButton(RIGHT)) { } if(PS3.getButton(RIGHT)) {
Serial.print(F(" - Right")); Serial.print(F(" - Right"));
PS3.setAllOff(); if(PS3.PS3Connected) {
PS3.setLedOn(LED1); PS3.setAllOff();
PS3.setLedOn(LED1);
}
} if(PS3.getButton(DOWN)) { } if(PS3.getButton(DOWN)) {
Serial.print(F(" - Down")); Serial.print(F(" - Down"));
PS3.setAllOff(); if(PS3.PS3Connected) {
PS3.setLedOn(LED2); PS3.setAllOff();
PS3.setLedOn(LED2);
}
} if(PS3.getButton(LEFT)) { } if(PS3.getButton(LEFT)) {
Serial.print(F(" - Left")); Serial.print(F(" - Left"));
PS3.setAllOff(); if(PS3.PS3Connected) {
PS3.setLedOn(LED3); PS3.setAllOff();
PS3.setLedOn(LED3);
}
} }
if(PS3.getButton(L1)) if(PS3.getButton(L1))
@ -130,39 +138,39 @@ void loop()
} }
else if(PS3.PS3MoveConnected) else if(PS3.PS3MoveConnected)
{ {
if(PS3.getAnalogButton(T_MOVE_ANALOG) > 0) { if(PS3.getAnalogButton(T_ANALOG) > 0) {
Serial.print(F("T: ")); Serial.print(F("T: "));
Serial.println(PS3.getAnalogButton(T_MOVE_ANALOG)); Serial.println(PS3.getAnalogButton(T_ANALOG));
} if(PS3.buttonPressed) { } if(PS3.buttonPressed) {
Serial.print(F("PS3 Move Controller")); Serial.print(F("PS3 Move Controller"));
if(PS3.getButton(PS_MOVE)) { if(PS3.getButton(PS)) {
Serial.print(F(" - PS")); Serial.print(F(" - PS"));
PS3.disconnect(); PS3.disconnect();
} else { } else {
if(PS3.getButton(SELECT_MOVE)) { if(PS3.getButton(SELECT)) {
Serial.print(F(" - Select")); Serial.print(F(" - Select"));
printTemperature = !printTemperature; printTemperature = !printTemperature;
while(PS3.getButton(SELECT_MOVE)) while(PS3.getButton(SELECT))
Usb.Task(); Usb.Task();
} if(PS3.getButton(START_MOVE)) { } if(PS3.getButton(START)) {
Serial.print(F(" - Start")); Serial.print(F(" - Start"));
printAngle = !printAngle; printAngle = !printAngle;
while(PS3.getButton(START_MOVE)) while(PS3.getButton(START))
Usb.Task(); Usb.Task();
} if(PS3.getButton(TRIANGLE_MOVE)) { } if(PS3.getButton(TRIANGLE)) {
Serial.print(F(" - Triangle")); Serial.print(F(" - Triangle"));
PS3.moveSetBulb(Red); PS3.moveSetBulb(Red);
} if(PS3.getButton(CIRCLE_MOVE)) { } if(PS3.getButton(CIRCLE)) {
Serial.print(F(" - Circle")); Serial.print(F(" - Circle"));
PS3.moveSetBulb(Green); PS3.moveSetBulb(Green);
} if(PS3.getButton(SQUARE_MOVE)) { } if(PS3.getButton(SQUARE)) {
Serial.print(F(" - Square")); Serial.print(F(" - Square"));
PS3.moveSetBulb(Blue); PS3.moveSetBulb(Blue);
} if(PS3.getButton(CROSS_MOVE)) { } if(PS3.getButton(CROSS)) {
Serial.print(F(" - Cross")); Serial.print(F(" - Cross"));
PS3.moveSetBulb(Yellow); PS3.moveSetBulb(Yellow);
} if(PS3.getButton(MOVE_MOVE)) { } if(PS3.getButton(MOVE)) {
PS3.moveSetBulb(Off); PS3.moveSetBulb(Off);
Serial.print(F(" - Move")); Serial.print(F(" - Move"));
Serial.print(F(" - ")); Serial.print(F(" - "));

View file

@ -82,15 +82,8 @@ CIRCLE LITERAL1
CROSS LITERAL1 CROSS LITERAL1
SQUARE LITERAL1 SQUARE LITERAL1
PS LITERAL1 PS LITERAL1
SELECT_MOVE LITERAL1 MOVE LITERAL1
START_MOVE LITERAL1 T LITERAL1
TRIANGLE_MOVE LITERAL1
CIRCLE_MOVE LITERAL1
CROSS_MOVE LITERAL1
SQUARE_MOVE LITERAL1
PS_MOVE LITERAL1
MOVE_MOVE LITERAL1
T_MOVE LITERAL1
UP_ANALOG LITERAL1 UP_ANALOG LITERAL1
RIGHT_ANALOG LITERAL1 RIGHT_ANALOG LITERAL1
@ -104,7 +97,7 @@ TRIANGLE_ANALOG LITERAL1
CIRCLE_ANALOG LITERAL1 CIRCLE_ANALOG LITERAL1
CROSS_ANALOG LITERAL1 CROSS_ANALOG LITERAL1
SQUARE_ANALOG LITERAL1 SQUARE_ANALOG LITERAL1
T_MOVE_ANALOG LITERAL1 T_ANALOG LITERAL1
LeftHatX LITERAL1 LeftHatX LITERAL1
LeftHatY LITERAL1 LeftHatY LITERAL1