Merge branch 'real-wiimote-scanning'

This commit is contained in:
Jordan Woyak
2013-02-25 17:33:34 -06:00
21 changed files with 960 additions and 847 deletions

View File

@ -100,37 +100,6 @@ CPanel::CPanel(
else
SetCursor(wxNullCursor);
break;
case WIIMOTE_DISCONNECT:
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
{
const int wiimote_idx = lParam;
const int wiimote_num = wiimote_idx + 1;
//Auto reconnect if option is turned on.
//TODO: Make this only auto reconnect wiimotes that have the option activated.
SConfig::GetInstance().LoadSettingsWii();//Make sure we are using the newest settings.
if (SConfig::GetInstance().m_WiiAutoReconnect[wiimote_idx])
{
GetUsbPointer()->AccessWiiMote(wiimote_idx | 0x100)->Activate(true);
NOTICE_LOG(WIIMOTE, "Wiimote %i has been auto-reconnected...", wiimote_num);
}
else
{
// The Wiimote has been disconnected, we offer reconnect here.
wxMessageDialog *dlg = new wxMessageDialog(
this,
wxString::Format(_("Wiimote %i has been disconnected by system.\nMaybe this game doesn't support multi-wiimote,\nor maybe it is due to idle time out or other reason.\nDo you want to reconnect immediately?"), wiimote_num),
_("Reconnect Wiimote Confirm"),
wxYES_NO | wxSTAY_ON_TOP | wxICON_INFORMATION, //wxICON_QUESTION,
wxDefaultPosition);
if (dlg->ShowModal() == wxID_YES)
GetUsbPointer()->AccessWiiMote(wiimote_idx | 0x100)->Activate(true);
dlg->Destroy();
}
}
}
break;

View File

@ -1355,10 +1355,6 @@ void CFrame::ConnectWiimote(int wm_idx, bool connect)
wxString msg(wxString::Format(wxT("Wiimote %i %s"), wm_idx + 1,
connect ? wxT("Connected") : wxT("Disconnected")));
Core::DisplayMessage(msg.ToAscii(), 3000);
// Wait for the wiimote to connect
while (GetUsbPointer()->AccessWiiMote(wm_idx | 0x100)->IsConnected() != connect)
{}
Host_UpdateMainFrame();
}
}

View File

