mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Can now disconnect a wireless controller
This commit is contained in:
parent
52858d502b
commit
764e74c94c
3 changed files with 18 additions and 1 deletions
|
@ -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;
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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"));
|
||||||
|
|
Loading…
Reference in a new issue