This commit is contained in:
Dentomologist 2025-07-29 04:13:01 -07:00 committed by GitHub
commit 3ca39c174d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 11 deletions

View File

@ -10,8 +10,6 @@
#include <hidclass.h>
#include <mutex>
#include "Common/Flag.h"
#include "Common/Logging/Log.h"
#include "InputCommon/ControllerInterface/DInput/DInput.h"
@ -20,7 +18,6 @@
#pragma comment(lib, "OneCoreUAP.Lib")
static std::mutex s_populate_mutex;
// TODO is this really needed?
static Common::Flag s_first_populate_devices_asked;
static HCMNOTIFICATION s_notify_handle;
@ -52,7 +49,6 @@ _Pre_satisfies_(EventDataSize >= sizeof(CM_NOTIFY_EVENT_DATA)) static DWORD CALL
// listen for it.
if (s_first_populate_devices_asked.IsSet())
{
std::lock_guard lk_population(s_populate_mutex);
// TODO: we could easily use the message passed alongside this event, which tells
// whether a device was added or removed, to avoid removing old, still connected, devices
g_controller_interface.PlatformPopulateDevices([&] {
@ -96,17 +92,18 @@ InputBackend::InputBackend(ControllerInterface* controller_interface)
void InputBackend::PopulateDevices()
{
std::lock_guard lk_population(s_populate_mutex);
s_first_populate_devices_asked.Set();
ciface::DInput::PopulateDevices(GetHWND());
ciface::XInput::PopulateDevices();
ciface::WGInput::PopulateDevices();
g_controller_interface.PlatformPopulateDevices([this] {
s_first_populate_devices_asked.Set();
ciface::DInput::PopulateDevices(GetHWND());
ciface::XInput::PopulateDevices();
ciface::WGInput::PopulateDevices();
});
}
void InputBackend::HandleWindowChange()
{
std::lock_guard lk_population(s_populate_mutex);
ciface::DInput::ChangeWindow(GetHWND());
g_controller_interface.PlatformPopulateDevices(
[this] { ciface::DInput::ChangeWindow(GetHWND()); });
}
InputBackend::~InputBackend()