mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-24 15:07:10 +02:00
UI: setting: Disable Input when Out of Focus
This commit is contained in:
parent
8aecccadb8
commit
501b199e24
10 changed files with 92 additions and 4 deletions
|
@ -126,6 +126,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
public bool EnableDockedMode { get; set; }
|
||||
public bool EnableKeyboard { get; set; }
|
||||
public bool EnableMouse { get; set; }
|
||||
public bool DisableInputWhenOutOfFocus { get; set; }
|
||||
|
||||
public VSyncMode VSyncMode
|
||||
{
|
||||
get => _vSyncMode;
|
||||
|
@ -498,6 +500,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
EnableDockedMode = config.System.EnableDockedMode;
|
||||
EnableKeyboard = config.Hid.EnableKeyboard;
|
||||
EnableMouse = config.Hid.EnableMouse;
|
||||
DisableInputWhenOutOfFocus = config.Hid.DisableInputWhenOutOfFocus;
|
||||
|
||||
// Keyboard Hotkeys
|
||||
KeyboardHotkey = new HotkeyConfig(config.Hid.Hotkeys.Value);
|
||||
|
@ -609,6 +612,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
config.System.EnableDockedMode.Value = EnableDockedMode;
|
||||
config.Hid.EnableKeyboard.Value = EnableKeyboard;
|
||||
config.Hid.EnableMouse.Value = EnableMouse;
|
||||
config.Hid.DisableInputWhenOutOfFocus.Value = DisableInputWhenOutOfFocus;
|
||||
|
||||
// Keyboard Hotkeys
|
||||
config.Hid.Hotkeys.Value = KeyboardHotkey.GetConfig();
|
||||
|
|
|
@ -37,6 +37,9 @@
|
|||
<CheckBox IsChecked="{Binding RememberWindowState}">
|
||||
<TextBlock Text="{ext:Locale SettingsTabGeneralRememberWindowState}" />
|
||||
</CheckBox>
|
||||
<CheckBox IsChecked="{Binding DisableInputWhenOutOfFocus}">
|
||||
<TextBlock Text="{ext:Locale SettingsTabGeneralDisableInputWhenOutOfFocus}" />
|
||||
</CheckBox>
|
||||
<CheckBox IsChecked="{Binding ShowTitleBar}" IsVisible="{x:Static helper:RunningPlatform.IsWindows}">
|
||||
<TextBlock Text="{ext:Locale SettingsTabGeneralShowTitleBar}" />
|
||||
</CheckBox>
|
||||
|
|
|
@ -21,7 +21,9 @@
|
|||
x:DataType="viewModels:MainWindowViewModel"
|
||||
mc:Ignorable="d"
|
||||
WindowStartupLocation="Manual"
|
||||
Focusable="True">
|
||||
Focusable="True"
|
||||
GotFocus="InputElement_OnGotFocus"
|
||||
LostFocus="InputElement_OnLostFocus">
|
||||
<Window.Styles>
|
||||
<Style Selector="TitleBar:fullscreen">
|
||||
<Setter Property="Background" Value="#000000" />
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform;
|
||||
using Avalonia.Threading;
|
||||
|
@ -761,5 +762,34 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
_intelMacWarningShown = true;
|
||||
}
|
||||
|
||||
private void InputElement_OnGotFocus(object sender, GotFocusEventArgs e)
|
||||
{
|
||||
if (!_didDisableInputUpdates)
|
||||
return;
|
||||
|
||||
if (!ConfigurationState.Instance.Hid.DisableInputWhenOutOfFocus)
|
||||
return;
|
||||
|
||||
if (ViewModel.AppHost is not { NpadManager.InputUpdatesBlocked: true } appHost)
|
||||
return;
|
||||
|
||||
appHost.NpadManager.UnblockInputUpdates();
|
||||
_didDisableInputUpdates = appHost.NpadManager.InputUpdatesBlocked;
|
||||
}
|
||||
|
||||
private bool _didDisableInputUpdates;
|
||||
|
||||
private void InputElement_OnLostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!ConfigurationState.Instance.Hid.DisableInputWhenOutOfFocus)
|
||||
return;
|
||||
|
||||
if (ViewModel.AppHost is not { NpadManager.InputUpdatesBlocked: false } appHost)
|
||||
return;
|
||||
|
||||
appHost.NpadManager.BlockInputUpdates();
|
||||
_didDisableInputUpdates = appHost.NpadManager.InputUpdatesBlocked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue