diff --git a/src/input/wiimote_manager.cpp b/src/input/wiimote_manager.cpp index 8a4821a02..98c1cbcdf 100644 --- a/src/input/wiimote_manager.cpp +++ b/src/input/wiimote_manager.cpp @@ -34,6 +34,8 @@ #include "wiiuse.h" +#include + WiimoteManager* wiimote_manager; @@ -203,7 +205,7 @@ void WiimoteManager::launchDetection(int timeout) // Launch the update thread #ifdef WIIMOTE_THREADING m_shut = false; - pthread_create(&m_thread, NULL, &threadFuncWrapper, this); + m_thread = std::thread(std::bind(&WiimoteManager::threadFunc, this)); #endif } // launchDetection @@ -263,7 +265,7 @@ void WiimoteManager::cleanup() // Shut the update thread #ifdef WIIMOTE_THREADING m_shut = true; - pthread_join(m_thread, NULL); + m_thread.join(); #endif // Cleanup WiiUse wiiuse_cleanup(m_all_wiimote_handles, MAX_WIIMOTES); @@ -311,6 +313,7 @@ void WiimoteManager::enableAccelerometer(bool state) void WiimoteManager::threadFunc() { #ifdef WIIMOTE_THREADING + VS::setThreadName("WiimoteManager"); while(!m_shut) #endif { @@ -366,18 +369,6 @@ void WiimoteManager::threadFunc() } // end while } // threadFunc -// ---------------------------------------------------------------------------- -/** This is the start function of a separate thread used to poll the wiimotes. - * It receives the wiimote manager as parameter when the thread is created. - * \param data Pointer to the wiimote manager. - */ -void* WiimoteManager::threadFuncWrapper(void *data) -{ - VS::setThreadName("WiimoteManager"); - ((WiimoteManager*)data)->threadFunc(); - return NULL; -} // threadFuncWrapper - // ---------------------------------------------------------------------------- /** Shows a simple popup menu asking the user to connect all wiimotes. */ diff --git a/src/input/wiimote_manager.hpp b/src/input/wiimote_manager.hpp index 810537151..1feb42d40 100644 --- a/src/input/wiimote_manager.hpp +++ b/src/input/wiimote_manager.hpp @@ -25,9 +25,9 @@ #include "states_screens/dialogs/message_dialog.hpp" #include "utils/cpp2011.hpp" -#include "IEventReceiver.h" +#include -#include +#include "IEventReceiver.h" #define MAX_WIIMOTES 4 @@ -57,7 +57,7 @@ private: #define WIIMOTE_THREADING #ifdef WIIMOTE_THREADING /** Wiimote state update thread */ - pthread_t m_thread; + std::thread m_thread; /** Shut the update thread? */ bool m_shut; @@ -68,7 +68,6 @@ private: /** Wiimotes update thread */ void threadFunc(); - static void* threadFuncWrapper(void* data); void setWiimoteBindings(GamepadConfig* gamepad_config); public: