mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Added setLedToggle()
This commit is contained in:
parent
2330fd95be
commit
e60ddbac5a
3 changed files with 14 additions and 22 deletions
30
PS3BT.cpp
30
PS3BT.cpp
|
@ -407,16 +407,12 @@ uint8_t PS3BT::Poll()
|
||||||
}
|
}
|
||||||
void PS3BT::setBdaddr(uint8_t* BDADDR)
|
void PS3BT::setBdaddr(uint8_t* BDADDR)
|
||||||
{
|
{
|
||||||
/* Store the bluetooth address */
|
|
||||||
for(uint8_t i = 0; i <6;i++)
|
|
||||||
my_bdaddr[i] = BDADDR[i];
|
|
||||||
|
|
||||||
/* Set the internal bluetooth address */
|
/* Set the internal bluetooth address */
|
||||||
uint8_t buf[8];
|
uint8_t buf[8];
|
||||||
buf[0] = 0x01;
|
buf[0] = 0x01;
|
||||||
buf[1] = 0x00;
|
buf[1] = 0x00;
|
||||||
for (uint8_t i = 0; i < 6; i++)
|
for (uint8_t i = 0; i < 6; i++)
|
||||||
buf[i+2] = my_bdaddr[5 - i];//Copy into buffer, has to be written reversed
|
buf[i+2] = BDADDR[5 - i];//Copy into buffer, has to be written reversed
|
||||||
|
|
||||||
//bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0xF5), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data)
|
//bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0xF5), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data)
|
||||||
pUsb->ctrlReq(bAddress,epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL);
|
pUsb->ctrlReq(bAddress,epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL);
|
||||||
|
@ -433,10 +429,6 @@ void PS3BT::setBdaddr(uint8_t* BDADDR)
|
||||||
}
|
}
|
||||||
void PS3BT::setMoveBdaddr(uint8_t* BDADDR)
|
void PS3BT::setMoveBdaddr(uint8_t* BDADDR)
|
||||||
{
|
{
|
||||||
/* Store the bluetooth address */
|
|
||||||
for(uint8_t i = 0; i <6;i++)
|
|
||||||
my_bdaddr[i] = BDADDR[i];
|
|
||||||
|
|
||||||
/* Set the internal bluetooth address */
|
/* Set the internal bluetooth address */
|
||||||
uint8_t buf[11];
|
uint8_t buf[11];
|
||||||
buf[0] = 0x05;
|
buf[0] = 0x05;
|
||||||
|
@ -446,7 +438,7 @@ void PS3BT::setMoveBdaddr(uint8_t* BDADDR)
|
||||||
buf[10] = 0x12;
|
buf[10] = 0x12;
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 6; i++)
|
for (uint8_t i = 0; i < 6; i++)
|
||||||
buf[i + 1] = my_bdaddr[i];
|
buf[i + 1] = BDADDR[i];
|
||||||
|
|
||||||
//bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x05), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data)
|
//bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x05), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data)
|
||||||
pUsb->ctrlReq(bAddress,epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x05, 0x03, 0x00,11,11, buf, NULL);
|
pUsb->ctrlReq(bAddress,epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x05, 0x03, 0x00,11,11, buf, NULL);
|
||||||
|
@ -1591,19 +1583,17 @@ void PS3BT::setRumbleOn(Rumble mode)
|
||||||
}
|
}
|
||||||
void PS3BT::setLedOff(LED a)
|
void PS3BT::setLedOff(LED a)
|
||||||
{
|
{
|
||||||
//check if LED is already off
|
HIDBuffer[11] &= ~((uint8_t)(((uint16_t)a & 0x0f) << 1));
|
||||||
if ((uint8_t)((uint8_t)(((uint16_t)a << 1) & HIDBuffer[11])) != 0)
|
HID_Command(HIDBuffer, HID_BUFFERSIZE);
|
||||||
{
|
|
||||||
//set the LED into the write buffer
|
|
||||||
HIDBuffer[11] = (uint8_t)((uint8_t)(((uint16_t)a & 0x0f) << 1) ^ HIDBuffer[11]);
|
|
||||||
|
|
||||||
HID_Command(HIDBuffer, HID_BUFFERSIZE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void PS3BT::setLedOn(LED a)
|
void PS3BT::setLedOn(LED a)
|
||||||
{
|
{
|
||||||
HIDBuffer[11] = (uint8_t)((uint8_t)(((uint16_t)a & 0x0f) << 1) | HIDBuffer[11]);
|
HIDBuffer[11] |= (uint8_t)(((uint16_t)a & 0x0f) << 1);
|
||||||
|
HID_Command(HIDBuffer, HID_BUFFERSIZE);
|
||||||
|
}
|
||||||
|
void PS3BT::setLedToggle(LED a)
|
||||||
|
{
|
||||||
|
HIDBuffer[11] ^= (uint8_t)(((uint16_t)a & 0x0f) << 1);
|
||||||
HID_Command(HIDBuffer, HID_BUFFERSIZE);
|
HID_Command(HIDBuffer, HID_BUFFERSIZE);
|
||||||
}
|
}
|
||||||
void PS3BT::enable_sixaxis()//Command used to enable the Dualshock 3 and Navigation controller to send data via USB
|
void PS3BT::enable_sixaxis()//Command used to enable the Dualshock 3 and Navigation controller to send data via USB
|
||||||
|
|
1
PS3BT.h
1
PS3BT.h
|
@ -352,6 +352,7 @@ public:
|
||||||
void setRumbleOn(Rumble mode);
|
void setRumbleOn(Rumble mode);
|
||||||
void setLedOff(LED a);
|
void setLedOff(LED a);
|
||||||
void setLedOn(LED a);
|
void setLedOn(LED a);
|
||||||
|
void setLedToggle(LED a);
|
||||||
/* Commands for Motion controller only */
|
/* Commands for Motion controller only */
|
||||||
void moveSetBulb(uint8_t r, uint8_t g, uint8_t b);//Use this to set the Color using RGB values
|
void moveSetBulb(uint8_t r, uint8_t g, uint8_t b);//Use this to set the Color using RGB values
|
||||||
void moveSetBulb(Colors color);//Use this to set the Color using the predefined colors in "enum Colors"
|
void moveSetBulb(Colors color);//Use this to set the Color using the predefined colors in "enum Colors"
|
||||||
|
|
|
@ -28,6 +28,7 @@ setRumbleOff KEYWORD2
|
||||||
setRumbleOn KEYWORD2
|
setRumbleOn KEYWORD2
|
||||||
setLedOff KEYWORD2
|
setLedOff KEYWORD2
|
||||||
setLedOn KEYWORD2
|
setLedOn KEYWORD2
|
||||||
|
setLedToggle KEYWORD2
|
||||||
moveSetBulb KEYWORD2
|
moveSetBulb KEYWORD2
|
||||||
moveSetRumble KEYWORD2
|
moveSetRumble KEYWORD2
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue