Merge pull request #251 from felis/issue234

Keep reading the IR camera as well if an extension disconnects
This commit is contained in:
Kristian Sloth Lauszus 2016-07-31 16:04:01 +02:00 committed by GitHub
commit 7b0396c1a0

13
Wii.cpp
View file

@ -327,11 +327,18 @@ void WII::ACLData(uint8_t* l2capinbuf) {
nunchuckConnected = false; // It must be the Nunchuck controller then nunchuckConnected = false; // It must be the Nunchuck controller then
wii_clear_flag(WII_FLAG_NUNCHUCK_CONNECTED); wii_clear_flag(WII_FLAG_NUNCHUCK_CONNECTED);
onInit(); onInit();
#ifdef WIICAMERA
if(!isIRCameraEnabled()) // We still want to read from the IR camera, so do not change the report mode
#endif
setReportMode(false, 0x31); // If there is no extension connected we will read the buttons and accelerometer setReportMode(false, 0x31); // If there is no extension connected we will read the buttons and accelerometer
} else } else {
#ifdef WIICAMERA
if(!isIRCameraEnabled()) // We still want to read from the IR camera, so do not change the report mode
#endif
setReportMode(false, 0x31); // If there is no extension connected we will read the buttons and accelerometer setReportMode(false, 0x31); // If there is no extension connected we will read the buttons and accelerometer
} }
} }
}
else { else {
#ifdef EXTRADEBUG #ifdef EXTRADEBUG
Notify(PSTR("\r\nChecking battery level"), 0x80); Notify(PSTR("\r\nChecking battery level"), 0x80);
@ -965,6 +972,10 @@ uint8_t WII::getBatteryLevel() {
}; };
void WII::setReportMode(bool continuous, uint8_t mode) { void WII::setReportMode(bool continuous, uint8_t mode) {
#ifdef EXTRADEBUG
Notify(PSTR("\r\nReport mode was changed to: "), 0x80);
D_PrintHex<uint8_t > (mode, 0x80);
#endif
uint8_t cmd_buf[4]; uint8_t cmd_buf[4];
cmd_buf[0] = 0xA2; // HID BT DATA_request (0xA0) | Report Type (Output 0x02) cmd_buf[0] = 0xA2; // HID BT DATA_request (0xA0) | Report Type (Output 0x02)
cmd_buf[1] = 0x12; cmd_buf[1] = 0x12;