Created same syntax for Move controller

This commit is contained in:
Kristian Lauszus 2012-05-28 21:53:20 +02:00
parent 91fbbfad3b
commit 9d6eb2d69b
5 changed files with 76 additions and 61 deletions

View file

@ -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)
{

35
PS3BT.h
View file

@ -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
{

View file

@ -68,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,
@ -108,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,

View file

@ -80,20 +80,28 @@ void loop()
if(PS3.getButton(UP)) {
Serial.print(F(" - Up"));
PS3.setAllOff();
PS3.setLedOn(LED4);
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);
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(" - "));

View file

@ -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