mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Created same syntax for Move controller
This commit is contained in:
parent
91fbbfad3b
commit
9d6eb2d69b
5 changed files with 76 additions and 61 deletions
|
@ -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)
|
||||
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)
|
||||
{
|
||||
|
|
25
PS3BT.h
25
PS3BT.h
|
@ -180,16 +180,16 @@ 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);
|
||||
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
|
||||
|
@ -217,6 +217,12 @@ enum Button
|
|||
|
||||
PS = (13 << 8) | 0x01,
|
||||
|
||||
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,
|
||||
|
@ -229,6 +235,7 @@ enum Button
|
|||
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
|
||||
*/
|
||||
};
|
||||
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
|
||||
{
|
||||
|
|
16
PS3USB.h
16
PS3USB.h
|
@ -69,16 +69,16 @@ 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);
|
||||
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
|
||||
|
|
|
@ -80,21 +80,29 @@ void loop()
|
|||
|
||||
if(PS3.getButton(UP)) {
|
||||
Serial.print(F(" - Up"));
|
||||
if(PS3.PS3Connected) {
|
||||
PS3.setAllOff();
|
||||
PS3.setLedOn(LED4);
|
||||
}
|
||||
} if(PS3.getButton(RIGHT)) {
|
||||
Serial.print(F(" - Right"));
|
||||
if(PS3.PS3Connected) {
|
||||
PS3.setAllOff();
|
||||
PS3.setLedOn(LED1);
|
||||
}
|
||||
} if(PS3.getButton(DOWN)) {
|
||||
Serial.print(F(" - Down"));
|
||||
if(PS3.PS3Connected) {
|
||||
PS3.setAllOff();
|
||||
PS3.setLedOn(LED2);
|
||||
}
|
||||
} if(PS3.getButton(LEFT)) {
|
||||
Serial.print(F(" - Left"));
|
||||
if(PS3.PS3Connected) {
|
||||
PS3.setAllOff();
|
||||
PS3.setLedOn(LED3);
|
||||
}
|
||||
}
|
||||
|
||||
if(PS3.getButton(L1))
|
||||
Serial.print(F(" - 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