bluetooth-mitm: clear controller state when wii controller extension state changes

This commit is contained in:
ndeadly 2020-10-03 17:50:07 +02:00
parent b21806c8c5
commit 5db4f38d25
3 changed files with 8 additions and 2 deletions

View file

@ -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

View file

@ -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(); };

View file

@ -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) {