mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-31 21:28:51 +00:00
Implement Cursor Locking and new input focus checks for it
This commit is contained in:
parent
ff08b85740
commit
3c7c2dfaa1
25 changed files with 400 additions and 15 deletions
|
@ -10,6 +10,10 @@
|
|||
|
||||
#include <imgui.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "Common/Common.h"
|
||||
|
||||
#include "Core/Config/MainSettings.h"
|
||||
|
@ -49,6 +53,8 @@ Host* Host::GetInstance()
|
|||
|
||||
void Host::SetRenderHandle(void* handle)
|
||||
{
|
||||
m_render_to_main = Config::Get(Config::MAIN_RENDER_TO_MAIN);
|
||||
|
||||
if (m_render_handle == handle)
|
||||
return;
|
||||
|
||||
|
@ -61,9 +67,27 @@ void Host::SetRenderHandle(void* handle)
|
|||
}
|
||||
}
|
||||
|
||||
void Host::SetMainWindowHandle(void* handle)
|
||||
{
|
||||
m_main_window_handle = handle;
|
||||
}
|
||||
|
||||
bool Host::GetRenderFocus()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// Unfortunately Qt calls SetRenderFocus() with a slight delay compared to what we actually need
|
||||
// to avoid inputs that cause a focus loss to be processed by the emulation
|
||||
if (m_render_to_main)
|
||||
return GetForegroundWindow() == (HWND)m_main_window_handle.load();
|
||||
return GetForegroundWindow() == (HWND)m_render_handle.load();
|
||||
#else
|
||||
return m_render_focus;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Host::GetRenderFullFocus()
|
||||
{
|
||||
return m_render_full_focus;
|
||||
}
|
||||
|
||||
void Host::SetRenderFocus(bool focus)
|
||||
|
@ -76,6 +100,11 @@ void Host::SetRenderFocus(bool focus)
|
|||
});
|
||||
}
|
||||
|
||||
void Host::SetRenderFullFocus(bool focus)
|
||||
{
|
||||
m_render_full_focus = focus;
|
||||
}
|
||||
|
||||
bool Host::GetRenderFullscreen()
|
||||
{
|
||||
return m_render_fullscreen;
|
||||
|
@ -131,6 +160,11 @@ bool Host_RendererHasFocus()
|
|||
return Host::GetInstance()->GetRenderFocus();
|
||||
}
|
||||
|
||||
bool Host_RendererHasFullFocus()
|
||||
{
|
||||
return Host::GetInstance()->GetRenderFullFocus();
|
||||
}
|
||||
|
||||
bool Host_RendererIsFullscreen()
|
||||
{
|
||||
return Host::GetInstance()->GetRenderFullscreen();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue