mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
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:
commit
dc9da41fa5
6 changed files with 123 additions and 111 deletions
49
PS3BT.cpp
49
PS3BT.cpp
|
@ -441,10 +441,17 @@ bool PS3BT::getButton(Button b)
|
|||
{
|
||||
if (l2capinbuf == NULL)
|
||||
return false;
|
||||
if ((l2capinbuf[(uint16_t)b >> 8] & ((uint8_t)b & 0xff)) > 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
if(PS3MoveConnected) {
|
||||
if((l2capinbuf[((uint16_t)b >> 8)-1] & ((uint8_t)b & 0xff))) // All the buttons locations are shifted one back on the Move controller
|
||||
return true;
|
||||
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)
|
||||
{
|
||||
|
@ -464,25 +471,25 @@ int32_t PS3BT::getSensor(Sensor a)
|
|||
return 0;
|
||||
if (a == aX || a == aY || a == aZ || a == gZ)
|
||||
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
|
||||
if (a == mXmove)
|
||||
/*if (a == mXmove)
|
||||
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)
|
||||
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)
|
||||
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
|
||||
return 0;
|
||||
return ((l2capinbuf[(uint16_t)a + 1] << 0x0F) | (l2capinbuf[(uint16_t)a] << 0x0C));
|
||||
*/
|
||||
if (a == mXmove || a == mYmove)
|
||||
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)
|
||||
return (((l2capinbuf[(uint16_t)a + 1] & 0xF0) >> 4) | (l2capinbuf[(uint16_t)a] << 4));
|
||||
else if (a == tempMove) // The tempearature is 12 bits long too
|
||||
return ((l2capinbuf[(uint16_t)a] << 4) | ((l2capinbuf[(uint16_t)a + 1] & 0xF0) >> 4));
|
||||
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 accXval;
|
||||
|
@ -946,14 +953,14 @@ void PS3BT::ACL_event_task()
|
|||
Notify(PSTR(" Identifier: "));
|
||||
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];
|
||||
control_scid[0] = l2capinbuf[14];
|
||||
control_scid[1] = l2capinbuf[15];
|
||||
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];
|
||||
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])
|
||||
{
|
||||
#ifdef DEBUG
|
||||
Notify(PSTR("\r\nDisconnected Request: Disconnected Control"));
|
||||
Notify(PSTR("\r\nDisconnect Request: Control Channel"));
|
||||
#endif
|
||||
identifier = l2capinbuf[9];
|
||||
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])
|
||||
{
|
||||
#ifdef DEBUG
|
||||
Notify(PSTR("\r\nDisconnected Request: Disconnected Interrupt"));
|
||||
Notify(PSTR("\r\nDisconnect Request: Interrupt Channel"));
|
||||
#endif
|
||||
identifier = l2capinbuf[9];
|
||||
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])
|
||||
{
|
||||
//Serial.print("\r\nDisconnected Response: Disconnected Control");
|
||||
//Serial.print("\r\nDisconnect Response: Control Channel");
|
||||
identifier = l2capinbuf[9];
|
||||
l2cap_event_flag |= L2CAP_EV_CONTROL_DISCONNECT_RESPONSE;
|
||||
}
|
||||
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];
|
||||
l2cap_event_flag |= L2CAP_EV_INTERRUPT_DISCONNECT_RESPONSE;
|
||||
}
|
||||
|
|
37
PS3BT.h
37
PS3BT.h
|
@ -179,24 +179,24 @@ enum LED
|
|||
};
|
||||
enum Colors
|
||||
{
|
||||
//Used to set the colors of the move controller
|
||||
Red = 0xFF0000,//((255 << 16) | (0 << 8) | 0);
|
||||
Green = 0xFF00,//((0 << 16) | (255 << 8) | 0);
|
||||
Blue = 0xFF,//((0 << 16) | (0 << 8) | 255);
|
||||
// Used to set the colors of the move controller
|
||||
Red = 0xFF0000, // r = 255, g = 0, b = 0
|
||||
Green = 0xFF00, // r = 0, g = 255, b = 0
|
||||
Blue = 0xFF, // r = 0, g = 0, b = 255
|
||||
|
||||
Yellow = 0xFFEB04,//((255 << 16) | (235 << 8) | 4);
|
||||
Lightblue = 0xFFFF,//((0 << 16) | (255 << 8) | 255);
|
||||
Purble = 0xFF00FF,//((255 << 16) | (0 << 8) | 255);
|
||||
Yellow = 0xFFEB04, // r = 255, g = 235, b = 4
|
||||
Lightblue = 0xFFFF, // r = 0, g = 255, b = 255
|
||||
Purble = 0xFF00FF, // r = 255, g = 0, b = 255
|
||||
|
||||
White = 0xFFFFFF,//((255 << 16) | (255 << 8) | 255);
|
||||
Off = 0x00,//((0 << 16) | (0 << 8) | 0);
|
||||
White = 0xFFFFFF, // r = 255, g = 255, b = 255
|
||||
Off = 0x00, // r = 0, g = 0, b = 0
|
||||
};
|
||||
|
||||
enum Button
|
||||
{
|
||||
// byte location | bit location
|
||||
|
||||
//Sixaxis Dualshcock 3 & Navigation controller
|
||||
// Sixaxis Dualshcock 3 & Navigation controller
|
||||
SELECT = (11 << 8) | 0x01,
|
||||
L3 = (11 << 8) | 0x02,
|
||||
R3 = (11 << 8) | 0x04,
|
||||
|
@ -217,7 +217,13 @@ enum Button
|
|||
|
||||
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,
|
||||
START_MOVE = (10 << 8) | 0x08,
|
||||
|
||||
|
@ -227,8 +233,9 @@ enum Button
|
|||
SQUARE_MOVE = (11 << 8) | 0x80,
|
||||
|
||||
PS_MOVE = (12 << 8) | 0x01,
|
||||
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
|
||||
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
|
||||
*/
|
||||
};
|
||||
enum AnalogButton
|
||||
{
|
||||
|
@ -248,7 +255,7 @@ enum AnalogButton
|
|||
SQUARE_ANALOG = 34,
|
||||
|
||||
//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
|
||||
{
|
||||
|
@ -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 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 l2capinbuf[BULK_MAXPKTSIZE];//General purpose buffer for l2cap in data
|
||||
uint8_t l2capoutbuf[BULK_MAXPKTSIZE];//General purpose buffer for l2cap out data
|
||||
|
|
52
PS3USB.cpp
52
PS3USB.cpp
|
@ -74,7 +74,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed)
|
|||
// get memory address of USB device address pool
|
||||
AddressPool &addrPool = pUsb->GetAddressPool();
|
||||
#ifdef EXTRADEBUG
|
||||
Notify(PSTR("\r\nPS3BT Init"));
|
||||
Notify(PSTR("\r\nPS3USB Init"));
|
||||
#endif
|
||||
// check if address has already been assigned to an instance
|
||||
if (bAddress)
|
||||
|
@ -209,17 +209,14 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed)
|
|||
/* Set internal bluetooth address and request for data */
|
||||
setBdaddr(my_bdaddr);
|
||||
enable_sixaxis();
|
||||
setLedOn(LED1);
|
||||
|
||||
// Needed for PS3 Dualshock and Navigation commands to work
|
||||
for (uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++)
|
||||
writeBuf[i] = pgm_read_byte(&PS3_REPORT_BUFFER[i]);
|
||||
|
||||
for (uint8_t i = 6; i < 10; i++)
|
||||
readBuf[i] = 0x7F; // Set the analog joystick values to center position
|
||||
|
||||
setLedOn(LED1);
|
||||
|
||||
timer = millis();
|
||||
readBuf[i] = 0x7F; // Set the analog joystick values to center position
|
||||
}
|
||||
else // must be a Motion controller
|
||||
{
|
||||
|
@ -232,9 +229,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed)
|
|||
|
||||
// Needed for Move commands to work
|
||||
for (uint8_t i = 0; i < MOVE_REPORT_BUFFER_SIZE; i++)
|
||||
writeBuf[i] = pgm_read_byte(&MOVE_REPORT_BUFFER[i]);
|
||||
|
||||
timer = millis();
|
||||
writeBuf[i] = pgm_read_byte(&MOVE_REPORT_BUFFER[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -242,6 +237,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed)
|
|||
|
||||
bPollEnable = true;
|
||||
Notify(PSTR("\r\n"));
|
||||
timer = millis();
|
||||
return 0; // successful configuration
|
||||
|
||||
/* diagnostic messages */
|
||||
|
@ -377,34 +373,37 @@ uint8_t PS3USB::getAnalogHat(AnalogHat a)
|
|||
return 0;
|
||||
return (uint8_t)(readBuf[(uint16_t)a]);
|
||||
}
|
||||
int32_t PS3USB::getSensor(Sensor a)
|
||||
uint16_t PS3USB::getSensor(Sensor a)
|
||||
{
|
||||
if (readBuf == NULL)
|
||||
return 0;
|
||||
return ((readBuf[(uint16_t)a] << 8) | readBuf[(uint16_t)a + 1]);
|
||||
}
|
||||
double PS3USB::getAngle(Angle a) {
|
||||
double accXval;
|
||||
double accYval;
|
||||
double accZval;
|
||||
|
||||
double PS3USB::getAngle(Angle a) {
|
||||
if(PS3Connected) {
|
||||
double accXval;
|
||||
double accYval;
|
||||
double accZval;
|
||||
|
||||
// Data for the Kionix KXPC4 used in the DualShock 3
|
||||
const double zeroG = 511.5; // 1.65/3.3*1023 (1,65V)
|
||||
accXval = -((double)getSensor(aX)-zeroG);
|
||||
accYval = -((double)getSensor(aY)-zeroG);
|
||||
accZval = -((double)getSensor(aZ)-zeroG);
|
||||
}
|
||||
// Convert to 360 degrees resolution
|
||||
// atan2 outputs the value of -π to π (radians)
|
||||
// We are then converting it to 0 to 2π and then to degrees
|
||||
if (a == Pitch) {
|
||||
double angle = (atan2(accYval,accZval)+PI)*RAD_TO_DEG;
|
||||
return angle;
|
||||
} else {
|
||||
double angle = (atan2(accXval,accZval)+PI)*RAD_TO_DEG;
|
||||
return angle;
|
||||
}
|
||||
|
||||
// Convert to 360 degrees resolution
|
||||
// atan2 outputs the value of -π to π (radians)
|
||||
// We are then converting it to 0 to 2π and then to degrees
|
||||
if (a == Pitch) {
|
||||
double angle = (atan2(accYval,accZval)+PI)*RAD_TO_DEG;
|
||||
return angle;
|
||||
} else {
|
||||
double angle = (atan2(accXval,accZval)+PI)*RAD_TO_DEG;
|
||||
return angle;
|
||||
}
|
||||
} else
|
||||
return 0;
|
||||
|
||||
}
|
||||
bool PS3USB::getStatus(Status c)
|
||||
{
|
||||
|
@ -428,6 +427,7 @@ String PS3USB::getStatusString()
|
|||
|
||||
|
||||
strcat(statusOutput," - PowerRating: ");
|
||||
|
||||
if (getStatus(Charging)) strcat(statusOutput,"Charging");
|
||||
else if (getStatus(NotCharging)) strcat(statusOutput,"Not Charging");
|
||||
else if (getStatus(Shutdown)) strcat(statusOutput,"Shutdown");
|
||||
|
|
31
PS3USB.h
31
PS3USB.h
|
@ -46,9 +46,6 @@
|
|||
#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
|
||||
|
||||
// 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
|
||||
#define bmREQ_HID_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
||||
#define HID_REQUEST_SET_REPORT 0x09
|
||||
|
@ -71,24 +68,24 @@ enum LED
|
|||
};
|
||||
enum Colors
|
||||
{
|
||||
//Used to set the colors of the move controller
|
||||
Red = 0xFF0000,//((255 << 16) | (0 << 8) | 0);
|
||||
Green = 0xFF00,//((0 << 16) | (255 << 8) | 0);
|
||||
Blue = 0xFF,//((0 << 16) | (0 << 8) | 255);
|
||||
// Used to set the colors of the move controller
|
||||
Red = 0xFF0000, // r = 255, g = 0, b = 0
|
||||
Green = 0xFF00, // r = 0, g = 255, b = 0
|
||||
Blue = 0xFF, // r = 0, g = 0, b = 255
|
||||
|
||||
Yellow = 0xFFEB04,//((255 << 16) | (235 << 8) | 4);
|
||||
Lightblue = 0xFFFF,//((0 << 16) | (255 << 8) | 255);
|
||||
Purble = 0xFF00FF,//((255 << 16) | (0 << 8) | 255);
|
||||
Yellow = 0xFFEB04, // r = 255, g = 235, b = 4
|
||||
Lightblue = 0xFFFF, // r = 0, g = 255, b = 255
|
||||
Purble = 0xFF00FF, // r = 255, g = 0, b = 255
|
||||
|
||||
White = 0xFFFFFF,//((255 << 16) | (255 << 8) | 255);
|
||||
Off = 0x00,//((0 << 16) | (0 << 8) | 0);
|
||||
White = 0xFFFFFF, // r = 255, g = 255, b = 255
|
||||
Off = 0x00, // r = 0, g = 0, b = 0
|
||||
};
|
||||
|
||||
enum Button
|
||||
{
|
||||
// byte location | bit location
|
||||
|
||||
//Sixaxis Dualshcock 3 & Navigation controller
|
||||
// Sixaxis Dualshcock 3 & Navigation controller
|
||||
SELECT = (2 << 8) | 0x01,
|
||||
L3 = (2 << 8) | 0x02,
|
||||
R3 = (2 << 8) | 0x04,
|
||||
|
@ -111,7 +108,7 @@ enum Button
|
|||
};
|
||||
enum AnalogButton
|
||||
{
|
||||
//Sixaxis Dualshcock 3 & Navigation controller
|
||||
// Sixaxis Dualshcock 3 & Navigation controller
|
||||
UP_ANALOG = 14,
|
||||
RIGHT_ANALOG = 15,
|
||||
DOWN_ANALOG = 16,
|
||||
|
@ -163,7 +160,7 @@ enum Status
|
|||
CableRumble = (31 << 8) | 0x10, // Opperating by USB and rumble is turned on
|
||||
Cable = (31 << 8) | 0x12, // Opperating by USB and rumble is turned off
|
||||
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
|
||||
{
|
||||
|
@ -190,7 +187,7 @@ public:
|
|||
bool getButton(Button b);
|
||||
uint8_t getAnalogButton(AnalogButton a);
|
||||
uint8_t getAnalogHat(AnalogHat a);
|
||||
int32_t getSensor(Sensor a);
|
||||
uint16_t getSensor(Sensor a);
|
||||
double getAngle(Angle a);
|
||||
bool getStatus(Status c);
|
||||
String getStatusString();
|
||||
|
@ -229,7 +226,7 @@ private:
|
|||
uint32_t ButtonState;
|
||||
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 writeBuf[EP_MAXPKTSIZE]; // General purpose buffer for output data
|
||||
|
||||
|
|
|
@ -79,21 +79,29 @@ void loop()
|
|||
Serial.print(F(" - Square"));
|
||||
|
||||
if(PS3.getButton(UP)) {
|
||||
Serial.print(F(" - Up"));
|
||||
PS3.setAllOff();
|
||||
PS3.setLedOn(LED4);
|
||||
Serial.print(F(" - Up"));
|
||||
if(PS3.PS3Connected) {
|
||||
PS3.setAllOff();
|
||||
PS3.setLedOn(LED4);
|
||||
}
|
||||
} if(PS3.getButton(RIGHT)) {
|
||||
Serial.print(F(" - Right"));
|
||||
PS3.setAllOff();
|
||||
PS3.setLedOn(LED1);
|
||||
if(PS3.PS3Connected) {
|
||||
PS3.setAllOff();
|
||||
PS3.setLedOn(LED1);
|
||||
}
|
||||
} if(PS3.getButton(DOWN)) {
|
||||
Serial.print(F(" - Down"));
|
||||
PS3.setAllOff();
|
||||
PS3.setLedOn(LED2);
|
||||
if(PS3.PS3Connected) {
|
||||
PS3.setAllOff();
|
||||
PS3.setLedOn(LED2);
|
||||
}
|
||||
} if(PS3.getButton(LEFT)) {
|
||||
Serial.print(F(" - Left"));
|
||||
PS3.setAllOff();
|
||||
PS3.setLedOn(LED3);
|
||||
Serial.print(F(" - Left"));
|
||||
if(PS3.PS3Connected) {
|
||||
PS3.setAllOff();
|
||||
PS3.setLedOn(LED3);
|
||||
}
|
||||
}
|
||||
|
||||
if(PS3.getButton(L1))
|
||||
|
@ -130,39 +138,39 @@ void loop()
|
|||
}
|
||||
else if(PS3.PS3MoveConnected)
|
||||
{
|
||||
if(PS3.getAnalogButton(T_MOVE_ANALOG) > 0) {
|
||||
if(PS3.getAnalogButton(T_ANALOG) > 0) {
|
||||
Serial.print(F("T: "));
|
||||
Serial.println(PS3.getAnalogButton(T_MOVE_ANALOG));
|
||||
Serial.println(PS3.getAnalogButton(T_ANALOG));
|
||||
} if(PS3.buttonPressed) {
|
||||
Serial.print(F("PS3 Move Controller"));
|
||||
|
||||
if(PS3.getButton(PS_MOVE)) {
|
||||
if(PS3.getButton(PS)) {
|
||||
Serial.print(F(" - PS"));
|
||||
PS3.disconnect();
|
||||
} else {
|
||||
if(PS3.getButton(SELECT_MOVE)) {
|
||||
if(PS3.getButton(SELECT)) {
|
||||
Serial.print(F(" - Select"));
|
||||
printTemperature = !printTemperature;
|
||||
while(PS3.getButton(SELECT_MOVE))
|
||||
while(PS3.getButton(SELECT))
|
||||
Usb.Task();
|
||||
} if(PS3.getButton(START_MOVE)) {
|
||||
} if(PS3.getButton(START)) {
|
||||
Serial.print(F(" - Start"));
|
||||
printAngle = !printAngle;
|
||||
while(PS3.getButton(START_MOVE))
|
||||
while(PS3.getButton(START))
|
||||
Usb.Task();
|
||||
} if(PS3.getButton(TRIANGLE_MOVE)) {
|
||||
} if(PS3.getButton(TRIANGLE)) {
|
||||
Serial.print(F(" - Triangle"));
|
||||
PS3.moveSetBulb(Red);
|
||||
} if(PS3.getButton(CIRCLE_MOVE)) {
|
||||
} if(PS3.getButton(CIRCLE)) {
|
||||
Serial.print(F(" - Circle"));
|
||||
PS3.moveSetBulb(Green);
|
||||
} if(PS3.getButton(SQUARE_MOVE)) {
|
||||
} if(PS3.getButton(SQUARE)) {
|
||||
Serial.print(F(" - Square"));
|
||||
PS3.moveSetBulb(Blue);
|
||||
} if(PS3.getButton(CROSS_MOVE)) {
|
||||
} if(PS3.getButton(CROSS)) {
|
||||
Serial.print(F(" - Cross"));
|
||||
PS3.moveSetBulb(Yellow);
|
||||
} if(PS3.getButton(MOVE_MOVE)) {
|
||||
} if(PS3.getButton(MOVE)) {
|
||||
PS3.moveSetBulb(Off);
|
||||
Serial.print(F(" - Move"));
|
||||
Serial.print(F(" - "));
|
||||
|
|
13
keywords.txt
13
keywords.txt
|
@ -82,15 +82,8 @@ CIRCLE LITERAL1
|
|||
CROSS LITERAL1
|
||||
SQUARE LITERAL1
|
||||
PS LITERAL1
|
||||
SELECT_MOVE LITERAL1
|
||||
START_MOVE LITERAL1
|
||||
TRIANGLE_MOVE LITERAL1
|
||||
CIRCLE_MOVE LITERAL1
|
||||
CROSS_MOVE LITERAL1
|
||||
SQUARE_MOVE LITERAL1
|
||||
PS_MOVE LITERAL1
|
||||
MOVE_MOVE LITERAL1
|
||||
T_MOVE LITERAL1
|
||||
MOVE LITERAL1
|
||||
T LITERAL1
|
||||
|
||||
UP_ANALOG LITERAL1
|
||||
RIGHT_ANALOG LITERAL1
|
||||
|
@ -104,7 +97,7 @@ TRIANGLE_ANALOG LITERAL1
|
|||
CIRCLE_ANALOG LITERAL1
|
||||
CROSS_ANALOG LITERAL1
|
||||
SQUARE_ANALOG LITERAL1
|
||||
T_MOVE_ANALOG LITERAL1
|
||||
T_ANALOG LITERAL1
|
||||
|
||||
LeftHatX LITERAL1
|
||||
LeftHatY LITERAL1
|
||||
|
|
Loading…
Reference in a new issue