summaryrefslogtreecommitdiffstats
path: root/src/input_common/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/main.cpp')
-rw-r--r--src/input_common/main.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp
index b12623d55..37f572853 100644
--- a/src/input_common/main.cpp
+++ b/src/input_common/main.cpp
@@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <memory>
+#include <thread>
#include "common/param_package.h"
#include "input_common/analog_from_button.h"
#include "input_common/keyboard.h"
@@ -17,6 +18,10 @@ namespace InputCommon {
static std::shared_ptr<Keyboard> keyboard;
static std::shared_ptr<MotionEmu> motion_emu;
+#ifdef HAVE_SDL2
+static std::thread poll_thread;
+#endif
+
void Init() {
keyboard = std::make_shared<Keyboard>();
Input::RegisterFactory<Input::ButtonDevice>("keyboard", keyboard);
@@ -30,6 +35,12 @@ void Init() {
#endif
}
+void StartJoystickEventHandler() {
+#ifdef HAVE_SDL2
+ poll_thread = std::thread(SDL::PollLoop);
+#endif
+}
+
void Shutdown() {
Input::UnregisterFactory<Input::ButtonDevice>("keyboard");
keyboard.reset();
@@ -39,6 +50,7 @@ void Shutdown() {
#ifdef HAVE_SDL2
SDL::Shutdown();
+ poll_thread.join();
#endif
}