Avoid sleeping the input thread if we don't have to. Improves latency slightly. Also fix mappings.

This commit is contained in:
Henrik Rydgård committed 2025-07-03 09:41:03 +02:00
1 parent 6b0e9b0989
commit 2e1fdc4c78
4 files changed
+123 -29

No files matched your search

+9 -2
View File
@@ -36,17 +36,24 @@ void InputManager::InputThread() {
// NOTE: The keyboard and mouse buttons are handled via raw input, not here.
// This is mainly for controllers which need to be polled, instead of generating events.
bool noSleep = false;
while (runThread_.load(std::memory_order_relaxed)) {
if (focused_.load(std::memory_order_relaxed) || !g_Config.bGamepadOnlyFocused) {
System_Notify(SystemNotification::POLL_CONTROLLERS);
for (const auto &device : devices_) {
if (device->UpdateState() == InputDevice::UPDATESTATE_SKIP_PAD)
int state = device->UpdateState();
if (state == InputDevice::UPDATESTATE_SKIP_PAD)
break;
if (state == InputDevice::UPDATESTATE_NO_SLEEP) {
// Sleep was handled automatically.
noSleep = true;
}
}
}
// Try to update 250 times per second.
Sleep(4);
if (!noSleep)
Sleep(4);
}
for (auto &device : devices_) {