Merge branch 'master' into Zero

Conflicts:
	examples/HID/USBHIDBootMouse/USBHIDBootMouse.ino
This commit is contained in:
Kristian Sloth Lauszus 2016-01-20 16:39:55 +01:00
commit 38db5513bf
8 changed files with 45 additions and 35 deletions

View file

@ -528,12 +528,13 @@ void PS3BT::setAllOff() {
} }
void PS3BT::setRumbleOff() { void PS3BT::setRumbleOff() {
HIDBuffer[3] = 0x00; uint8_t rumbleBuf[HID_BUFFERSIZE];
HIDBuffer[4] = 0x00; memcpy(rumbleBuf, HIDBuffer, HID_BUFFERSIZE);
HIDBuffer[5] = 0x00; rumbleBuf[3] = 0x00;
HIDBuffer[6] = 0x00; rumbleBuf[4] = 0x00;
rumbleBuf[5] = 0x00;
HID_Command(HIDBuffer, HID_BUFFERSIZE); rumbleBuf[6] = 0x00;
HID_Command(rumbleBuf, HID_BUFFERSIZE);
} }
void PS3BT::setRumbleOn(RumbleEnum mode) { void PS3BT::setRumbleOn(RumbleEnum mode) {
@ -546,11 +547,13 @@ void PS3BT::setRumbleOn(RumbleEnum mode) {
} }
void PS3BT::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) { void PS3BT::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) {
HIDBuffer[3] = rightDuration; uint8_t rumbleBuf[HID_BUFFERSIZE];
HIDBuffer[4] = rightPower; memcpy(rumbleBuf, HIDBuffer, HID_BUFFERSIZE);
HIDBuffer[5] = leftDuration; rumbleBuf[3] = rightDuration;
HIDBuffer[6] = leftPower; rumbleBuf[4] = rightPower;
HID_Command(HIDBuffer, HID_BUFFERSIZE); rumbleBuf[5] = leftDuration;
rumbleBuf[6] = leftPower;
HID_Command(rumbleBuf, HID_BUFFERSIZE);
} }
void PS3BT::setLedRaw(uint8_t value) { void PS3BT::setLedRaw(uint8_t value) {

View file

@ -408,12 +408,13 @@ void PS3USB::setAllOff() {
} }
void PS3USB::setRumbleOff() { void PS3USB::setRumbleOff() {
writeBuf[1] = 0x00; uint8_t rumbleBuf[EP_MAXPKTSIZE];
writeBuf[2] = 0x00; // Low mode off memcpy(rumbleBuf, writeBuf, EP_MAXPKTSIZE);
writeBuf[3] = 0x00; rumbleBuf[1] = 0x00;
writeBuf[4] = 0x00; // High mode off rumbleBuf[2] = 0x00; // Low mode off
rumbleBuf[3] = 0x00;
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE); rumbleBuf[4] = 0x00; // High mode off
PS3_Command(rumbleBuf, PS3_REPORT_BUFFER_SIZE);
} }
void PS3USB::setRumbleOn(RumbleEnum mode) { void PS3USB::setRumbleOn(RumbleEnum mode) {
@ -428,11 +429,13 @@ void PS3USB::setRumbleOn(RumbleEnum mode) {
} }
void PS3USB::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) { void PS3USB::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) {
writeBuf[1] = rightDuration; uint8_t rumbleBuf[EP_MAXPKTSIZE];
writeBuf[2] = rightPower; memcpy(rumbleBuf, writeBuf, EP_MAXPKTSIZE);
writeBuf[3] = leftDuration; rumbleBuf[1] = rightDuration;
writeBuf[4] = leftPower; rumbleBuf[2] = rightPower;
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE); rumbleBuf[3] = leftDuration;
rumbleBuf[4] = leftPower;
PS3_Command(rumbleBuf, PS3_REPORT_BUFFER_SIZE);
} }
void PS3USB::setLedRaw(uint8_t value) { void PS3USB::setLedRaw(uint8_t value) {

View file

@ -40,8 +40,8 @@ void setup() {
while (1); // Halt while (1); // Halt
} }
bthid.SetReportParser(KEYBOARD_PARSER_ID, (HIDReportParser*)&keyboardPrs); bthid.SetReportParser(KEYBOARD_PARSER_ID, &keyboardPrs);
bthid.SetReportParser(MOUSE_PARSER_ID, (HIDReportParser*)&mousePrs); bthid.SetReportParser(MOUSE_PARSER_ID, &mousePrs);
// If "Boot Protocol Mode" does not work, then try "Report Protocol Mode" // If "Boot Protocol Mode" does not work, then try "Report Protocol Mode"
// If that does not work either, then uncomment PRINTREPORT in BTHID.cpp to see the raw report // If that does not work either, then uncomment PRINTREPORT in BTHID.cpp to see the raw report

View file

@ -21,8 +21,7 @@ BTD Btd(&usb); // You have to create the Bluetooth Dongle instance like so
PS3BT PS3(&Btd); // This will just create the instance PS3BT PS3(&Btd); // This will just create the instance
//PS3BT PS3(&Btd, 0x00, 0x15, 0x83, 0x3D, 0x0A, 0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch //PS3BT PS3(&Btd, 0x00, 0x15, 0x83, 0x3D, 0x0A, 0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch
bool printTemperature; bool printTemperature, printAngle;
bool printAngle;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
@ -61,15 +60,20 @@ void loop() {
Serial.print(PS3.getAnalogButton(R2)); Serial.print(PS3.getAnalogButton(R2));
} }
} }
if (PS3.getButtonClick(PS)) { if (PS3.getButtonClick(PS)) {
Serial.print(F("\r\nPS")); Serial.print(F("\r\nPS"));
PS3.disconnect(); PS3.disconnect();
} }
else { else {
if (PS3.getButtonClick(TRIANGLE)) if (PS3.getButtonClick(TRIANGLE)) {
Serial.print(F("\r\nTraingle")); Serial.print(F("\r\nTraingle"));
if (PS3.getButtonClick(CIRCLE)) PS3.setRumbleOn(RumbleLow);
}
if (PS3.getButtonClick(CIRCLE)) {
Serial.print(F("\r\nCircle")); Serial.print(F("\r\nCircle"));
PS3.setRumbleOn(RumbleHigh);
}
if (PS3.getButtonClick(CROSS)) if (PS3.getButtonClick(CROSS))
Serial.print(F("\r\nCross")); Serial.print(F("\r\nCross"));
if (PS3.getButtonClick(SQUARE)) if (PS3.getButtonClick(SQUARE))

View file

@ -119,7 +119,7 @@ void setup()
next_time = millis() + 5000; next_time = millis() + 5000;
HidKeyboard.SetReportParser(0, (HIDReportParser*)&Prs); HidKeyboard.SetReportParser(0, &Prs);
} }
void loop() void loop()

