diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp index 1b60d418ac..a0fe473d54 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp @@ -114,13 +114,6 @@ WiimotePadConfigDialog::WiimotePadConfigDialog(wxWindow *parent, wxWindowID id, // Reset values GetButtonWaitingID = 0; GetButtonWaitingTimer = 0; - // Settings - // Only tested in Windows - #ifdef _WIN32 - LiveUpdates = true; - #else - LiveUpdates = false; - #endif // Start the slow timer int TimesPerSecond = 2; diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h index 149e6304f8..9ca709eee0 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h @@ -61,6 +61,7 @@ class WiimotePadConfigDialog : public wxDialog void OnButtonTimer(wxTimerEvent& WXUNUSED(event)) { DoGetButtons(GetButtonWaitingID); } void Update(wxTimerEvent& WXUNUSED(event)); void UpdatePad(wxTimerEvent& WXUNUSED(event)); + void UpdateDeviceList(); wxTimer *m_Update, *m_UpdatePad, @@ -253,7 +254,6 @@ class WiimotePadConfigDialog : public wxDialog }; void OnClose(wxCloseEvent& event); - void UpdateDeviceList(); void CreatePadGUIControls(); void GeneralSettingsChanged(wxCommandEvent& event); diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.cpp index 1151aee786..2823eb568f 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.cpp @@ -59,6 +59,12 @@ bool g_Encryption; // Encryption on or off // Gamepad input int NumPads = 0, NumDIDevices = -1; // Number of pads bool SDLPolling = true; +#ifdef _WIN32 +bool LiveUpdates = false; +#else +bool LiveUpdates = false; +#endif + std::vector joyinfo; InputCommon::CONTROLLER_STATE_NEW PadState[4]; InputCommon::CONTROLLER_MAPPING_NEW PadMapping[4]; diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h b/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h index b69433528a..e54614bbb1 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h @@ -184,6 +184,7 @@ static const u8 partially_id[] = // Gamepad input extern int NumPads, NumDIDevices; // Number of pads extern bool SDLPolling; // Turn off polling +extern bool LiveUpdates; extern std::vector joyinfo; extern InputCommon::CONTROLLER_STATE_NEW PadState[4]; extern InputCommon::CONTROLLER_MAPPING_NEW PadMapping[4]; diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuPad.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuPad.cpp index 487a6e0077..8f232ba43f 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuPad.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuPad.cpp @@ -57,29 +57,24 @@ bool LocalSearchDevices(std::vector &_joyinfo, int return bSuccess; } + bool LocalSearchDevicesReset(std::vector &_joyinfo, int &_NumPads) { DEBUG_LOG(CONSOLE, "LocalSearchDevicesReset"); // Turn off device polling while resetting EnablePolling(false); - bool bSuccess = InputCommon::SearchDevicesReset(_joyinfo, _NumPads); + bool bSuccess = InputCommon::SearchDevicesReset(_joyinfo, _NumPads); + DoLocalSearchDevices(_joyinfo, _NumPads); EnablePolling(true); - DoLocalSearchDevices(_joyinfo, _NumPads); - - return bSuccess; + return true; } // Fill joyinfo with the current connected devices bool DoLocalSearchDevices(std::vector &_joyinfo, int &_NumPads) { //DEBUG_LOG(WIIMOTE, "LocalSearchDevices"); - - // Turn off device polling while searching - WiiMoteEmu::EnablePolling(false); - - bool bReturn = InputCommon::SearchDevices(_joyinfo, _NumPads); // Warn the user if no gamepads are detected if (_NumPads == 0 && g_EmulatorRunning) @@ -108,9 +103,7 @@ bool DoLocalSearchDevices(std::vector &_joyinfo, i if (!Match) PadState[i].joy = NULL; } - WiiMoteEmu::EnablePolling(true); - - return bReturn; + return true; } // Is the device connected? @@ -147,6 +140,7 @@ void EnablePolling(bool Enable) } } + // ID to Name // ---------------- std::string IDToName(int ID) @@ -219,10 +213,10 @@ void GetJoyState(InputCommon::CONTROLLER_STATE_NEW &_PadState, InputCommon::CONT //DEBUG_LOG(WIIMOTE, "GetJoyState: Polling:%i NumPads:%i", SDLPolling, NumPads); // Return if polling is off - if (!IsPolling) return; + if (!IsPolling()) return; // Update joyinfo handles. This is in case the Wiimote plugin has restarted SDL after a pad was conencted/disconnected // so that the handles are updated. We don't need to run this this often. Once a second would be enough. - LocalSearchDevices(joyinfo, NumPads); + if (LiveUpdates) LocalSearchDevices(joyinfo, NumPads); // Return if we have no pads if (NumPads == 0) return; // Read info diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp index ceda5cabc0..2ba5957e23 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp @@ -121,12 +121,6 @@ PADConfigDialognJoy::PADConfigDialognJoy(wxWindow *parent, wxWindowID id, const // Settings Debugging = false; - // Only tested in Windows - #ifdef _WIN32 - LiveUpdates = true; - #else - LiveUpdates = false; - #endif // Create controls CreateGUIControls(); diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp index 461ae011d5..48d8054c15 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp @@ -49,6 +49,11 @@ InputCommon::CONTROLLER_STATE PadState[4]; InputCommon::CONTROLLER_MAPPING PadMapping[4]; bool g_EmulatorRunning = false; bool SDLPolling = true; +#ifdef _WIN32 +bool LiveUpdates = false; +#else +bool LiveUpdates = false; +#endif int NumPads = 0, NumDIDevices = -1, LastPad = 0; #ifdef _WIN32 HWND m_hWnd = NULL, m_hConsole = NULL; // Handle to window @@ -284,7 +289,7 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) // Update joyinfo handles. This is in case the Wiimote plugin has restarted SDL after a pad was conencted/disconnected // so that the handles are updated. - LocalSearchDevices(joyinfo, NumPads); + if (LiveUpdates) LocalSearchDevices(joyinfo, NumPads); // Check if the pad is avaliable, currently we don't disable pads just because they are // disconnected @@ -459,9 +464,8 @@ bool LocalSearchDevicesReset(std::vector &_joyinfo // Turn off device polling while resetting EnablePolling(false); bool Success = InputCommon::SearchDevicesReset(_joyinfo, _NumPads); - EnablePolling(true); - DoLocalSearchDevices(_joyinfo, _NumPads); + EnablePolling(true); return Success; } diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h index fea488b47d..7ae50fcabf 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h @@ -97,6 +97,7 @@ #endif extern int NumPads, NumDIDevices, LastPad; // Number of pads extern bool SDLPolling; + extern bool LiveUpdates; #endif