diff --git a/bluetooth-mitm/source/controllers/emulated_switch_controller.cpp b/bluetooth-mitm/source/controllers/emulated_switch_controller.cpp index 4df2afc..0848328 100644 --- a/bluetooth-mitm/source/controllers/emulated_switch_controller.cpp +++ b/bluetooth-mitm/source/controllers/emulated_switch_controller.cpp @@ -26,11 +26,15 @@ namespace ams::controller { : SwitchController(address) , m_charging(false) , m_battery(BATTERY_MAX) { + this->ClearControllerState(); + }; + + void EmulatedSwitchController::ClearControllerState(void) { std::memset(&m_buttons, 0, sizeof(m_buttons)); this->PackStickData(&m_left_stick, STICK_ZERO, STICK_ZERO); this->PackStickData(&m_right_stick, STICK_ZERO, STICK_ZERO); std::memset(&m_motion_data, 0, sizeof(m_motion_data)); - }; + } Result EmulatedSwitchController::HandleIncomingReport(const bluetooth::HidReport *report) { // Update controller state diff --git a/bluetooth-mitm/source/controllers/emulated_switch_controller.hpp b/bluetooth-mitm/source/controllers/emulated_switch_controller.hpp index 7c896d0..fd4a546 100644 --- a/bluetooth-mitm/source/controllers/emulated_switch_controller.hpp +++ b/bluetooth-mitm/source/controllers/emulated_switch_controller.hpp @@ -29,6 +29,7 @@ namespace ams::controller { protected: virtual void UpdateControllerState(const bluetooth::HidReport *report) {}; + void ClearControllerState(void); virtual Result SetVibration(void) { return ams::ResultSuccess(); }; virtual Result SetPlayerLed(uint8_t led_mask) { return ams::ResultSuccess(); }; diff --git a/bluetooth-mitm/source/controllers/wii_controller.cpp b/bluetooth-mitm/source/controllers/wii_controller.cpp index b38d0cc..ff46ba2 100644 --- a/bluetooth-mitm/source/controllers/wii_controller.cpp +++ b/bluetooth-mitm/source/controllers/wii_controller.cpp @@ -89,7 +89,6 @@ namespace ams::controller { void WiiController::HandleInputReport0x21(const WiiReportData *src) { uint16_t read_addr = util::SwapBytes(src->input0x21.address); - //uint8_t size = src->input0x21.size + 1; if (read_addr == 0x00fa) { // Identify extension controller by ID @@ -123,6 +122,8 @@ namespace ams::controller { break; } } + + this->ClearControllerState(); } void WiiController::HandleInputReport0x22(const WiiReportData *src) {