Move the rest of input initialization to the input thread. Speeds up startup.

This commit is contained in:
Henrik Rydgård
2025-08-31 15:47:03 +02:00
parent c9acf8e80e
commit 21f25b5e57
3 changed files with 16 additions and 8 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
#pragma once
#include "Input/InputState.h"
#include "Common/Input/InputState.h"
#include "Windows/InputDevice.h"
#include <set>
#include <windows.h>
+14
View File
@@ -25,6 +25,12 @@
#include "Core/Config.h"
#include "Windows/InputDevice.h"
#if !PPSSPP_PLATFORM(UWP)
#include "Windows/DinputDevice.h"
#include "Windows/HidInputDevice.h"
#include "Windows/XinputDevice.h"
#endif
InputManager g_InputManager;
void InputManager::InputThread() {
@@ -64,6 +70,14 @@ void InputManager::InputThread() {
void InputManager::BeginPolling() {
runThread_.store(true, std::memory_order_relaxed);
inputThread_ = std::thread([this]() {
// In UWP, we add the devices from the main thread, before launching the thread.
// This is a bit awkward but worth the startup speed boost on non-UWP until we refactor it.
#if !PPSSPP_PLATFORM(UWP)
//add first XInput device to respond
AddDevice(new XinputDevice());
AddDevice(new DInputMetaDevice());
AddDevice(new HidInputDevice());
#endif
InputThread();
});
}
+1 -7
View File
@@ -66,9 +66,7 @@
#include "UI/GameInfoCache.h"
#include "Windows/resource.h"
#include "Windows/DinputDevice.h"
#include "Windows/XinputDevice.h"
#include "Windows/HidInputDevice.h"
#include "Windows/InputDevice.h"
#include "Windows/MainWindow.h"
#include "Windows/Debugger/Debugger_Disasm.h"
#include "Windows/Debugger/Debugger_MemoryDlg.h"
@@ -1140,10 +1138,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
MainWindow::Minimize();
}
//add first XInput device to respond
g_InputManager.AddDevice(new XinputDevice());
g_InputManager.AddDevice(new DInputMetaDevice());
g_InputManager.AddDevice(new HidInputDevice());
// Emu thread (and render thread, if any) is always running!
// Only OpenGL uses an externally managed render thread (due to GL's single-threaded context design). Vulkan
// manages its own render thread.