mirror of
https://github.com/Ryubing/Ryujinx.git
synced 2025-03-15 05:44:47 +00: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
|
@ -185,6 +185,15 @@ namespace Ryujinx.Input.HLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool InputUpdatesBlocked
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
|
return _blockInputUpdates;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void BlockInputUpdates()
|
public void BlockInputUpdates()
|
||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
|
|
|
@ -3497,6 +3497,31 @@
|
||||||
"zh_TW": "記住視窗大小/位置"
|
"zh_TW": "記住視窗大小/位置"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"ID": "SettingsTabGeneralDisableInputWhenOutOfFocus",
|
||||||
|
"Translations": {
|
||||||
|
"ar_SA": "",
|
||||||
|
"de_DE": "",
|
||||||
|
"el_GR": "",
|
||||||
|
"en_US": "Disable Input when Out of Focus",
|
||||||
|
"es_ES": "",
|
||||||
|
"fr_FR": "",
|
||||||
|
"he_IL": "",
|
||||||
|
"it_IT": "",
|
||||||
|
"ja_JP": "",
|
||||||
|
"ko_KR": "",
|
||||||
|
"no_NO": "Deaktiver inndata når vinduet er ute av fokus",
|
||||||
|
"pl_PL": "",
|
||||||
|
"pt_BR": "",
|
||||||
|
"ru_RU": "",
|
||||||
|
"sv_SE": "",
|
||||||
|
"th_TH": "",
|
||||||
|
"tr_TR": "",
|
||||||
|
"uk_UA": "",
|
||||||
|
"zh_CN": "",
|
||||||
|
"zh_TW": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"ID": "SettingsTabGeneralShowTitleBar",
|
"ID": "SettingsTabGeneralShowTitleBar",
|
||||||
"Translations": {
|
"Translations": {
|
||||||
|
@ -23898,4 +23923,4 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,6 +126,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
public bool EnableDockedMode { get; set; }
|
public bool EnableDockedMode { get; set; }
|
||||||
public bool EnableKeyboard { get; set; }
|
public bool EnableKeyboard { get; set; }
|
||||||
public bool EnableMouse { get; set; }
|
public bool EnableMouse { get; set; }
|
||||||
|
public bool DisableInputWhenOutOfFocus { get; set; }
|
||||||
|
|
||||||
public VSyncMode VSyncMode
|
public VSyncMode VSyncMode
|
||||||
{
|
{
|
||||||
get => _vSyncMode;
|
get => _vSyncMode;
|
||||||
|
@ -498,6 +500,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
EnableDockedMode = config.System.EnableDockedMode;
|
EnableDockedMode = config.System.EnableDockedMode;
|
||||||
EnableKeyboard = config.Hid.EnableKeyboard;
|
EnableKeyboard = config.Hid.EnableKeyboard;
|
||||||
EnableMouse = config.Hid.EnableMouse;
|
EnableMouse = config.Hid.EnableMouse;
|
||||||
|
DisableInputWhenOutOfFocus = config.Hid.DisableInputWhenOutOfFocus;
|
||||||
|
|
||||||
// Keyboard Hotkeys
|
// Keyboard Hotkeys
|
||||||
KeyboardHotkey = new HotkeyConfig(config.Hid.Hotkeys.Value);
|
KeyboardHotkey = new HotkeyConfig(config.Hid.Hotkeys.Value);
|
||||||
|
@ -609,6 +612,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
config.System.EnableDockedMode.Value = EnableDockedMode;
|
config.System.EnableDockedMode.Value = EnableDockedMode;
|
||||||
config.Hid.EnableKeyboard.Value = EnableKeyboard;
|
config.Hid.EnableKeyboard.Value = EnableKeyboard;
|
||||||
config.Hid.EnableMouse.Value = EnableMouse;
|
config.Hid.EnableMouse.Value = EnableMouse;
|
||||||
|
config.Hid.DisableInputWhenOutOfFocus.Value = DisableInputWhenOutOfFocus;
|
||||||
|
|
||||||
// Keyboard Hotkeys
|
// Keyboard Hotkeys
|
||||||
config.Hid.Hotkeys.Value = KeyboardHotkey.GetConfig();
|
config.Hid.Hotkeys.Value = KeyboardHotkey.GetConfig();
|
||||||
|
|
|
@ -37,6 +37,9 @@
|
||||||
<CheckBox IsChecked="{Binding RememberWindowState}">
|
<CheckBox IsChecked="{Binding RememberWindowState}">
|
||||||
<TextBlock Text="{ext:Locale SettingsTabGeneralRememberWindowState}" />
|
<TextBlock Text="{ext:Locale SettingsTabGeneralRememberWindowState}" />
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
|
<CheckBox IsChecked="{Binding DisableInputWhenOutOfFocus}">
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabGeneralDisableInputWhenOutOfFocus}" />
|
||||||
|
</CheckBox>
|
||||||
<CheckBox IsChecked="{Binding ShowTitleBar}" IsVisible="{x:Static helper:RunningPlatform.IsWindows}">
|
<CheckBox IsChecked="{Binding ShowTitleBar}" IsVisible="{x:Static helper:RunningPlatform.IsWindows}">
|
||||||
<TextBlock Text="{ext:Locale SettingsTabGeneralShowTitleBar}" />
|
<TextBlock Text="{ext:Locale SettingsTabGeneralShowTitleBar}" />
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
x:DataType="viewModels:MainWindowViewModel"
|
x:DataType="viewModels:MainWindowViewModel"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
WindowStartupLocation="Manual"
|
WindowStartupLocation="Manual"
|
||||||
Focusable="True">
|
Focusable="True"
|
||||||
|
GotFocus="InputElement_OnGotFocus"
|
||||||
|
LostFocus="InputElement_OnLostFocus">
|
||||||
<Window.Styles>
|
<Window.Styles>
|
||||||
<Style Selector="TitleBar:fullscreen">
|
<Style Selector="TitleBar:fullscreen">
|
||||||
<Setter Property="Background" Value="#000000" />
|
<Setter Property="Background" Value="#000000" />
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
|
using Avalonia.Input;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Platform;
|
using Avalonia.Platform;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
|
@ -761,5 +762,34 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
|
|
||||||
_intelMacWarningShown = true;
|
_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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current version of the file format
|
/// The current version of the file format
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int CurrentVersion = 65;
|
public const int CurrentVersion = 66;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Version of the configuration file format
|
/// Version of the configuration file format
|
||||||
|
@ -383,6 +383,11 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
||||||
/// Enable or disable mouse support (Independent from controllers binding)
|
/// Enable or disable mouse support (Independent from controllers binding)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableMouse { get; set; }
|
public bool EnableMouse { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enable/disable the ability to control Ryujinx when it's not the currently focused window.
|
||||||
|
/// </summary>
|
||||||
|
public bool DisableInputWhenOutOfFocus { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hotkey Keyboard Bindings
|
/// Hotkey Keyboard Bindings
|
||||||
|
|
|
@ -139,6 +139,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
||||||
|
|
||||||
Hid.EnableKeyboard.Value = cff.EnableKeyboard;
|
Hid.EnableKeyboard.Value = cff.EnableKeyboard;
|
||||||
Hid.EnableMouse.Value = cff.EnableMouse;
|
Hid.EnableMouse.Value = cff.EnableMouse;
|
||||||
|
Hid.DisableInputWhenOutOfFocus.Value = cff.DisableInputWhenOutOfFocus;
|
||||||
Hid.Hotkeys.Value = cff.Hotkeys;
|
Hid.Hotkeys.Value = cff.Hotkeys;
|
||||||
Hid.InputConfig.Value = cff.InputConfig ?? [];
|
Hid.InputConfig.Value = cff.InputConfig ?? [];
|
||||||
Hid.RainbowSpeed.Value = cff.RainbowSpeed;
|
Hid.RainbowSpeed.Value = cff.RainbowSpeed;
|
||||||
|
@ -433,7 +434,8 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
||||||
(62, static cff => cff.RainbowSpeed = 1f),
|
(62, static cff => cff.RainbowSpeed = 1f),
|
||||||
(63, static cff => cff.MatchSystemTime = false),
|
(63, static cff => cff.MatchSystemTime = false),
|
||||||
(64, static cff => cff.LoggingEnableAvalonia = false),
|
(64, static cff => cff.LoggingEnableAvalonia = false),
|
||||||
(65, static cff => cff.UpdateCheckerType = cff.CheckUpdatesOnStart ? UpdaterType.PromptAtStartup : UpdaterType.Off)
|
(65, static cff => cff.UpdateCheckerType = cff.CheckUpdatesOnStart ? UpdaterType.PromptAtStartup : UpdaterType.Off),
|
||||||
|
(66, static cff => cff.DisableInputWhenOutOfFocus = false)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -447,6 +447,11 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
||||||
/// Enable or disable mouse support (Independent from controllers binding)
|
/// Enable or disable mouse support (Independent from controllers binding)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ReactiveObject<bool> EnableMouse { get; private set; }
|
public ReactiveObject<bool> EnableMouse { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enable/disable the ability to control Ryujinx when it's not the currently focused window.
|
||||||
|
/// </summary>
|
||||||
|
public ReactiveObject<bool> DisableInputWhenOutOfFocus { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hotkey Keyboard Bindings
|
/// Hotkey Keyboard Bindings
|
||||||
|
@ -469,6 +474,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
||||||
{
|
{
|
||||||
EnableKeyboard = new ReactiveObject<bool>();
|
EnableKeyboard = new ReactiveObject<bool>();
|
||||||
EnableMouse = new ReactiveObject<bool>();
|
EnableMouse = new ReactiveObject<bool>();
|
||||||
|
DisableInputWhenOutOfFocus = new ReactiveObject<bool>();
|
||||||
Hotkeys = new ReactiveObject<KeyboardHotkeys>();
|
Hotkeys = new ReactiveObject<KeyboardHotkeys>();
|
||||||
InputConfig = new ReactiveObject<List<InputConfig>>();
|
InputConfig = new ReactiveObject<List<InputConfig>>();
|
||||||
RainbowSpeed = new ReactiveObject<float>();
|
RainbowSpeed = new ReactiveObject<float>();
|
||||||
|
|
|
@ -131,6 +131,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
||||||
ShowConsole = UI.ShowConsole,
|
ShowConsole = UI.ShowConsole,
|
||||||
EnableKeyboard = Hid.EnableKeyboard,
|
EnableKeyboard = Hid.EnableKeyboard,
|
||||||
EnableMouse = Hid.EnableMouse,
|
EnableMouse = Hid.EnableMouse,
|
||||||
|
DisableInputWhenOutOfFocus = Hid.DisableInputWhenOutOfFocus,
|
||||||
Hotkeys = Hid.Hotkeys,
|
Hotkeys = Hid.Hotkeys,
|
||||||
InputConfig = Hid.InputConfig,
|
InputConfig = Hid.InputConfig,
|
||||||
RainbowSpeed = Hid.RainbowSpeed,
|
RainbowSpeed = Hid.RainbowSpeed,
|
||||||
|
@ -245,6 +246,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
||||||
UI.WindowStartup.WindowMaximized.Value = false;
|
UI.WindowStartup.WindowMaximized.Value = false;
|
||||||
Hid.EnableKeyboard.Value = false;
|
Hid.EnableKeyboard.Value = false;
|
||||||
Hid.EnableMouse.Value = false;
|
Hid.EnableMouse.Value = false;
|
||||||
|
Hid.DisableInputWhenOutOfFocus.Value = false;
|
||||||
Hid.Hotkeys.Value = new KeyboardHotkeys
|
Hid.Hotkeys.Value = new KeyboardHotkeys
|
||||||
{
|
{
|
||||||
ToggleVSyncMode = Key.F1,
|
ToggleVSyncMode = Key.F1,
|
||||||
|
|
Loading…
Add table
Reference in a new issue