mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-11-19 09:21:15 +01:00
UI: setting: Disable Input when Out of Focus
- chore: rename InputElement_OnGotFocus/OnLostFocus to fit what it's listening to better
This commit is contained in:
1 parent
a9bf7644eb
commit
d765814a1b
19 files changed
+86
-2
No files matched your search
@@ -189,6 +189,15 @@ namespace Ryujinx.Input.HLE
|
||||
}
|
||||
}
|
||||
|
||||
public bool InputUpdatesBlocked
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _blockInputUpdates;
|
||||
}
|
||||
}
|
||||
|
||||
public void BlockInputUpdates()
|
||||
{
|
||||
lock (_lock)
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||
/// <summary>
|
||||
/// The current version of the file format
|
||||
/// </summary>
|
||||
public const int CurrentVersion = 62;
|
||||
public const int CurrentVersion = 63;
|
||||
|
||||
/// <summary>
|
||||
/// Version of the configuration file format
|
||||
@@ -415,6 +415,11 @@ namespace Ryujinx.UI.Common.Configuration
|
||||
/// </summary>
|
||||
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>
|
||||
/// Hotkey Keyboard Bindings
|
||||
/// </summary>
|
||||
|
||||
@@ -477,6 +477,11 @@ namespace Ryujinx.UI.Common.Configuration
|
||||
/// </summary>
|
||||
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>
|
||||
/// Hotkey Keyboard Bindings
|
||||
/// </summary>
|
||||
@@ -493,6 +498,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||
{
|
||||
EnableKeyboard = new ReactiveObject<bool>();
|
||||
EnableMouse = new ReactiveObject<bool>();
|
||||
DisableInputWhenOutOfFocus = new ReactiveObject<bool>();
|
||||
Hotkeys = new ReactiveObject<KeyboardHotkeys>();
|
||||
InputConfig = new ReactiveObject<List<InputConfig>>();
|
||||
}
|
||||
@@ -937,6 +943,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||
ShowConsole = UI.ShowConsole,
|
||||
EnableKeyboard = Hid.EnableKeyboard,
|
||||
EnableMouse = Hid.EnableMouse,
|
||||
DisableInputWhenOutOfFocus = Hid.DisableInputWhenOutOfFocus,
|
||||
Hotkeys = Hid.Hotkeys,
|
||||
KeyboardConfig = [],
|
||||
ControllerConfig = [],
|
||||
@@ -1058,6 +1065,8 @@ namespace Ryujinx.UI.Common.Configuration
|
||||
UI.WindowStartup.WindowMaximized.Value = false;
|
||||
Hid.EnableKeyboard.Value = false;
|
||||
Hid.EnableMouse.Value = false;
|
||||
Hid.DisableInputWhenOutOfFocus.Value = false;
|
||||
|
||||
Hid.Hotkeys.Value = new KeyboardHotkeys
|
||||
{
|
||||
ToggleVSyncMode = Key.F1,
|
||||
@@ -1823,6 +1832,15 @@ namespace Ryujinx.UI.Common.Configuration
|
||||
configurationFileUpdated = true;
|
||||
}
|
||||
|
||||
if (configurationFileFormat.Version < 63)
|
||||
{
|
||||
Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 63.");
|
||||
|
||||
configurationFileFormat.DisableInputWhenOutOfFocus = false;
|
||||
|
||||
configurationFileUpdated = true;
|
||||
}
|
||||
|
||||
Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
|
||||
Graphics.ResScale.Value = configurationFileFormat.ResScale;
|
||||
Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
|
||||
@@ -1922,6 +1940,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||
UI.WindowStartup.WindowMaximized.Value = configurationFileFormat.WindowStartup.WindowMaximized;
|
||||
Hid.EnableKeyboard.Value = configurationFileFormat.EnableKeyboard;
|
||||
Hid.EnableMouse.Value = configurationFileFormat.EnableMouse;
|
||||
Hid.DisableInputWhenOutOfFocus.Value = configurationFileFormat.DisableInputWhenOutOfFocus;
|
||||
Hid.Hotkeys.Value = configurationFileFormat.Hotkeys;
|
||||
Hid.InputConfig.Value = configurationFileFormat.InputConfig;
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@
|
||||
"SettingsTabGeneralCheckUpdatesOnLaunch": "Beim Start nach Updates suchen",
|
||||
"SettingsTabGeneralShowConfirmExitDialog": "Zeige den \"Beenden bestätigen\"-Dialog",
|
||||
"SettingsTabGeneralRememberWindowState": "Fenstergröße/-position merken",
|
||||
"SettingsTabGeneralDisableInputWhenOutOfFocus": "Eingabe deaktivieren wenn nicht fokussiert",
|
||||
"SettingsTabGeneralHideCursor": "Mauszeiger ausblenden",
|
||||
"SettingsTabGeneralHideCursorNever": "Niemals",
|
||||
"SettingsTabGeneralHideCursorOnIdle": "Mauszeiger bei Inaktivität ausblenden",
|
||||
|
||||
@@ -115,6 +115,7 @@
|
||||
"SettingsTabGeneralCheckUpdatesOnLaunch": "Check for Updates on Launch",
|
||||
"SettingsTabGeneralShowConfirmExitDialog": "Show \"Confirm Exit\" Dialog",
|
||||
"SettingsTabGeneralRememberWindowState": "Remember Window Size/Position",
|
||||
"SettingsTabGeneralDisableInputWhenOutOfFocus": "Disable Input when Out of Focus",
|
||||
"SettingsTabGeneralHideCursor": "Hide Cursor:",
|
||||
"SettingsTabGeneralHideCursorNever": "Never",
|
||||
"SettingsTabGeneralHideCursorOnIdle": "On Idle",
|
||||
|
||||
@@ -107,6 +107,7 @@
|
||||
"SettingsTabGeneralCheckUpdatesOnLaunch": "Buscar actualizaciones al iniciar",
|
||||
"SettingsTabGeneralShowConfirmExitDialog": "Mostrar diálogo de confirmación al cerrar",
|
||||
"SettingsTabGeneralRememberWindowState": "Remember Window Size/Position",
|
||||
"SettingsTabGeneralDisableInputWhenOutOfFocus": "Desactivar la Entrada al Perder el Foco",
|
||||
"SettingsTabGeneralHideCursor": "Esconder el cursor:",
|
||||
"SettingsTabGeneralHideCursorNever": "Nunca",
|
||||
"SettingsTabGeneralHideCursorOnIdle": "Ocultar cursor cuando esté inactivo",
|
||||
|
||||
@@ -107,6 +107,7 @@
|
||||
"SettingsTabGeneralCheckUpdatesOnLaunch": "Vérifier les mises à jour au démarrage",
|
||||
"SettingsTabGeneralShowConfirmExitDialog": "Afficher le message de \"Confirmation de sortie\"",
|
||||
"SettingsTabGeneralRememberWindowState": "Mémoriser la taille/position de la fenêtre",
|
||||
"SettingsTabGeneralDisableInputWhenOutOfFocus": "Désactiver la Saisie en cas de Perte de Focus",
|
||||
"SettingsTabGeneralHideCursor": "Masquer le Curseur :",
|
||||
"SettingsTabGeneralHideCursorNever": "Jamais",
|
||||
"SettingsTabGeneralHideCursorOnIdle": "Masquer le curseur si inactif",
|
||||
|
||||
@@ -114,6 +114,7 @@
|
||||
"SettingsTabGeneralCheckUpdatesOnLaunch": "Controlla aggiornamenti all'avvio",
|
||||
"SettingsTabGeneralShowConfirmExitDialog": "Mostra dialogo \"Conferma Uscita\"",
|
||||
"SettingsTabGeneralRememberWindowState": "Ricorda la dimensione e la posizione della finestra",
|
||||
"SettingsTabGeneralDisableInputWhenOutOfFocus": "Disabilità Input quando fuori dal focus",
|
||||
"SettingsTabGeneralHideCursor": "Nascondi il cursore:",
|
||||
"SettingsTabGeneralHideCursorNever": "Mai",
|
||||
"SettingsTabGeneralHideCursorOnIdle": "Quando è inattivo",
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
"SettingsTabGeneralCheckUpdatesOnLaunch": "시작 시, 업데이트 확인",
|
||||
"SettingsTabGeneralShowConfirmExitDialog": "\"종료 확인\" 대화 상자 표시",
|
||||
"SettingsTabGeneralRememberWindowState": "창 크기/위치 기억",
|
||||
"SettingsTabGeneralDisableInputWhenOutOfFocus": "초점이 맞지 않으면 입력 비활성화",
|
||||
"SettingsTabGeneralHideCursor": "마우스 커서 숨기기",
|
||||
"SettingsTabGeneralHideCursorNever": "절대 안 함",
|
||||
"SettingsTabGeneralHideCursorOnIdle": "유휴 상태",
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
"SettingsTabGeneralCheckUpdatesOnLaunch": "Verificar se há atualizações ao iniciar",
|
||||
"SettingsTabGeneralShowConfirmExitDialog": "Exibir diálogo de confirmação ao sair",
|
||||
"SettingsTabGeneralRememberWindowState": "Lembrar tamanho/posição da Janela",
|
||||
"SettingsTabGeneralDisableInputWhenOutOfFocus": "Desativar Controles Quando Estiver Fora de Foco",
|
||||
"SettingsTabGeneralHideCursor": "Esconder o cursor do mouse:",
|
||||
"SettingsTabGeneralHideCursorNever": "Nunca",
|
||||
"SettingsTabGeneralHideCursorOnIdle": "Esconder o cursor quando ocioso",
|
||||
|
||||
@@ -114,6 +114,7 @@
|
||||
"SettingsTabGeneralCheckUpdatesOnLaunch": "Проверять наличие обновлений при запуске",
|
||||
"SettingsTabGeneralShowConfirmExitDialog": "Подтверждать выход из приложения",
|
||||
"SettingsTabGeneralRememberWindowState": "Запомнить размер/положение окна",
|
||||
"SettingsTabGeneralDisableInputWhenOutOfFocus": "Отключить ввод при потере фокуса",
|
||||
"SettingsTabGeneralHideCursor": "Скрывать курсор",
|
||||
"SettingsTabGeneralHideCursorNever": "Никогда",
|
||||
"SettingsTabGeneralHideCursorOnIdle": "В простое",
|
||||
|
||||
@@ -107,6 +107,7 @@
|
||||
"SettingsTabGeneralCheckUpdatesOnLaunch": "ตรวจหาการอัปเดตเมื่อเปิดโปรแกรม",
|
||||
"SettingsTabGeneralShowConfirmExitDialog": "แสดง \"ยืนยันการออก\" กล่องข้อความโต้ตอบ",
|
||||
"SettingsTabGeneralRememberWindowState": "Remember Window Size/Position",
|
||||
"SettingsTabGeneralDisableInputWhenOutOfFocus": "ปิดการพิมพ์เมื่อไม่ได้เลือกช่องอินพุต ไม่ให้กรอกข้อมูลเมื่อช่องอินพุตไม่อยู่ในโฟกัส",
|
||||
"SettingsTabGeneralHideCursor": "ซ่อน เคอร์เซอร์:",
|
||||
"SettingsTabGeneralHideCursorNever": "ไม่มี",
|
||||
"SettingsTabGeneralHideCursorOnIdle": "เมื่อไม่ได้ใช้",
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
"SettingsTabGeneralCheckUpdatesOnLaunch": "Перевіряти наявність оновлень під час запуску",
|
||||
"SettingsTabGeneralShowConfirmExitDialog": "Показати діалогове вікно «Підтвердити вихід».",
|
||||
"SettingsTabGeneralRememberWindowState": "Remember Window Size/Position",
|
||||
"SettingsTabGeneralDisableInputWhenOutOfFocus": "Вимкнути введення, якщо вікно неактивне",
|
||||
"SettingsTabGeneralHideCursor": "Сховати вказівник:",
|
||||
"SettingsTabGeneralHideCursorNever": "Ніколи",
|
||||
"SettingsTabGeneralHideCursorOnIdle": "Сховати у режимі очікування",
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
"SettingsTabGeneralCheckUpdatesOnLaunch": "启动时检查更新",
|
||||
"SettingsTabGeneralShowConfirmExitDialog": "退出游戏时需要确认",
|
||||
"SettingsTabGeneralRememberWindowState": "记住窗口大小和位置",
|
||||
"SettingsTabGeneralDisableInputWhenOutOfFocus": "在后台时禁用输入",
|
||||
"SettingsTabGeneralHideCursor": "隐藏鼠标指针:",
|
||||
"SettingsTabGeneralHideCursorNever": "从不隐藏",
|
||||
"SettingsTabGeneralHideCursorOnIdle": "自动隐藏",
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
"SettingsTabGeneralCheckUpdatesOnLaunch": "啟動時檢查更新",
|
||||
"SettingsTabGeneralShowConfirmExitDialog": "顯示「確認結束」對話方塊",
|
||||
"SettingsTabGeneralRememberWindowState": "記住視窗大小/位置",
|
||||
"SettingsTabGeneralDisableInputWhenOutOfFocus": "在「失去焦點」時停用輸入",
|
||||
"SettingsTabGeneralHideCursor": "隱藏滑鼠游標:",
|
||||
"SettingsTabGeneralHideCursorNever": "從不",
|
||||
"SettingsTabGeneralHideCursorOnIdle": "閒置時",
|
||||
|
||||
@@ -152,6 +152,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;
|
||||
@@ -592,6 +594,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);
|
||||
@@ -715,6 +718,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();
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
<CheckBox IsChecked="{Binding RememberWindowState}">
|
||||
<TextBlock Text="{locale:Locale SettingsTabGeneralRememberWindowState}" />
|
||||
</CheckBox>
|
||||
<CheckBox IsChecked="{Binding DisableInputWhenOutOfFocus}">
|
||||
<TextBlock Text="{locale:Locale SettingsTabGeneralDisableInputWhenOutOfFocus}" />
|
||||
</CheckBox>
|
||||
<StackPanel Margin="0, 15, 0, 0" Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Text="{locale:Locale SettingsTabGeneralHideCursor}"
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
x:DataType="viewModels:MainWindowViewModel"
|
||||
mc:Ignorable="d"
|
||||
WindowStartupLocation="Manual"
|
||||
Focusable="True">
|
||||
Focusable="True"
|
||||
GotFocus="AppWindow_OnGotFocus"
|
||||
LostFocus="AppWindow_OnLostFocus">
|
||||
<Window.Styles>
|
||||
<Style Selector="WindowDrawnDecorations:fullscreen /template/ Border">
|
||||
<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;
|
||||
@@ -749,5 +750,34 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
msg, "", "", "", LocaleManager.Instance[LocaleKeys.InputDialogOk], (int)FASymbol.Checkmark);
|
||||
});
|
||||
}
|
||||
|
||||
private void AppWindow_OnGotFocus(object sender, FocusChangedEventArgs 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 AppWindow_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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user