mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 09:09:52 -06:00
Move the Wiimote connect code out of Host
I don't know who thought it would be a good idea to put the Wiimote connect code as part of the Host interface, and have that called from both the UI code and the core. And then hack around it by having "force connect" events whenever Host_ConnectWiimote is called from the core...
This commit is contained in:
@ -817,22 +817,6 @@ void CFrame::OnHostMessage(wxCommandEvent& event)
|
||||
case IDM_STOPPED:
|
||||
OnStopped();
|
||||
break;
|
||||
|
||||
case IDM_FORCE_CONNECT_WIIMOTE1:
|
||||
case IDM_FORCE_CONNECT_WIIMOTE2:
|
||||
case IDM_FORCE_CONNECT_WIIMOTE3:
|
||||
case IDM_FORCE_CONNECT_WIIMOTE4:
|
||||
case IDM_FORCE_CONNECT_BALANCEBOARD:
|
||||
ConnectWiimote(event.GetId() - IDM_FORCE_CONNECT_WIIMOTE1, true);
|
||||
break;
|
||||
|
||||
case IDM_FORCE_DISCONNECT_WIIMOTE1:
|
||||
case IDM_FORCE_DISCONNECT_WIIMOTE2:
|
||||
case IDM_FORCE_DISCONNECT_WIIMOTE3:
|
||||
case IDM_FORCE_DISCONNECT_WIIMOTE4:
|
||||
case IDM_FORCE_DISCONNECT_BALANCEBOARD:
|
||||
ConnectWiimote(event.GetId() - IDM_FORCE_DISCONNECT_WIIMOTE1, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,6 @@ private:
|
||||
void OnStopped();
|
||||
void OnRenderWindowSizeRequest(int width, int height);
|
||||
void UpdateTitle(const wxString& str);
|
||||
static void ConnectWiimote(int wm_idx, bool connect);
|
||||
|
||||
// Event functions
|
||||
void PostEvent(wxCommandEvent& event);
|
||||
|
@ -1406,27 +1406,6 @@ void CFrame::OnFifoPlayer(wxCommandEvent& WXUNUSED(event))
|
||||
}
|
||||
}
|
||||
|
||||
void CFrame::ConnectWiimote(int wm_idx, bool connect)
|
||||
{
|
||||
if (Core::IsRunning() && SConfig::GetInstance().bWii &&
|
||||
!SConfig::GetInstance().m_bt_passthrough_enabled)
|
||||
{
|
||||
Core::RunAsCPUThread([&] {
|
||||
const auto ios = IOS::HLE::GetIOS();
|
||||
if (!ios)
|
||||
return;
|
||||
|
||||
const auto bt = std::static_pointer_cast<IOS::HLE::Device::BluetoothEmu>(
|
||||
ios->GetDeviceByName("/dev/usb/oh1/57e/305"));
|
||||
if (bt)
|
||||
bt->AccessWiiMote(wm_idx | 0x100)->Activate(connect);
|
||||
const char* message = connect ? "Wii Remote %i connected" : "Wii Remote %i disconnected";
|
||||
Core::DisplayMessage(StringFromFormat(message, wm_idx + 1), 3000);
|
||||
Host_UpdateMainFrame();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void CFrame::OnConnectWiimote(wxCommandEvent& event)
|
||||
{
|
||||
const auto ios = IOS::HLE::GetIOS();
|
||||
@ -1435,9 +1414,9 @@ void CFrame::OnConnectWiimote(wxCommandEvent& event)
|
||||
Core::RunAsCPUThread([&] {
|
||||
const auto bt = std::static_pointer_cast<IOS::HLE::Device::BluetoothEmu>(
|
||||
ios->GetDeviceByName("/dev/usb/oh1/57e/305"));
|
||||
const bool is_connected =
|
||||
bt && bt->AccessWiiMote((event.GetId() - IDM_CONNECT_WIIMOTE1) | 0x100)->IsConnected();
|
||||
ConnectWiimote(event.GetId() - IDM_CONNECT_WIIMOTE1, !is_connected);
|
||||
const unsigned int wiimote_index = event.GetId() - IDM_CONNECT_WIIMOTE1;
|
||||
const bool is_connected = bt && bt->AccessWiiMote(wiimote_index | 0x100)->IsConnected();
|
||||
Wiimote::Connect(wiimote_index, !is_connected);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -308,18 +308,6 @@ enum
|
||||
IDM_STOPPED,
|
||||
IDM_HOST_MESSAGE,
|
||||
|
||||
// Used for Host_ConnectWiimote()
|
||||
IDM_FORCE_CONNECT_WIIMOTE1,
|
||||
IDM_FORCE_CONNECT_WIIMOTE2,
|
||||
IDM_FORCE_CONNECT_WIIMOTE3,
|
||||
IDM_FORCE_CONNECT_WIIMOTE4,
|
||||
IDM_FORCE_CONNECT_BALANCEBOARD,
|
||||
IDM_FORCE_DISCONNECT_WIIMOTE1,
|
||||
IDM_FORCE_DISCONNECT_WIIMOTE2,
|
||||
IDM_FORCE_DISCONNECT_WIIMOTE3,
|
||||
IDM_FORCE_DISCONNECT_WIIMOTE4,
|
||||
IDM_FORCE_DISCONNECT_BALANCEBOARD,
|
||||
|
||||
IDM_MPANEL,
|
||||
ID_STATUSBAR,
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <OptionParser.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <wx/app.h>
|
||||
@ -70,8 +69,6 @@ std::string wxStringTranslator(const char*);
|
||||
|
||||
CFrame* main_frame = nullptr;
|
||||
|
||||
static std::mutex s_init_mutex;
|
||||
|
||||
bool DolphinApp::Initialize(int& c, wxChar** v)
|
||||
{
|
||||
#if defined HAVE_X11 && HAVE_X11
|
||||
@ -122,8 +119,6 @@ bool DolphinApp::OnInit()
|
||||
|
||||
ParseCommandLine();
|
||||
|
||||
std::lock_guard<std::mutex> lk(s_init_mutex);
|
||||
|
||||
UICommon::SetUserDirectory(m_user_path.ToStdString());
|
||||
UICommon::CreateDirectories();
|
||||
InitLanguageSupport(); // The language setting is loaded from the user directory
|
||||
@ -473,21 +468,6 @@ bool Host_RendererIsFullscreen()
|
||||
return main_frame->RendererIsFullscreen();
|
||||
}
|
||||
|
||||
void Host_ConnectWiimote(int wm_idx, bool connect)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(s_init_mutex);
|
||||
if (connect)
|
||||
{
|
||||
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_FORCE_CONNECT_WIIMOTE1 + wm_idx);
|
||||
main_frame->GetEventHandler()->AddPendingEvent(event);
|
||||
}
|
||||
else
|
||||
{
|
||||
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_FORCE_DISCONNECT_WIIMOTE1 + wm_idx);
|
||||
main_frame->GetEventHandler()->AddPendingEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void Host_ShowVideoConfig(void* parent, const std::string& backend_name)
|
||||
{
|
||||
wxWindow* const parent_window = static_cast<wxWindow*>(parent);
|
||||
|
Reference in New Issue
Block a user