Implement Cursor Locking and new input focus checks for it

This commit is contained in:
Filoppi committed 2021-05-27 10:31:12 +03:00
1 parent ff08b85740
commit 3c7c2dfaa1
25 files changed
+400 -15

No files matched your search

+2
View File
@@ -147,6 +147,7 @@ void SConfig::SaveInterfaceSettings(IniFile& ini)
interface->Set("ConfirmStop", bConfirmStop);
interface->Set("HideCursor", bHideCursor);
interface->Set("LockCursor", bLockCursor);
interface->Set("LanguageCode", m_InterfaceLanguage);
interface->Set("ExtendedFPSInfo", m_InterfaceExtendedFPSInfo);
interface->Set("ShowActiveTitle", m_show_active_title);
@@ -401,6 +402,7 @@ void SConfig::LoadInterfaceSettings(IniFile& ini)
interface->Get("ConfirmStop", &bConfirmStop, true);
interface->Get("HideCursor", &bHideCursor, false);
interface->Get("LockCursor", &bLockCursor, false);
interface->Get("LanguageCode", &m_InterfaceLanguage, "");
interface->Get("ExtendedFPSInfo", &m_InterfaceExtendedFPSInfo, false);
interface->Get("ShowActiveTitle", &m_show_active_title, true);
+1
View File
@@ -150,6 +150,7 @@ struct SConfig
// Interface settings
bool bConfirmStop = false;
bool bHideCursor = false;
bool bLockCursor = false;
std::string theme_name;
// Bluetooth passthrough mode settings
+8 -3
View File
@@ -1113,10 +1113,15 @@ void DoFrameStep()
}
}
void UpdateInputGate(bool require_focus)
void UpdateInputGate(bool require_focus, bool require_full_focus)
{
ControlReference::SetInputGate((!require_focus || Host_RendererHasFocus()) &&
!Host_UIBlocksControllerState());
// If the user accepts background input, controls should pass even if an on screen interface is on
const bool focus_passes =
!require_focus || (Host_RendererHasFocus() && !Host_UIBlocksControllerState());
// Ignore full focus if we don't require basic focus
const bool full_focus_passes =
!require_focus || !require_full_focus || (focus_passes && Host_RendererHasFullFocus());
ControlReference::SetInputGate(focus_passes && full_focus_passes);
}
} // namespace Core
+1 -1
View File
@@ -169,6 +169,6 @@ void HostDispatchJobs();
void DoFrameStep();
void UpdateInputGate(bool require_focus);
void UpdateInputGate(bool require_focus, bool require_full_focus = false);
} // namespace Core
+2 -1
View File
@@ -867,7 +867,8 @@ void Update(u64 ticks)
if (s_half_line_of_next_si_poll == s_half_line_count)
{
Core::UpdateInputGate(!SConfig::GetInstance().m_BackgroundInput);
Core::UpdateInputGate(!SConfig::GetInstance().m_BackgroundInput,
SConfig::GetInstance().bLockCursor);
SerialInterface::UpdateDevices();
s_half_line_of_next_si_poll += 2 * SerialInterface::GetPollXLines();
}
+1
View File
@@ -36,6 +36,7 @@ enum class HostMessageID
std::vector<std::string> Host_GetPreferredLocales();
bool Host_UIBlocksControllerState();
bool Host_RendererHasFocus();
bool Host_RendererHasFullFocus();
bool Host_RendererIsFullscreen();
void Host_Message(HostMessageID id);
+2 -1
View File
@@ -24,7 +24,7 @@
#include "InputCommon/GCPadStatus.h"
// clang-format off
constexpr std::array<const char*, 125> s_hotkey_labels{{
constexpr std::array<const char*, 126> s_hotkey_labels{{
_trans("Open"),
_trans("Change Disc"),
_trans("Eject Disc"),
@@ -35,6 +35,7 @@ constexpr std::array<const char*, 125> s_hotkey_labels{{
_trans("Toggle Fullscreen"),
_trans("Take Screenshot"),
_trans("Exit"),
_trans("Unlock Cursor"),
_trans("Activate NetPlay Chat"),
_trans("Control NetPlay Golf Mode"),
+1
View File
@@ -29,6 +29,7 @@ enum Hotkey
HK_FULLSCREEN,
HK_SCREENSHOT,
HK_EXIT,
HK_UNLOCK_CURSOR,
HK_ACTIVATE_CHAT,
HK_REQUEST_GOLF_CONTROL,