Can now disconnect a wireless controller

This commit is contained in:
Kristian Lauszus 2013-11-11 00:43:18 +01:00
parent 52858d502b
commit 764e74c94c
3 changed files with 18 additions and 1 deletions

View file

@ -494,6 +494,15 @@ void XBOXRECV::XboxCommand(uint8_t controller, uint8_t* data, uint16_t nbytes) {
#endif #endif
} }
void XBOXRECV::disconnect(uint8_t controller) {
writeBuf[0] = 0x00;
writeBuf[1] = 0x00;
writeBuf[2] = 0x08;
writeBuf[3] = 0xC0;
XboxCommand(controller, writeBuf, 4);
}
void XBOXRECV::setLedRaw(uint8_t value, uint8_t controller) { void XBOXRECV::setLedRaw(uint8_t value, uint8_t controller) {
writeBuf[0] = 0x00; writeBuf[0] = 0x00;
writeBuf[1] = 0x00; writeBuf[1] = 0x00;

View file

@ -144,6 +144,12 @@ public:
*/ */
int16_t getAnalogHat(AnalogHat a, uint8_t controller = 0); int16_t getAnalogHat(AnalogHat a, uint8_t controller = 0);
/**
* Used to disconnect any of the controllers.
* @param controller The controller to disconnect. Default to 0.
*/
void disconnect(uint8_t controller = 0);
/** /**
* Turn rumble off and all the LEDs on the specific controller. * Turn rumble off and all the LEDs on the specific controller.
* @param controller The controller to write to. Default to 0. * @param controller The controller to write to. Default to 0.

View file

@ -94,8 +94,10 @@ void loop() {
Serial.print(Xbox.getBatteryLevel(i)); // The battery level in the range 0-3 Serial.print(Xbox.getBatteryLevel(i)); // The battery level in the range 0-3
Serial.println(F(")")); Serial.println(F(")"));
} }
if(Xbox.getButtonClick(SYNC,i)) if (Xbox.getButtonClick(SYNC, i)) {
Serial.println(F("Sync")); Serial.println(F("Sync"));
Xbox.disconnect(i);
}
if (Xbox.getButtonClick(A, i)) if (Xbox.getButtonClick(A, i))
Serial.println(F("A")); Serial.println(F("A"));