Added config for enabling Balance Board.

Fixed other structures that still assumed 4 of everything.
This commit is contained in:
Matthew Parlane 2013-05-19 00:30:20 +12:00
parent 59924d0291
commit 7208823396
4 changed files with 56 additions and 23 deletions

View File

@ -457,7 +457,10 @@ void LoadSettings()
sec.Get("Source", &g_wiimote_sources[i], i ? WIIMOTE_SRC_NONE : WIIMOTE_SRC_EMU);
}
g_wiimote_sources[WIIMOTE_BALANCE_BOARD] = WIIMOTE_SRC_REAL;
std::string secname("BalanceBoard");
IniFile::Section& sec = *inifile.GetOrCreateSection(secname.c_str());
sec.Get("Source", &g_wiimote_sources[WIIMOTE_BALANCE_BOARD], WIIMOTE_SRC_NONE);
}
// config dialog calls this when some settings change
@ -501,14 +504,14 @@ void Shutdown(void)
void ChangeWiimoteSource(unsigned int index, int source)
{
{
std::lock_guard<std::recursive_mutex> lk(g_refresh_lock);
g_wiimote_sources[index] = source;
g_wiimote_scanner.WantWiimotes(0 != CalculateWantedWiimotes());
g_wiimote_scanner.WantBB(0 != CalculateWantedBB());
// kill real connection (or swap to different slot)
DoneWithWiimote(index);
std::lock_guard<std::recursive_mutex> lk(g_refresh_lock);
g_wiimote_sources[index] = source;
g_wiimote_scanner.WantWiimotes(0 != CalculateWantedWiimotes());
g_wiimote_scanner.WantBB(0 != CalculateWantedBB());
// kill real connection (or swap to different slot)
DoneWithWiimote(index);
}
// reconnect to the emulator
@ -635,7 +638,7 @@ void Refresh()
std::vector<Wiimote*> found_wiimotes;
Wiimote* found_board = NULL;
if (0 != CalculateWantedWiimotes())
if (0 != CalculateWantedWiimotes() || 0 != CalculateWantedBB())
{
// Don't hang Dolphin when searching
lk.unlock();
@ -646,7 +649,8 @@ void Refresh()
CheckForDisconnectedWiimotes();
// Brief rumble for already connected Wiimotes.
for (int i = 0; i < MAX_BBMOTES; ++i)
// Don't do this for Balance Board as it doesn't have rumble anyway.
for (int i = 0; i < MAX_WIIMOTES; ++i)
{
if (g_wiimotes[i])
{

View File

@ -54,8 +54,25 @@ WiimoteConfigDiag::WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin
wiimote_sizer->Add(wiimote_configure_bt[i]);
}
wiimote_group->Add(wiimote_sizer, 1, wxEXPAND, 5 );
// "BalanceBoard" layout
wxStaticBoxSizer* const bb_group = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Balance Board"));
wxFlexGridSizer* const bb_sizer = new wxFlexGridSizer(1, 5, 5);
int source_ctrl_id = wxWindow::NewControlId();
m_wiimote_index_from_ctrl_id.insert(std::pair<wxWindowID, unsigned int>(source_ctrl_id, WIIMOTE_BALANCE_BOARD));
const wxString src_choices[] = { _("None"), _("Real Balance Board") };
wxChoice* bb_source = new wxChoice(this, source_ctrl_id, wxDefaultPosition, wxDefaultSize, sizeof(src_choices)/sizeof(*src_choices), src_choices);
bb_source->Bind(wxEVT_COMMAND_CHOICE_SELECTED, &WiimoteConfigDiag::SelectSource, this);
m_orig_wiimote_sources[WIIMOTE_BALANCE_BOARD] = g_wiimote_sources[WIIMOTE_BALANCE_BOARD];
bb_source->Select(m_orig_wiimote_sources[WIIMOTE_BALANCE_BOARD] ? 1 : 0);
bb_sizer->Add(bb_source, 0, wxALIGN_CENTER_VERTICAL);
bb_group->Add(bb_sizer, 1, wxEXPAND, 5 );
// "Real wiimotes" controls
wxButton* const refresh_btn = new wxButton(this, -1, _("Refresh"), wxDefaultPosition);
refresh_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &WiimoteConfigDiag::RefreshRealWiimotes, this);
@ -166,6 +183,7 @@ WiimoteConfigDiag::WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin
// Dialog layout
main_sizer->Add(wiimote_group, 0, wxEXPAND | wxALL, 5);
main_sizer->Add(bb_group, 0, wxEXPAND | wxALL, 5);
main_sizer->Add(real_wiimotes_group, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
main_sizer->Add(general_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
@ -196,17 +214,23 @@ void WiimoteConfigDiag::SelectSource(wxCommandEvent& event)
// Revert if the dialog is canceled.
int index = m_wiimote_index_from_ctrl_id[event.GetId()];
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();
if(index != WIIMOTE_BALANCE_BOARD)
{
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();
}
else
wiimote_configure_bt[index]->Enable();
{
WiimoteReal::ChangeWiimoteSource(index, event.GetInt() ? WIIMOTE_SRC_REAL : WIIMOTE_SRC_NONE);
}
}
void WiimoteConfigDiag::RevertSource()
{
for (int i = 0; i < MAX_WIIMOTES; ++i)
for (int i = 0; i < MAX_BBMOTES; ++i)
g_wiimote_sources[i] = m_orig_wiimote_sources[i];
}
@ -225,6 +249,10 @@ void WiimoteConfigDiag::Save(wxCommandEvent& event)
sec.Set("Source", (int)g_wiimote_sources[i]);
}
std::string secname("BalanceBoard");
IniFile::Section& sec = *inifile.GetOrCreateSection(secname.c_str());
sec.Set("Source", (int)g_wiimote_sources[WIIMOTE_BALANCE_BOARD]);
inifile.Save(ini_filename);

View File

@ -76,7 +76,7 @@ private:
wxNotebook* m_pad_notebook;
std::map<wxWindowID, unsigned int> m_wiimote_index_from_ctrl_id;
unsigned int m_orig_wiimote_sources[MAX_WIIMOTES];
unsigned int m_orig_wiimote_sources[MAX_BBMOTES];
wxButton* wiimote_configure_bt[MAX_WIIMOTES];
std::map<wxWindowID, unsigned int> m_wiimote_index_from_conf_bt_id;

View File

@ -3,7 +3,8 @@
// Refer to the license.txt file included.
#include "InputConfig.h"
#include "../../Core/Src/ConfigManager.h"
#include "../Src/ConfigManager.h"
#include "../Src/HW/Wiimote.h"
InputPlugin::~InputPlugin()
{
@ -18,9 +19,9 @@ bool InputPlugin::LoadConfig(bool isGC)
{
IniFile inifile;
IniFile game_ini;
bool useProfile[4] = {false, false, false, false};
std::string num[4] = {"1", "2", "3", "4"};
std::string profile[4];
bool useProfile[MAX_BBMOTES] = {false, false, false, false, false};
std::string num[MAX_BBMOTES] = {"1", "2", "3", "4", "BB"};
std::string profile[MAX_BBMOTES];
std::string path;
if (SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID() != "00000000")