SDL: call SDL_PumpEvents from main thread

This commit is contained in:
Megamouse
2025-09-20 11:12:54 +02:00
parent 6b87423293
commit 1667998b4e
2 changed files with 16 additions and 1 deletions
+15 -1
View File
@@ -3,6 +3,8 @@
#include "stdafx.h"
#include "sdl_instance.h"
#include "Emu/System.h"
#include "Emu/system_config.h"
#include "Emu/Cell/timers.hpp"
#ifndef _MSC_VER
#pragma GCC diagnostic push
@@ -37,7 +39,19 @@ void sdl_instance::pump_events()
if (m_initialized)
{
SDL_PumpEvents();
const u64 sleep_us = std::clamp<u64>(g_cfg.io.pad_sleep.get(), 1000, 16000); // 1ms to 16ms
if ((get_system_time() - m_last_pump_us) < sleep_us)
{
return;
}
Emu.CallFromMainThread([this]()
{
if (!m_initialized) return;
SDL_PumpEvents();
m_last_pump_us = get_system_time();
}, nullptr, false);
}
}
+1
View File
@@ -21,6 +21,7 @@ private:
bool m_initialized = false;
std::mutex m_instance_mutex;
atomic_t<u64> m_last_pump_us {0};
};
#endif