mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Added setLedStatus()
This will give some feedback to the user about which extensions is currently connected
This commit is contained in:
parent
70eaa7732c
commit
02719f4c92
2 changed files with 16 additions and 1 deletions
16
Wii.cpp
16
Wii.cpp
|
@ -219,6 +219,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
#endif
|
#endif
|
||||||
nunchuckConnected = false; // It must be the Nunchuck controller then
|
nunchuckConnected = false; // It must be the Nunchuck controller then
|
||||||
l2cap_event_flag &= ~WII_FLAG_NUNCHUCK_CONNECTED;
|
l2cap_event_flag &= ~WII_FLAG_NUNCHUCK_CONNECTED;
|
||||||
|
setLedStatus();
|
||||||
setReportMode(false,0x31); // If there is no extension connected we will read the button and accelerometer
|
setReportMode(false,0x31); // If there is no extension connected we will read the button and accelerometer
|
||||||
} else {
|
} else {
|
||||||
setReportMode(false,0x31); // If there is no extension connected we will read the button and accelerometer
|
setReportMode(false,0x31); // If there is no extension connected we will read the button and accelerometer
|
||||||
|
@ -569,7 +570,7 @@ void WII::Run() {
|
||||||
case L2CAP_LED_STATE:
|
case L2CAP_LED_STATE:
|
||||||
if(nunchuck_connected_flag)
|
if(nunchuck_connected_flag)
|
||||||
nunchuckConnected = true;
|
nunchuckConnected = true;
|
||||||
setLedOn(LED1);
|
setLedStatus();
|
||||||
l2cap_state = L2CAP_DONE;
|
l2cap_state = L2CAP_DONE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -616,6 +617,7 @@ void WII::Run() {
|
||||||
else if(stateCounter == 400)
|
else if(stateCounter == 400)
|
||||||
readExtensionType(); // Check if it has been activated
|
readExtensionType(); // Check if it has been activated
|
||||||
else if(stateCounter == 450) {
|
else if(stateCounter == 450) {
|
||||||
|
setLedStatus();
|
||||||
stateCounter = 0;
|
stateCounter = 0;
|
||||||
unknownExtensionConnected = false;
|
unknownExtensionConnected = false;
|
||||||
}
|
}
|
||||||
|
@ -670,6 +672,18 @@ void WII::setLedToggle(LED a) {
|
||||||
HIDBuffer[2] ^= (uint8_t)a;
|
HIDBuffer[2] ^= (uint8_t)a;
|
||||||
HID_Command(HIDBuffer, 3);
|
HID_Command(HIDBuffer, 3);
|
||||||
}
|
}
|
||||||
|
void WII::setLedStatus() {
|
||||||
|
HIDBuffer[1] = 0x11;
|
||||||
|
HIDBuffer[2] = 0;
|
||||||
|
if(wiimoteConnected)
|
||||||
|
HIDBuffer[2] |= 0x10; // If it's connected LED1 will light up
|
||||||
|
if(motionPlusConnected)
|
||||||
|
HIDBuffer[2] |= 0x20; // If it's connected LED2 will light up
|
||||||
|
if(nunchuckConnected)
|
||||||
|
HIDBuffer[2] |= 0x40; // If it's connected LED3 will light up
|
||||||
|
|
||||||
|
HID_Command(HIDBuffer, 3);
|
||||||
|
}
|
||||||
void WII::setReportMode(bool continuous, uint8_t mode) {
|
void WII::setReportMode(bool continuous, uint8_t mode) {
|
||||||
uint8_t cmd_buf[4];
|
uint8_t cmd_buf[4];
|
||||||
cmd_buf[0] = 0xA2; // HID BT DATA_request (0x50) | Report Type (Output 0x02)
|
cmd_buf[0] = 0xA2; // HID BT DATA_request (0x50) | Report Type (Output 0x02)
|
||||||
|
|
1
Wii.h
1
Wii.h
|
@ -127,6 +127,7 @@ public:
|
||||||
void setLedOff(LED a);
|
void setLedOff(LED a);
|
||||||
void setLedOn(LED a);
|
void setLedOn(LED a);
|
||||||
void setLedToggle(LED a);
|
void setLedToggle(LED a);
|
||||||
|
void setLedStatus(); // This will set the LEDs, so the user can see which connections are active
|
||||||
|
|
||||||
bool wiimoteConnected; // Variable used to indicate if a Wiimote is connected
|
bool wiimoteConnected; // Variable used to indicate if a Wiimote is connected
|
||||||
bool nunchuckConnected; // Variable used to indicate if a Nunchuck controller is connected
|
bool nunchuckConnected; // Variable used to indicate if a Nunchuck controller is connected
|
||||||
|
|
Loading…
Reference in a new issue