mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-28 06:46:24 +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
|
@ -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