View file

@ -165,10 +165,10 @@ void setup()
//next_time = millis() + 5000; //next_time = millis() + 5000;
HidComposite.SetReportParser(0, (HIDReportParser*)&KbdPrs); HidComposite.SetReportParser(0, &KbdPrs);
HidComposite.SetReportParser(1, (HIDReportParser*)&MousePrs); HidComposite.SetReportParser(1, &MousePrs);
HidKeyboard.SetReportParser(0, (HIDReportParser*)&KbdPrs); HidKeyboard.SetReportParser(0, &KbdPrs);
HidMouse.SetReportParser(0, (HIDReportParser*)&MousePrs); HidMouse.SetReportParser(0, &MousePrs);
} }
void loop() void loop()

View file

@ -73,7 +73,7 @@ void setup()
next_time = millis() + 5000; next_time = millis() + 5000;
HidMouse.SetReportParser(0, (HIDReportParser*)&Prs); HidMouse.SetReportParser(0, &Prs);
} }
void loop() void loop()

View file

@ -80,7 +80,7 @@ void setup()
while (1); //halt while (1); //halt
}//if (usb.Init() == -1... }//if (usb.Init() == -1...
HidKeyboard.SetReportParser(0, (HIDReportParser*)&Prs); HidKeyboard.SetReportParser(0, &Prs);
delay( 200 ); delay( 200 );
} }