Misc: Backports from PCSX2 UI
This commit is contained in:
@ -478,6 +478,11 @@ void NoGUIHost::PlatformWindowFocusLost()
|
||||
});
|
||||
}
|
||||
|
||||
void NoGUIHost::PlatformDevicesChanged()
|
||||
{
|
||||
Host::RunOnCPUThread([]() { InputManager::ReloadDevices(); });
|
||||
}
|
||||
|
||||
bool NoGUIHost::GetSavedPlatformWindowGeometry(s32* x, s32* y, s32* width, s32* height)
|
||||
{
|
||||
auto lock = Host::GetSettingsLock();
|
||||
@ -687,6 +692,11 @@ bool NoGUIHost::AcquireHostDisplay(RenderAPI api)
|
||||
return false;
|
||||
}
|
||||
|
||||
// reload input sources, since it might use the window handle
|
||||
{
|
||||
auto lock = Host::GetSettingsLock();
|
||||
InputManager::ReloadSources(*Host::GetSettingsInterface(), lock);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -708,6 +718,9 @@ void NoGUIHost::ReleaseHostDisplay()
|
||||
if (!g_host_display)
|
||||
return;
|
||||
|
||||
// close input sources, since it might use the window handle
|
||||
InputManager::CloseSources();
|
||||
|
||||
CommonHost::ReleaseHostDisplayResources();
|
||||
ImGuiManager::Shutdown();
|
||||
g_host_display.reset();
|
||||
|
||||
@ -30,6 +30,7 @@ void ProcessPlatformKeyEvent(s32 key, bool pressed);
|
||||
void ProcessPlatformTextEvent(const char* text);
|
||||
void PlatformWindowFocusGained();
|
||||
void PlatformWindowFocusLost();
|
||||
void PlatformDevicesChanged();
|
||||
bool GetSavedPlatformWindowGeometry(s32* x, s32* y, s32* width, s32* height);
|
||||
void SavePlatformWindowGeometry(s32 x, s32 y, s32 width, s32 height);
|
||||
} // namespace NoGUIHost
|
||||
@ -9,6 +9,7 @@
|
||||
#include "nogui_host.h"
|
||||
#include "resource.h"
|
||||
#include "win32_key_names.h"
|
||||
#include <Dbt.h>
|
||||
#include <shellapi.h>
|
||||
#include <tchar.h>
|
||||
Log_SetChannel(Win32HostInterface);
|
||||
@ -122,6 +123,11 @@ bool Win32NoGUIPlatform::CreatePlatformWindow(std::string title)
|
||||
if (m_fullscreen.load(std::memory_order_acquire))
|
||||
SetFullscreen(true);
|
||||
|
||||
// We use these notifications to detect when a controller is connected or disconnected.
|
||||
DEV_BROADCAST_DEVICEINTERFACE_W filter = {sizeof(DEV_BROADCAST_DEVICEINTERFACE_W), DBT_DEVTYP_DEVICEINTERFACE};
|
||||
m_dev_notify_handle =
|
||||
RegisterDeviceNotificationW(hwnd, &filter, DEVICE_NOTIFY_WINDOW_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -130,6 +136,12 @@ void Win32NoGUIPlatform::DestroyPlatformWindow()
|
||||
if (!m_hwnd)
|
||||
return;
|
||||
|
||||
if (m_dev_notify_handle)
|
||||
{
|
||||
UnregisterDeviceNotification(m_dev_notify_handle);
|
||||
m_dev_notify_handle = NULL;
|
||||
}
|
||||
|
||||
RECT rc;
|
||||
if (!m_fullscreen.load(std::memory_order_acquire) && GetWindowRect(m_hwnd, &rc))
|
||||
{
|
||||
@ -393,6 +405,13 @@ LRESULT CALLBACK Win32NoGUIPlatform::WndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_DEVICECHANGE:
|
||||
{
|
||||
if (wParam == DBT_DEVNODES_CHANGED)
|
||||
NoGUIHost::PlatformDevicesChanged();
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_FUNC:
|
||||
{
|
||||
std::function<void()>* pfunc = reinterpret_cast<std::function<void()>*>(lParam);
|
||||
|
||||
@ -59,4 +59,6 @@ private:
|
||||
std::atomic_bool m_fullscreen{false};
|
||||
|
||||
DWORD m_last_mouse_buttons = 0;
|
||||
|
||||
HDEVNOTIFY m_dev_notify_handle = NULL;
|
||||
};
|
||||
Reference in New Issue
Block a user