summaryrefslogtreecommitdiffstats
path: root/src/input_common
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2022-11-27 02:08:44 +0100
committergerman77 <juangerman-13@hotmail.com>2022-11-27 18:09:40 +0100
commit7d8095d944f4d3234b67fded9dba0a0ff61f6056 (patch)
tree462623cf46f3b48f72250cf5d23a7f55fb3877d7 /src/input_common
parentMerge pull request #9276 from goldenx86/fsrSlider (diff)
downloadyuzu-7d8095d944f4d3234b67fded9dba0a0ff61f6056.tar
yuzu-7d8095d944f4d3234b67fded9dba0a0ff61f6056.tar.gz
yuzu-7d8095d944f4d3234b67fded9dba0a0ff61f6056.tar.bz2
yuzu-7d8095d944f4d3234b67fded9dba0a0ff61f6056.tar.lz
yuzu-7d8095d944f4d3234b67fded9dba0a0ff61f6056.tar.xz
yuzu-7d8095d944f4d3234b67fded9dba0a0ff61f6056.tar.zst
yuzu-7d8095d944f4d3234b67fded9dba0a0ff61f6056.zip
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/drivers/sdl_driver.cpp15
-rw-r--r--src/input_common/drivers/sdl_driver.h3
-rw-r--r--src/input_common/main.cpp10
-rw-r--r--src/input_common/main.h3
4 files changed, 21 insertions, 10 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index 45ce588f0..8de86b61e 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -361,6 +361,12 @@ void SDLDriver::CloseJoystick(SDL_Joystick* sdl_joystick) {
}
}
+void SDLDriver::PumpEvents() const {
+ if (initialized) {
+ SDL_PumpEvents();
+ }
+}
+
void SDLDriver::HandleGameControllerEvent(const SDL_Event& event) {
switch (event.type) {
case SDL_JOYBUTTONUP: {
@@ -451,14 +457,6 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en
initialized = true;
if (start_thread) {
- poll_thread = std::thread([this] {
- Common::SetCurrentThreadName("SDL_MainLoop");
- using namespace std::chrono_literals;
- while (initialized) {
- SDL_PumpEvents();
- std::this_thread::sleep_for(1ms);
- }
- });
vibration_thread = std::thread([this] {
Common::SetCurrentThreadName("SDL_Vibration");
using namespace std::chrono_literals;
@@ -481,7 +479,6 @@ SDLDriver::~SDLDriver() {
initialized = false;
if (start_thread) {
- poll_thread.join();
vibration_thread.join();
SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER);
}
diff --git a/src/input_common/drivers/sdl_driver.h b/src/input_common/drivers/sdl_driver.h
index d1b4471cf..366bcc496 100644
--- a/src/input_common/drivers/sdl_driver.h
+++ b/src/input_common/drivers/sdl_driver.h
@@ -36,6 +36,8 @@ public:
/// Unregisters SDL device factories and shut them down.
~SDLDriver() override;
+ void PumpEvents() const;
+
/// Handle SDL_Events for joysticks from SDL_PollEvent
void HandleGameControllerEvent(const SDL_Event& event);
@@ -128,7 +130,6 @@ private:
bool start_thread = false;
std::atomic<bool> initialized = false;
- std::thread poll_thread;
std::thread vibration_thread;
};
} // namespace InputCommon
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp
index b2064ef95..cd42344aa 100644
--- a/src/input_common/main.cpp
+++ b/src/input_common/main.cpp
@@ -324,6 +324,12 @@ struct InputSubsystem::Impl {
#endif
}
+ void PumpEvents() const {
+#ifdef HAVE_SDL2
+ sdl->PumpEvents();
+#endif
+ }
+
void RegisterInput(const MappingData& data) {
mapping_factory->RegisterInput(data);
}
@@ -472,6 +478,10 @@ void InputSubsystem::StopMapping() const {
impl->mapping_factory->StopMapping();
}
+void InputSubsystem::PumpEvents() const {
+ impl->PumpEvents();
+}
+
std::string GenerateKeyboardParam(int key_code) {
Common::ParamPackage param;
param.Set("engine", "keyboard");
diff --git a/src/input_common/main.h b/src/input_common/main.h
index ced252383..6218c37f6 100644
--- a/src/input_common/main.h
+++ b/src/input_common/main.h
@@ -147,6 +147,9 @@ public:
/// Stop polling from all backends.
void StopMapping() const;
+ /// Signals SDL driver for new input events
+ void PumpEvents() const;
+
private:
struct Impl;
std::unique_ptr<Impl> impl;