@ -390,10 +390,6 @@ void DolphinApp::InitLanguageSupport()
int DolphinApp::OnExit()
{
WiimoteReal::Shutdown();
#ifdef _WIN32
if (SConfig::GetInstance().m_WiiAutoUnpair)
WiimoteReal::UnPair();
#endif
VideoBackend::ClearList();
SConfig::Shutdown();
LogManager::Shutdown();

View File

@ -4,13 +4,6 @@
#include "HW/WiimoteReal/WiimoteReal.h"
#include "Frame.h"
const wxString& ConnectedWiimotesString()
{
static wxString str;
str.Printf(_("%i connected"), WiimoteReal::Initialize());
return str;
}
WiimoteConfigDiag::WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin)
: wxDialog(parent, -1, _("Dolphin Wiimote Configuration"), wxDefaultPosition, wxDefaultSize)
, m_plugin(plugin)
@ -64,27 +57,31 @@ WiimoteConfigDiag::WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin
// "Real wiimotes" controls
connected_wiimotes_txt = new wxStaticText(this, -1, ConnectedWiimotesString());
wxButton* const refresh_btn = new wxButton(this, -1, _("Refresh"), wxDefaultPosition);
refresh_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &WiimoteConfigDiag::RefreshRealWiimotes, this);
#ifdef _WIN32
wxButton* const pairup_btn = new wxButton(this, -1, _("Pair Up"), wxDefaultPosition);
pairup_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &WiimoteConfigDiag::PairUpRealWiimotes, this);
#endif
wxStaticBoxSizer* const real_wiimotes_group = new wxStaticBoxSizer(wxVERTICAL, this, _("Real Wiimotes"));
wxBoxSizer* const real_wiimotes_sizer = new wxBoxSizer(wxHORIZONTAL);
if (!WiimoteReal::g_wiimote_scanner.IsReady())
real_wiimotes_group->Add(new wxStaticText(this, -1, _("A supported bluetooth device could not be found.\n"
"You must manually connect your wiimotes.")), 0, wxALIGN_CENTER | wxALL, 5);
wxCheckBox* const continuous_scanning = new wxCheckBox(this, wxID_ANY, _("Continuous Scanning"));
continuous_scanning->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &WiimoteConfigDiag::OnContinuousScanning, this);
continuous_scanning->SetValue(SConfig::GetInstance().m_WiimoteContinuousScanning);
auto wiimote_speaker = new wxCheckBox(this, wxID_ANY, _("Enable Speaker Data"));
wiimote_speaker->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &WiimoteConfigDiag::OnEnableSpeaker, this);
wiimote_speaker->SetValue(SConfig::GetInstance().m_WiimoteEnableSpeaker);
real_wiimotes_sizer->Add(continuous_scanning, 0, wxALIGN_CENTER_VERTICAL);
real_wiimotes_sizer->AddStretchSpacer(1);
real_wiimotes_sizer->Add(refresh_btn, 0, wxALL | wxALIGN_CENTER, 5);
// "Real wiimotes" layout
wxStaticBoxSizer* const real_wiimotes_group = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Real Wiimotes"));
wxFlexGridSizer* const real_wiimotes_sizer = new wxFlexGridSizer(3, 5, 5);
real_wiimotes_sizer->Add(connected_wiimotes_txt, 0, wxALIGN_CENTER_VERTICAL);
#ifdef _WIN32
real_wiimotes_sizer->Add(pairup_btn);
#endif
real_wiimotes_sizer->Add(refresh_btn);
real_wiimotes_group->Add(real_wiimotes_sizer, 1, wxALL, 5);
real_wiimotes_group->Add(wiimote_speaker, 0);
real_wiimotes_group->Add(real_wiimotes_sizer, 0, wxEXPAND);
// "General Settings" controls
const wxString str[] = { _("Bottom"), _("Top") };
@ -188,33 +185,9 @@ void WiimoteConfigDiag::ConfigEmulatedWiimote(wxCommandEvent& ev)
m_emu_config_diag->Destroy();
}
void WiimoteConfigDiag::UpdateGUI()
{
connected_wiimotes_txt->SetLabel(ConnectedWiimotesString());
}
#ifdef _WIN32
void WiimoteConfigDiag::PairUpRealWiimotes(wxCommandEvent&)
{
const int paired = WiimoteReal::PairUp();
if (paired > 0)
{
// TODO: Maybe add a label of newly paired up wiimotes?
WiimoteReal::Refresh();
UpdateGUI();
}
else if (paired < 0)
PanicAlertT("A supported bluetooth device could not be found!\n"
"If you are not using Microsoft's bluetooth stack "
"you must manually pair your wiimotes and use only the \"Refresh\" button.");
}
#endif
void WiimoteConfigDiag::RefreshRealWiimotes(wxCommandEvent&)
{
WiimoteReal::Refresh();
UpdateGUI();
}
void WiimoteConfigDiag::SelectSource(wxCommandEvent& event)
@ -222,30 +195,15 @@ void WiimoteConfigDiag::SelectSource(wxCommandEvent& event)
// This needs to be changed now in order for refresh to work right.
// Revert if the dialog is canceled.
int index = m_wiimote_index_from_ctrl_id[event.GetId()];
g_wiimote_sources[index] = event.GetInt();
WiimoteReal::ChangeWiimoteSource(index, event.GetInt());
if (g_wiimote_sources[index] != WIIMOTE_SRC_EMU && g_wiimote_sources[index] != WIIMOTE_SRC_HYBRID)
wiimote_configure_bt[index]->Disable();
else
wiimote_configure_bt[index]->Enable();
}
void WiimoteConfigDiag::UpdateWiimoteStatus()
{
for (int index = 0; index < 4; ++index)
{
if (m_orig_wiimote_sources[index] != g_wiimote_sources[index])
{
// Disconnect first, otherwise the new source doesn't seem to work
CFrame::ConnectWiimote(index, false);
// Connect wiimotes
if (WIIMOTE_SRC_EMU & g_wiimote_sources[index])
CFrame::ConnectWiimote(index, true);
else if (WIIMOTE_SRC_REAL & g_wiimote_sources[index] && WiimoteReal::g_wiimotes[index])
CFrame::ConnectWiimote(index, WiimoteReal::g_wiimotes[index]->IsConnected());
}
}
}
void WiimoteConfigDiag::RevertSource()
{
for (int i = 0; i < 4; ++i)
@ -267,7 +225,6 @@ void WiimoteConfigDiag::Save(wxCommandEvent& event)
sec.Set("Source", (int)g_wiimote_sources[i]);
}
UpdateWiimoteStatus();
inifile.Save(ini_filename);

View File

@ -24,20 +24,13 @@ class WiimoteConfigDiag : public wxDialog
public:
WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin);
#ifdef _WIN32
void PairUpRealWiimotes(wxCommandEvent& event);
#endif
void RefreshRealWiimotes(wxCommandEvent& event);
void SelectSource(wxCommandEvent& event);
void UpdateWiimoteStatus();
void RevertSource();
void ConfigEmulatedWiimote(wxCommandEvent& event);
void Save(wxCommandEvent& event);
void UpdateGUI();
void OnSensorBarPos(wxCommandEvent& event)
{
@ -64,6 +57,17 @@ public:
SConfig::GetInstance().m_WiimoteReconnectOnLoad = event.IsChecked();
event.Skip();
}
void OnContinuousScanning(wxCommandEvent& event)
{
SConfig::GetInstance().m_WiimoteContinuousScanning = event.IsChecked();
WiimoteReal::Initialize();
event.Skip();
}
void OnEnableSpeaker(wxCommandEvent& event)
{
SConfig::GetInstance().m_WiimoteEnableSpeaker = event.IsChecked();
event.Skip();
}
private:
void Cancel(wxCommandEvent& event);
@ -76,8 +80,6 @@ private:
wxButton* wiimote_configure_bt[4];
std::map<wxWindowID, unsigned int> m_wiimote_index_from_conf_bt_id;
wxStaticText* connected_wiimotes_txt;
};