BTEmu: Add helper function for accessing WiimoteDevice instances by index

This makes it much more straightforward to access WiimoteDevice
instances and also keeps the implementation details of accessing those
instances in one spot.

Given as all external accesses to the WiimoteDevice instances go through
this function, we can make the other two private.
This commit is contained in:
Lioncash
2018-06-20 15:27:31 -04:00
parent e4b6d7626b
commit 7eb86cdb67
8 changed files with 45 additions and 29 deletions

View File

@ -914,14 +914,16 @@ void MenuBar::UpdateToolsMenu(bool emulation_started)
const auto bt = ios ? std::static_pointer_cast<IOS::HLE::Device::BluetoothEmu>(
ios->GetDeviceByName("/dev/usb/oh1/57e/305")) :
nullptr;
bool enable_wiimotes =
const bool enable_wiimotes =
emulation_started && bt && !SConfig::GetInstance().m_bt_passthrough_enabled;
for (int i = 0; i < 5; i++)
for (std::size_t i = 0; i < m_wii_remotes.size(); i++)
{
m_wii_remotes[i]->setEnabled(enable_wiimotes);
QAction* const wii_remote = m_wii_remotes[i];
wii_remote->setEnabled(enable_wiimotes);
if (enable_wiimotes)
m_wii_remotes[i]->setChecked(bt->AccessWiiMote(0x0100 + i)->IsConnected());
wii_remote->setChecked(bt->AccessWiiMoteByIndex(i)->IsConnected());
}
}