Keep reading the IR camera as well if an extension disconnects

Fixes #234

Also added some debugging code, so this could be detected faster in the future
This commit is contained in:
Kristian Sloth Lauszus 2016-07-02 19:42:32 +02:00
parent 2295571e2d
commit ce7f62e8d9

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;