mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-31 01:59:52 -06:00
Merge pull request #2330 from mathieui/background-gc-adapter-scan
Add a background thread to detect the GC adapter
This commit is contained in:
@ -52,6 +52,8 @@ const std::array<wxString, 8> ControllerConfigDiag::m_gc_pad_type_strs = {{
|
||||
_("AM-Baseboard")
|
||||
}};
|
||||
|
||||
wxDEFINE_EVENT(wxEVT_ADAPTER_UPDATE, wxCommandEvent);
|
||||
|
||||
ControllerConfigDiag::ControllerConfigDiag(wxWindow* const parent)
|
||||
: wxDialog(parent, wxID_ANY, _("Dolphin Controller Configuration"))
|
||||
{
|
||||
@ -71,6 +73,7 @@ ControllerConfigDiag::ControllerConfigDiag(wxWindow* const parent)
|
||||
SetLayoutAdaptationMode(wxDIALOG_ADAPTATION_MODE_ENABLED);
|
||||
SetSizerAndFit(main_sizer);
|
||||
Center();
|
||||
Bind(wxEVT_ADAPTER_UPDATE, &ControllerConfigDiag::UpdateAdapter, this);
|
||||
}
|
||||
|
||||
wxStaticBoxSizer* ControllerConfigDiag::CreateGamecubeSizer()
|
||||
@ -147,39 +150,64 @@ wxStaticBoxSizer* ControllerConfigDiag::CreateGamecubeSizer()
|
||||
gamecube_static_sizer->Add(gamecube_flex_sizer, 1, wxEXPAND, 5);
|
||||
gamecube_static_sizer->AddSpacer(5);
|
||||
|
||||
wxStaticBoxSizer* const gamecube_adapter_group = new wxStaticBoxSizer(wxHORIZONTAL, this, _("GameCube Adapter"));
|
||||
wxStaticBoxSizer* const gamecube_adapter_group = new wxStaticBoxSizer(wxVERTICAL, this, _("GameCube Adapter"));
|
||||
wxBoxSizer* const gamecube_adapter_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
wxCheckBox* const gamecube_adapter = new wxCheckBox(this, wxID_ANY, _("Direct Connect"));
|
||||
gamecube_adapter->Bind(wxEVT_CHECKBOX, &ControllerConfigDiag::OnGameCubeAdapter, this);
|
||||
|
||||
wxCheckBox* const gamecube_rumble = new wxCheckBox(this, wxID_ANY, _("Rumble"));
|
||||
gamecube_rumble->SetValue(SConfig::GetInstance().m_AdapterRumble);
|
||||
gamecube_rumble->Bind(wxEVT_CHECKBOX, &ControllerConfigDiag::OnAdapterRumble, this);
|
||||
|
||||
m_adapter_status = new wxStaticText(this, wxID_ANY, _("Adapter Not Detected"));
|
||||
|
||||
gamecube_adapter_group->Add(m_adapter_status, 0, wxEXPAND);
|
||||
gamecube_adapter_sizer->Add(gamecube_adapter, 0, wxEXPAND);
|
||||
gamecube_adapter_sizer->Add(gamecube_rumble, 0, wxEXPAND);
|
||||
gamecube_adapter_group->Add(gamecube_adapter_sizer, 0, wxEXPAND);
|
||||
gamecube_static_sizer->Add(gamecube_adapter_group, 0, wxEXPAND);
|
||||
|
||||
#if defined(__LIBUSB__) || defined (_WIN32)
|
||||
gamecube_adapter->SetValue(SConfig::GetInstance().m_GameCubeAdapter);
|
||||
if (!SI_GCAdapter::IsDetected())
|
||||
{
|
||||
if (!SI_GCAdapter::IsDriverDetected())
|
||||
gamecube_adapter->SetLabelText(_("Driver Not Detected"));
|
||||
else
|
||||
gamecube_adapter->SetLabelText(_("Adapter Not Detected"));
|
||||
gamecube_adapter->SetValue(false);
|
||||
gamecube_adapter->Disable();
|
||||
{
|
||||
m_adapter_status->SetLabelText(_("Driver Not Detected"));
|
||||
gamecube_adapter->Disable();
|
||||
gamecube_adapter->SetValue(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gamecube_adapter->SetValue(SConfig::GetInstance().m_GameCubeAdapter);
|
||||
if (Core::GetState() != Core::CORE_UNINITIALIZED)
|
||||
{
|
||||
gamecube_adapter->Disable();
|
||||
}
|
||||
m_adapter_status->SetLabelText(_("Adapter Detected"));
|
||||
}
|
||||
if (Core::GetState() != Core::CORE_UNINITIALIZED)
|
||||
{
|
||||
gamecube_adapter->Disable();
|
||||
}
|
||||
SI_GCAdapter::SetAdapterCallback(std::bind(&ControllerConfigDiag::ScheduleAdapterUpdate, this));
|
||||
#endif
|
||||
|
||||
return gamecube_static_sizer;
|
||||
}
|
||||
|
||||
void ControllerConfigDiag::ScheduleAdapterUpdate()
|
||||
{
|
||||
wxQueueEvent(this, new wxCommandEvent(wxEVT_ADAPTER_UPDATE));
|
||||
}
|
||||
|
||||
void ControllerConfigDiag::UpdateAdapter(wxCommandEvent& ev)
|
||||
{
|
||||
bool unpause = Core::PauseAndLock(true);
|
||||
if (SI_GCAdapter::IsDetected())
|
||||
m_adapter_status->SetLabelText(_("Adapter Detected"));
|
||||
else
|
||||
m_adapter_status->SetLabelText(_("Adapter Not Detected"));
|
||||
Core::PauseAndLock(false, unpause);
|
||||
}
|
||||
|
||||
wxStaticBoxSizer* ControllerConfigDiag::CreateWiimoteConfigSizer()
|
||||
{
|
||||
wxStaticText* wiimote_label[4];
|
||||
@ -537,3 +565,8 @@ void ControllerConfigDiag::OnGameCubeConfigButton(wxCommandEvent& event)
|
||||
|
||||
HotkeyManagerEmu::Enable(true);
|
||||
}
|
||||
|
||||
ControllerConfigDiag::~ControllerConfigDiag()
|
||||
{
|
||||
SI_GCAdapter::SetAdapterCallback(nullptr);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "Common/SysConf.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/HW/SI_GCAdapter.h"
|
||||
#include "Core/HW/Wiimote.h"
|
||||
|
||||
class InputConfig;
|
||||
@ -19,6 +20,7 @@ class ControllerConfigDiag : public wxDialog
|
||||
{
|
||||
public:
|
||||
ControllerConfigDiag(wxWindow* const parent);
|
||||
~ControllerConfigDiag();
|
||||
|
||||
private:
|
||||
void RefreshRealWiimotes(wxCommandEvent& event);
|
||||
@ -72,6 +74,11 @@ private:
|
||||
SConfig::GetInstance().m_GameCubeAdapter = event.IsChecked();
|
||||
event.Skip();
|
||||
}
|
||||
void OnAdapterRumble(wxCommandEvent& event)
|
||||
{
|
||||
SConfig::GetInstance().m_AdapterRumble = event.IsChecked();
|
||||
}
|
||||
|
||||
|
||||
wxStaticBoxSizer* CreateGamecubeSizer();
|
||||
wxStaticBoxSizer* CreateWiimoteConfigSizer();
|
||||
@ -82,6 +89,8 @@ private:
|
||||
void Cancel(wxCommandEvent& event);
|
||||
void OnGameCubePortChanged(wxCommandEvent& event);
|
||||
void OnGameCubeConfigButton(wxCommandEvent& event);
|
||||
void ScheduleAdapterUpdate();
|
||||
void UpdateAdapter(wxCommandEvent& ev);
|
||||
|
||||
std::map<wxWindowID, unsigned int> m_gc_port_choice_ids;
|
||||
std::map<wxWindowID, unsigned int> m_gc_port_config_ids;
|
||||
@ -90,6 +99,7 @@ private:
|
||||
std::map<wxWindowID, unsigned int> m_wiimote_index_from_ctrl_id;
|
||||
unsigned int m_orig_wiimote_sources[MAX_BBMOTES];
|
||||
|
||||
wxStaticText* m_adapter_status;
|
||||
wxButton* wiimote_configure_bt[MAX_WIIMOTES];
|
||||
wxButton* gamecube_configure_bt[4];
|
||||
std::map<wxWindowID, unsigned int> m_wiimote_index_from_conf_bt_id;
|
||||
|
Reference in New Issue
Block a user