Merge pull request #8548 from jordan-woyak/wiimote-source-cleanup

Core/WiimoteReal: Wii remote connection pool and source change cleanup.
This commit is contained in:
Tilka
2020-01-25 23:04:50 +00:00
committed by GitHub
11 changed files with 181 additions and 105 deletions

View File

@ -489,11 +489,13 @@ void ControllersWindow::LoadSettings()
m_gc_controller_boxes[i]->setCurrentIndex(*gc_index);
m_gc_buttons[i]->setEnabled(*gc_index != 0 && *gc_index != 6);
}
m_wiimote_boxes[i]->setCurrentIndex(g_wiimote_sources[i]);
m_wiimote_buttons[i]->setEnabled(g_wiimote_sources[i] != 0 && g_wiimote_sources[i] != 2);
const WiimoteSource source = WiimoteCommon::GetSource(int(i));
m_wiimote_boxes[i]->setCurrentIndex(int(source));
m_wiimote_buttons[i]->setEnabled(source == WiimoteSource::Emulated);
}
m_wiimote_real_balance_board->setChecked(g_wiimote_sources[WIIMOTE_BALANCE_BOARD] ==
WIIMOTE_SRC_REAL);
m_wiimote_real_balance_board->setChecked(WiimoteCommon::GetSource(WIIMOTE_BALANCE_BOARD) ==
WiimoteSource::Real);
m_wiimote_speaker_data->setChecked(SConfig::GetInstance().m_WiimoteEnableSpeaker);
m_wiimote_continuous_scanning->setChecked(SConfig::GetInstance().m_WiimoteContinuousScanning);
@ -514,15 +516,15 @@ void ControllersWindow::SaveSettings()
SConfig::GetInstance().m_bt_passthrough_enabled = m_wiimote_passthrough->isChecked();
SConfig::GetInstance().m_BackgroundInput = m_common_bg_input->isChecked();
WiimoteReal::ChangeWiimoteSource(WIIMOTE_BALANCE_BOARD,
m_wiimote_real_balance_board->isChecked() ? WIIMOTE_SRC_REAL :
WIIMOTE_SRC_NONE);
WiimoteCommon::SetSource(WIIMOTE_BALANCE_BOARD, m_wiimote_real_balance_board->isChecked() ?
WiimoteSource::Real :
WiimoteSource::None);
for (size_t i = 0; i < m_wiimote_groups.size(); i++)
{
const int index = m_wiimote_boxes[i]->currentIndex();
m_wiimote_buttons[i]->setEnabled(index != 0 && index != 2);
WiimoteReal::ChangeWiimoteSource(static_cast<u32>(i), index);
const auto source = WiimoteSource(m_wiimote_boxes[i]->currentIndex());
m_wiimote_buttons[i]->setEnabled(source == WiimoteSource::Emulated);
WiimoteCommon::SetSource(static_cast<u32>(i), source);
}
UICommon::SaveWiimoteSources();

View File

@ -115,6 +115,8 @@
#if defined(HAVE_XRANDR) && HAVE_XRANDR
#include "UICommon/X11Utils.h"
// This #define within X11/X.h conflicts with our WiimoteSource enum.
#undef None
#endif
#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
@ -1593,7 +1595,7 @@ void MainWindow::OnStartRecording()
if (SerialInterface::SIDevice_IsGCController(SConfig::GetInstance().m_SIDevice[i]))
controllers |= (1 << i);
if (g_wiimote_sources[i] != WIIMOTE_SRC_NONE)
if (WiimoteCommon::GetSource(i) != WiimoteSource::None)
controllers |= (1 << (i + 4));
}
@ -1660,7 +1662,7 @@ void MainWindow::ShowTASInput()
for (int i = 0; i < num_wii_controllers; i++)
{
if (g_wiimote_sources[i] == WIIMOTE_SRC_EMU &&
if (WiimoteCommon::GetSource(i) == WiimoteSource::Emulated &&
(!Core::IsRunning() || SConfig::GetInstance().bWii))
{
m_wii_tas_input_windows[i]->show();