mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
Implemented Auto-Unpair (MS bluetooth stack). For those people, who are tired of removing the batteries after they were finished playing around with dolphin, to avoid battery drain. It's switchable via checkbox within the wiimote gui. This will simply remove valid wiimote pairings on Exit/Close.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5373 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
7a7d1a7b55
commit
6cc0ddadd4
@ -264,6 +264,7 @@ void Config::Load()
|
||||
|
||||
// Real Wiimote
|
||||
iniFile.Get("Real", "UpdateStatus", &bUpdateRealWiimote, true);
|
||||
iniFile.Get("Real", "Unpair", &bUnpairRealWiimote, false);
|
||||
iniFile.Get("Real", "AccNeutralX", &iAccNeutralX, 0);
|
||||
iniFile.Get("Real", "AccNeutralY", &iAccNeutralY, 0);
|
||||
iniFile.Get("Real", "AccNeutralZ", &iAccNeutralZ, 0);
|
||||
@ -388,6 +389,7 @@ void Config::Save()
|
||||
iniFile.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "Wiimote.ini").c_str());
|
||||
|
||||
iniFile.Set("Real", "UpdateStatus", bUpdateRealWiimote);
|
||||
iniFile.Set("Real", "Unpair", bUnpairRealWiimote);
|
||||
iniFile.Set("Real", "AccNeutralX", iAccNeutralX);
|
||||
iniFile.Set("Real", "AccNeutralY", iAccNeutralY);
|
||||
iniFile.Set("Real", "AccNeutralZ", iAccNeutralZ);
|
||||
|
@ -33,7 +33,7 @@ struct Config
|
||||
int CurrentPage;
|
||||
|
||||
// Real Wiimote
|
||||
bool bUpdateRealWiimote;
|
||||
bool bUpdateRealWiimote, bUnpairRealWiimote;
|
||||
int bNumberRealWiimotes, bNumberEmuWiimotes;
|
||||
int iIRLeft, iIRTop, iIRWidth, iIRHeight, iIRLevel;
|
||||
int iAccNeutralX, iAccNeutralY, iAccNeutralZ;
|
||||
|
@ -25,8 +25,6 @@
|
||||
#include "EmuMain.h" // for SetDefaultExtensionRegistry
|
||||
#include "EmuSubroutines.h" // for WmRequestStatus
|
||||
|
||||
|
||||
|
||||
BEGIN_EVENT_TABLE(WiimoteBasicConfigDialog,wxDialog)
|
||||
EVT_CLOSE(WiimoteBasicConfigDialog::OnClose)
|
||||
EVT_BUTTON(wxID_OK, WiimoteBasicConfigDialog::ButtonClick)
|
||||
@ -43,6 +41,7 @@ BEGIN_EVENT_TABLE(WiimoteBasicConfigDialog,wxDialog)
|
||||
EVT_CHECKBOX(IDC_UPRIGHTWIIMOTE, WiimoteBasicConfigDialog::GeneralSettingsChanged)
|
||||
EVT_CHECKBOX(IDC_MOTIONPLUSCONNECTED, WiimoteBasicConfigDialog::GeneralSettingsChanged)
|
||||
EVT_CHECKBOX(IDC_WIIAUTORECONNECT, WiimoteBasicConfigDialog::GeneralSettingsChanged)
|
||||
EVT_CHECKBOX(IDC_WIIAUTOUNPAIR, WiimoteBasicConfigDialog::GeneralSettingsChanged)
|
||||
EVT_CHOICE(IDC_EXTCONNECTED, WiimoteBasicConfigDialog::GeneralSettingsChanged)
|
||||
|
||||
//UDPWii
|
||||
@ -122,7 +121,7 @@ void WiimoteBasicConfigDialog::ButtonClick(wxCommandEvent& event)
|
||||
if (g_EmulatorState != PLUGIN_EMUSTATE_PLAY)
|
||||
{
|
||||
m_PairUpRealWiimote[m_Page]->Enable(false);
|
||||
if (WiiMoteReal::WiimotePairUp() > 0)
|
||||
if (WiiMoteReal::WiimotePairUp(false) > 0)
|
||||
{ // Only temporay solution TODO: 2nd step: threaded.
|
||||
// sleep would be required (but not best way to solve that cuz 3000ms~ would be needed, which is not convenient),cuz BT device is not ready yet when calling DoRefreshReal()
|
||||
DoRefreshReal();
|
||||
@ -203,8 +202,13 @@ void WiimoteBasicConfigDialog::CreateGUIControls()
|
||||
m_ConnectRealWiimote[i] = new wxButton(m_Controller[i], IDB_REFRESH_REAL, wxT("Refresh Real Wiimotes"));
|
||||
m_ConnectRealWiimote[i]->SetToolTip(wxT("This can only be done when the emulator is paused or stopped."));
|
||||
|
||||
m_WiiAutoReconnect[i] = new wxCheckBox(m_Controller[i], IDC_WIIAUTORECONNECT, wxT("Auto reconnect wiimote"));
|
||||
m_WiiAutoReconnect[i] = new wxCheckBox(m_Controller[i], IDC_WIIAUTORECONNECT, wxT("Reconnect Wiimote on disconnect"));
|
||||
m_WiiAutoReconnect[i]->SetToolTip(wxT("This makes dolphin automatically reconnect a wiimote when it has being disconnected.\nThis will cause problems when 2 controllers are connected for a 1 player game."));
|
||||
m_WiiAutoUnpair[i] = new wxCheckBox(m_Controller[i], IDC_WIIAUTOUNPAIR, wxT("Unpair Wiimote on close"));
|
||||
m_WiiAutoUnpair[i]->SetToolTip(wxT("This makes dolphin automatically unpair a wiimote when dolphin is about to be closed."));
|
||||
#ifndef _WIN32
|
||||
m_WiiAutoUnpair[i]->Enable(false);
|
||||
#endif
|
||||
|
||||
//IR Pointer
|
||||
m_TextScreenWidth[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Width: 000"));
|
||||
@ -251,11 +255,15 @@ void WiimoteBasicConfigDialog::CreateGUIControls()
|
||||
m_SizeUDPWii[i]->Add(m_UDPWiiIR[i], 0, wxEXPAND | wxALL,1);
|
||||
m_SizeUDPWii[i]->Add(m_UDPWiiNun[i], 0, wxEXPAND | wxALL,1);
|
||||
|
||||
m_SizeRealAuto[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Automatic"));
|
||||
m_SizeRealAuto[i]->Add(m_WiiAutoReconnect[i], 0, wxEXPAND | (wxDOWN | wxTOP), 5);
|
||||
m_SizeRealAuto[i]->Add(m_WiiAutoUnpair[i], 0, wxEXPAND | (wxDOWN | wxTOP), 5);
|
||||
|
||||
m_SizeReal[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Real Wiimote"));
|
||||
m_SizeReal[i]->Add(m_PairUpRealWiimote[i], 0, wxEXPAND | wxALL, 5);
|
||||
m_SizeReal[i]->Add(m_TextFoundRealWiimote[i], 0, wxEXPAND | wxALL, 5);
|
||||
m_SizeReal[i]->Add(m_ConnectRealWiimote[i], 0, wxEXPAND | wxALL, 5);
|
||||
m_SizeReal[i]->Add(m_WiiAutoReconnect[i], 0, wxEXPAND | wxALL, 5);
|
||||
m_SizeReal[i]->Add(m_SizeRealAuto[i], 0, wxEXPAND | wxALL, 5);
|
||||
|
||||
m_SizerIRPointerWidth[i] = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_SizerIRPointerWidth[i]->Add(m_TextScreenLeft[i], 0, wxEXPAND | (wxTOP), 3);
|
||||
@ -452,6 +460,9 @@ void WiimoteBasicConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
|
||||
case IDC_WIIAUTORECONNECT:
|
||||
WiiMoteEmu::WiiMapping[m_Page].bWiiAutoReconnect = m_WiiAutoReconnect[m_Page]->IsChecked();
|
||||
break;
|
||||
case IDC_WIIAUTOUNPAIR:
|
||||
g_Config.bUnpairRealWiimote = m_WiiAutoUnpair[m_Page]->IsChecked();
|
||||
break;
|
||||
case IDC_EXTCONNECTED:
|
||||
// Disconnect the extension so that the game recognize the change
|
||||
DoExtensionConnectedDisconnected(WiiMoteEmu::EXT_NONE);
|
||||
@ -555,6 +566,7 @@ void WiimoteBasicConfigDialog::UpdateGUI()
|
||||
m_UprightWiimote[m_Page]->SetValue(WiiMoteEmu::WiiMapping[m_Page].bUpright);
|
||||
m_WiiMotionPlusConnected[m_Page]->SetValue(WiiMoteEmu::WiiMapping[m_Page].bMotionPlusConnected);
|
||||
m_WiiAutoReconnect[m_Page]->SetValue(WiiMoteEmu::WiiMapping[m_Page].bWiiAutoReconnect);
|
||||
m_WiiAutoUnpair[m_Page]->SetValue(g_Config.bUnpairRealWiimote);
|
||||
m_Extension[m_Page]->SetSelection(WiiMoteEmu::WiiMapping[m_Page].iExtensionConnected);
|
||||
|
||||
// Update the Wiimote IR pointer calibration
|
||||
|
@ -85,6 +85,7 @@ class WiimoteBasicConfigDialog : public wxDialog
|
||||
*m_CheckAR169[MAX_WIIMOTES],
|
||||
*m_Crop[MAX_WIIMOTES],
|
||||
*m_WiiAutoReconnect[MAX_WIIMOTES],
|
||||
*m_WiiAutoUnpair[MAX_WIIMOTES],
|
||||
*m_UDPWiiEnable[MAX_WIIMOTES],
|
||||
*m_UDPWiiAccel[MAX_WIIMOTES],
|
||||
*m_UDPWiiButt[MAX_WIIMOTES],
|
||||
@ -112,6 +113,7 @@ class WiimoteBasicConfigDialog : public wxDialog
|
||||
|
||||
wxStaticBoxSizer *m_SizeBasic[MAX_WIIMOTES],
|
||||
*m_SizeEmu[MAX_WIIMOTES],
|
||||
*m_SizeRealAuto[MAX_WIIMOTES],
|
||||
*m_SizeReal[MAX_WIIMOTES],
|
||||
*m_SizeExtensions[MAX_WIIMOTES],
|
||||
*m_SizerIRPointer[MAX_WIIMOTES],
|
||||
@ -139,6 +141,7 @@ class WiimoteBasicConfigDialog : public wxDialog
|
||||
IDC_UPRIGHTWIIMOTE,
|
||||
IDC_MOTIONPLUSCONNECTED,
|
||||
IDC_WIIAUTORECONNECT,
|
||||
IDC_WIIAUTOUNPAIR,
|
||||
IDC_EXTCONNECTED,
|
||||
|
||||
//UDPWii
|
||||
|
@ -104,6 +104,9 @@ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
#ifdef _WIN32
|
||||
if (g_Config.bUnpairRealWiimote) WiiMoteReal::WiimotePairUp(true);
|
||||
#endif
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
wxUninitialize();
|
||||
#endif
|
||||
|
@ -619,7 +619,7 @@ THREAD_RETURN SafeCloseReadWiimote_ThreadFunc(void* arg)
|
||||
}
|
||||
// WiiMote Pair-Up
|
||||
#ifdef WIN32
|
||||
int WiimotePairUp(void)
|
||||
int WiimotePairUp(bool unpair)
|
||||
{
|
||||
HANDLE hRadios[256];
|
||||
int nRadios;
|
||||
@ -683,7 +683,7 @@ int WiimotePairUp(void)
|
||||
|
||||
do
|
||||
{
|
||||
if ((!wcscmp(btdi.szName, L"Nintendo RVL-WBC-01") || !wcscmp(btdi.szName, L"Nintendo RVL-CNT-01")) && !btdi.fConnected)
|
||||
if ((!wcscmp(btdi.szName, L"Nintendo RVL-WBC-01") || !wcscmp(btdi.szName, L"Nintendo RVL-CNT-01")) && !btdi.fConnected && !unpair)
|
||||
{
|
||||
//TODO: improve the readd of the BT driver, esp. when batteries of the wiimote are removed while beeing fConnected
|
||||
if (btdi.fRemembered)
|
||||
@ -706,6 +706,13 @@ int WiimotePairUp(void)
|
||||
ERROR_LOG(WIIMOTE, "Pair-Up: BluetoothSetServiceState() returned %08x", hr);
|
||||
}
|
||||
}
|
||||
else if ((!wcscmp(btdi.szName, L"Nintendo RVL-WBC-01") || !wcscmp(btdi.szName, L"Nintendo RVL-CNT-01")) && unpair)
|
||||
{
|
||||
|
||||
BluetoothRemoveDevice(&btdi.Address);
|
||||
NOTICE_LOG(WIIMOTE, "Pair-Up: Automatically removed BT Device on shutdown: %08x", GetLastError());
|
||||
|
||||
}
|
||||
} while (BluetoothFindNextDevice(hFind, &btdi));
|
||||
BluetoothFindRadioClose(hFind);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ namespace WiiMoteReal
|
||||
{
|
||||
|
||||
int Initialize();
|
||||
int WiimotePairUp();
|
||||
int WiimotePairUp(bool unpair);
|
||||
|
||||
void Allocate();
|
||||
void DoState(PointerWrap &p);
|
||||
|
Loading…
Reference in New Issue
Block a user