This commit is contained in:
Premo 2024-09-20 17:19:25 +02:00 committed by GitHub
commit 5756c87407
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 175 additions and 160 deletions

View file

@ -67,10 +67,10 @@ namespace Ryujinx.UI
private readonly CancellationTokenSource _gpuCancellationTokenSource; private readonly CancellationTokenSource _gpuCancellationTokenSource;
// Hide Cursor // Hide Cursor
const int CursorHideIdleTime = 5; // seconds
private static readonly Cursor _invisibleCursor = new(Display.Default, CursorType.BlankCursor); private static readonly Cursor _invisibleCursor = new(Display.Default, CursorType.BlankCursor);
private long _lastCursorMoveTime; private long _lastCursorMoveTime;
private HideCursorMode _hideCursorMode; private HideCursorMode _hideCursorMode;
private int _hideCursorIdleTime;
private readonly InputManager _inputManager; private readonly InputManager _inputManager;
private readonly IKeyboard _keyboardInterface; private readonly IKeyboard _keyboardInterface;
private readonly GraphicsDebugLevel _glLogLevel; private readonly GraphicsDebugLevel _glLogLevel;
@ -113,9 +113,12 @@ namespace Ryujinx.UI
_gpuCancellationTokenSource = new CancellationTokenSource(); _gpuCancellationTokenSource = new CancellationTokenSource();
_hideCursorMode = ConfigurationState.Instance.HideCursor; _hideCursorMode = ConfigurationState.Instance.HideCursor;
_hideCursorIdleTime = ConfigurationState.Instance.HideCursorIdleTime;
_lastCursorMoveTime = Stopwatch.GetTimestamp(); _lastCursorMoveTime = Stopwatch.GetTimestamp();
ConfigurationState.Instance.HideCursor.Event += HideCursorStateChanged; ConfigurationState.Instance.HideCursor.Event += HideCursorStateChanged;
ConfigurationState.Instance.HideCursorIdleTime.Event += HideCursorIdleTimeStateChanged;
ConfigurationState.Instance.Graphics.AntiAliasing.Event += UpdateAnriAliasing; ConfigurationState.Instance.Graphics.AntiAliasing.Event += UpdateAnriAliasing;
ConfigurationState.Instance.Graphics.ScalingFilter.Event += UpdateScalingFilter; ConfigurationState.Instance.Graphics.ScalingFilter.Event += UpdateScalingFilter;
ConfigurationState.Instance.Graphics.ScalingFilterLevel.Event += UpdateScalingFilterLevel; ConfigurationState.Instance.Graphics.ScalingFilterLevel.Event += UpdateScalingFilterLevel;
@ -167,9 +170,18 @@ namespace Ryujinx.UI
}); });
} }
private void HideCursorIdleTimeStateChanged(object sender, ReactiveEventArgs<int> state)
{
Application.Invoke(delegate
{
_hideCursorIdleTime = state.NewValue;
});
}
private void Renderer_Destroyed(object sender, EventArgs e) private void Renderer_Destroyed(object sender, EventArgs e)
{ {
ConfigurationState.Instance.HideCursor.Event -= HideCursorStateChanged; ConfigurationState.Instance.HideCursor.Event -= HideCursorStateChanged;
ConfigurationState.Instance.HideCursorIdleTime.Event -= HideCursorIdleTimeStateChanged;
ConfigurationState.Instance.Graphics.AntiAliasing.Event -= UpdateAnriAliasing; ConfigurationState.Instance.Graphics.AntiAliasing.Event -= UpdateAnriAliasing;
ConfigurationState.Instance.Graphics.ScalingFilter.Event -= UpdateScalingFilter; ConfigurationState.Instance.Graphics.ScalingFilter.Event -= UpdateScalingFilter;
ConfigurationState.Instance.Graphics.ScalingFilterLevel.Event -= UpdateScalingFilterLevel; ConfigurationState.Instance.Graphics.ScalingFilterLevel.Event -= UpdateScalingFilterLevel;
@ -332,7 +344,7 @@ namespace Ryujinx.UI
{ {
case HideCursorMode.OnIdle: case HideCursorMode.OnIdle:
long cursorMoveDelta = Stopwatch.GetTimestamp() - _lastCursorMoveTime; long cursorMoveDelta = Stopwatch.GetTimestamp() - _lastCursorMoveTime;
Window.Cursor = (cursorMoveDelta >= CursorHideIdleTime * Stopwatch.Frequency) ? _invisibleCursor : null; Window.Cursor = (cursorMoveDelta >= _hideCursorIdleTime * Stopwatch.Frequency) ? _invisibleCursor : null;
break; break;
case HideCursorMode.Always: case HideCursorMode.Always:
Window.Cursor = _invisibleCursor; Window.Cursor = _invisibleCursor;

View file

@ -53,9 +53,9 @@ namespace Ryujinx.UI.Windows
[GUI] CheckButton _discordToggle; [GUI] CheckButton _discordToggle;
[GUI] CheckButton _checkUpdatesToggle; [GUI] CheckButton _checkUpdatesToggle;
[GUI] CheckButton _showConfirmExitToggle; [GUI] CheckButton _showConfirmExitToggle;
[GUI] RadioButton _hideCursorNever; [GUI] ComboBoxText _hideCursorSelect;
[GUI] RadioButton _hideCursorOnIdle; [GUI] Box _hideCursorIdleTimeBox;
[GUI] RadioButton _hideCursorAlways; [GUI] Entry _hideCursorIdleTimeSpin;
[GUI] CheckButton _vSyncToggle; [GUI] CheckButton _vSyncToggle;
[GUI] CheckButton _shaderCacheToggle; [GUI] CheckButton _shaderCacheToggle;
[GUI] CheckButton _textureRecompressionToggle; [GUI] CheckButton _textureRecompressionToggle;
@ -147,6 +147,7 @@ namespace Ryujinx.UI.Windows
_configureControllerH.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Handheld); _configureControllerH.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Handheld);
_systemTimeZoneEntry.FocusOutEvent += TimeZoneEntry_FocusOut; _systemTimeZoneEntry.FocusOutEvent += TimeZoneEntry_FocusOut;
_hideCursorSelect.Changed += (sender, args) => _hideCursorIdleTimeBox.Visible = _hideCursorSelect.ActiveId == HideCursorMode.OnIdle.ToString();
_resScaleCombo.Changed += (sender, args) => _resScaleText.Visible = _resScaleCombo.ActiveId == "-1"; _resScaleCombo.Changed += (sender, args) => _resScaleText.Visible = _resScaleCombo.ActiveId == "-1";
_scalingFilter.Changed += (sender, args) => _scalingFilterSlider.Visible = _scalingFilter.ActiveId == "2"; _scalingFilter.Changed += (sender, args) => _scalingFilterSlider.Visible = _scalingFilter.ActiveId == "2";
_galThreading.Changed += (sender, args) => _galThreading.Changed += (sender, args) =>
@ -230,19 +231,6 @@ namespace Ryujinx.UI.Windows
_showConfirmExitToggle.Click(); _showConfirmExitToggle.Click();
} }
switch (ConfigurationState.Instance.HideCursor.Value)
{
case HideCursorMode.Never:
_hideCursorNever.Click();
break;
case HideCursorMode.OnIdle:
_hideCursorOnIdle.Click();
break;
case HideCursorMode.Always:
_hideCursorAlways.Click();
break;
}
if (ConfigurationState.Instance.Graphics.EnableVsync) if (ConfigurationState.Instance.Graphics.EnableVsync)
{ {
_vSyncToggle.Click(); _vSyncToggle.Click();
@ -349,6 +337,7 @@ namespace Ryujinx.UI.Windows
_systemTimeZoneCompletion.MatchFunc = TimeZoneMatchFunc; _systemTimeZoneCompletion.MatchFunc = TimeZoneMatchFunc;
_hideCursorSelect.SetActiveId(ConfigurationState.Instance.HideCursor.Value.ToString());
_systemLanguageSelect.SetActiveId(ConfigurationState.Instance.System.Language.Value.ToString()); _systemLanguageSelect.SetActiveId(ConfigurationState.Instance.System.Language.Value.ToString());
_systemRegionSelect.SetActiveId(ConfigurationState.Instance.System.Region.Value.ToString()); _systemRegionSelect.SetActiveId(ConfigurationState.Instance.System.Region.Value.ToString());
_galThreading.SetActiveId(ConfigurationState.Instance.Graphics.BackendThreading.Value.ToString()); _galThreading.SetActiveId(ConfigurationState.Instance.Graphics.BackendThreading.Value.ToString());
@ -366,6 +355,8 @@ namespace Ryujinx.UI.Windows
_multiLanSelect.SetActiveId(ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value); _multiLanSelect.SetActiveId(ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value);
_multiModeSelect.SetActiveId(ConfigurationState.Instance.Multiplayer.Mode.Value.ToString()); _multiModeSelect.SetActiveId(ConfigurationState.Instance.Multiplayer.Mode.Value.ToString());
_hideCursorIdleTimeBox.Visible = _hideCursorSelect.ActiveId == HideCursorMode.OnIdle.ToString();
_hideCursorIdleTimeSpin.Buffer.Text = ConfigurationState.Instance.HideCursorIdleTime.Value.ToString();
_custThemePath.Buffer.Text = ConfigurationState.Instance.UI.CustomThemePath; _custThemePath.Buffer.Text = ConfigurationState.Instance.UI.CustomThemePath;
_resScaleText.Buffer.Text = ConfigurationState.Instance.Graphics.ResScaleCustom.Value.ToString(); _resScaleText.Buffer.Text = ConfigurationState.Instance.Graphics.ResScaleCustom.Value.ToString();
_scalingFilterLevel.Value = ConfigurationState.Instance.Graphics.ScalingFilterLevel.Value; _scalingFilterLevel.Value = ConfigurationState.Instance.Graphics.ScalingFilterLevel.Value;
@ -573,18 +564,6 @@ namespace Ryujinx.UI.Windows
_directoryChanged = false; _directoryChanged = false;
} }
HideCursorMode hideCursor = HideCursorMode.Never;
if (_hideCursorOnIdle.Active)
{
hideCursor = HideCursorMode.OnIdle;
}
if (_hideCursorAlways.Active)
{
hideCursor = HideCursorMode.Always;
}
if (!float.TryParse(_resScaleText.Buffer.Text, out float resScaleCustom) || resScaleCustom <= 0.0f) if (!float.TryParse(_resScaleText.Buffer.Text, out float resScaleCustom) || resScaleCustom <= 0.0f)
{ {
resScaleCustom = 1.0f; resScaleCustom = 1.0f;
@ -627,7 +606,8 @@ namespace Ryujinx.UI.Windows
ConfigurationState.Instance.EnableDiscordIntegration.Value = _discordToggle.Active; ConfigurationState.Instance.EnableDiscordIntegration.Value = _discordToggle.Active;
ConfigurationState.Instance.CheckUpdatesOnStart.Value = _checkUpdatesToggle.Active; ConfigurationState.Instance.CheckUpdatesOnStart.Value = _checkUpdatesToggle.Active;
ConfigurationState.Instance.ShowConfirmExit.Value = _showConfirmExitToggle.Active; ConfigurationState.Instance.ShowConfirmExit.Value = _showConfirmExitToggle.Active;
ConfigurationState.Instance.HideCursor.Value = hideCursor; ConfigurationState.Instance.HideCursor.Value = Enum.Parse<HideCursorMode>(_hideCursorSelect.ActiveId);
ConfigurationState.Instance.HideCursorIdleTime.Value = int.Parse(_hideCursorIdleTimeSpin.Buffer.Text);
ConfigurationState.Instance.Graphics.EnableVsync.Value = _vSyncToggle.Active; ConfigurationState.Instance.Graphics.EnableVsync.Value = _vSyncToggle.Active;
ConfigurationState.Instance.Graphics.EnableShaderCache.Value = _shaderCacheToggle.Active; ConfigurationState.Instance.Graphics.EnableShaderCache.Value = _shaderCacheToggle.Active;
ConfigurationState.Instance.Graphics.EnableTextureRecompression.Value = _textureRecompressionToggle.Active; ConfigurationState.Instance.Graphics.EnableTextureRecompression.Value = _textureRecompressionToggle.Active;

View file

@ -2,6 +2,12 @@
<!-- Generated with glade 3.40.0 --> <!-- Generated with glade 3.40.0 -->
<interface> <interface>
<requires lib="gtk+" version="3.20"/> <requires lib="gtk+" version="3.20"/>
<object class="GtkAdjustment" id="_hideCursorIdleTimeSpinAdjustment">
<property name="lower">1</property>
<property name="upper">10</property>
<property name="step-increment">1</property>
<property name="page-increment">1</property>
</object>
<object class="GtkAdjustment" id="_fsLogSpinAdjustment"> <object class="GtkAdjustment" id="_fsLogSpinAdjustment">
<property name="upper">3</property> <property name="upper">3</property>
<property name="step-increment">1</property> <property name="step-increment">1</property>
@ -168,6 +174,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="halign">end</property> <property name="halign">end</property>
<property name="tooltip-text" translatable="yes">Whether to hide cursor on idle, always or never</property>
<property name="label" translatable="yes">Hide Cursor:</property> <property name="label" translatable="yes">Hide Cursor:</property>
</object> </object>
<packing> <packing>
@ -178,16 +185,16 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkRadioButton" id="_hideCursorNever"> <object class="GtkComboBoxText" id="_hideCursorSelect">
<property name="label" translatable="yes">Never</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="receives-default">False</property> <property name="width-request">100</property>
<property name="halign">start</property> <property name="tooltip-text" translatable="yes">Whether to hide cursor on idle, always or never</property>
<property name="margin-top">5</property> <items>
<property name="margin-bottom">5</property> <item id="Never" translatable="yes">Never</item>
<property name="active">True</property> <item id="OnIdle" translatable="yes">On Idle</item>
<property name="draw-indicator">True</property> <item id="Always" translatable="yes">Always</item>
</items>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -196,16 +203,17 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkRadioButton" id="_hideCursorOnIdle"> <object class="GtkBox" id="_hideCursorIdleTimeBox">
<property name="label" translatable="yes">On Idle</property> <property name="visible">False</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">False</property>
<property name="receives-default">False</property> <property name="margin-left">10</property>
<property name="halign">start</property> <property name="margin-right">5</property>
<property name="margin-top">5</property> <property name="tooltip-text" translatable="yes">How many seconds to wait before hiding the cursor</property>
<property name="margin-bottom">5</property> <property name="label" translatable="yes">Seconds:</property>
<property name="draw-indicator">True</property>
<property name="group">_hideCursorNever</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -214,26 +222,24 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkRadioButton" id="_hideCursorAlways"> <object class="GtkSpinButton" id="_hideCursorIdleTimeSpin">
<property name="label" translatable="yes">Always</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="receives-default">False</property> <property name="tooltip-text" translatable="yes">How many seconds to wait before hiding the cursor</property>
<property name="halign">start</property> <property name="text" translatable="yes">0</property>
<property name="margin-top">5</property> <property name="adjustment">_hideCursorIdleTimeSpinAdjustment</property>
<property name="margin-bottom">5</property>
<property name="draw-indicator">True</property>
<property name="group">_hideCursorNever</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">False</property>
<property name="position">5</property> <property name="position">5</property>
</packing> </packing>
</child> </child>
</object> </object>
</child>
</object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="padding">5</property> <property name="padding">5</property>
<property name="position">4</property> <property name="position">4</property>

View file

@ -177,6 +177,11 @@ namespace Ryujinx.UI.Common.Configuration
/// </summary> /// </summary>
public HideCursorMode HideCursor { get; set; } public HideCursorMode HideCursor { get; set; }
/// <summary>
/// How many seconds to wait before hiding the cursor when set to hide on idle
/// </summary>
public int HideCursorIdleTime { get; set; }
/// <summary> /// <summary>
/// Enables or disables Vertical Sync /// Enables or disables Vertical Sync
/// </summary> /// </summary>

View file

@ -638,10 +638,15 @@ namespace Ryujinx.UI.Common.Configuration
public ReactiveObject<bool> EnableHardwareAcceleration { get; private set; } public ReactiveObject<bool> EnableHardwareAcceleration { get; private set; }
/// <summary> /// <summary>
/// Hide Cursor on Idle /// Whether to hide cursor on idle, always or never
/// </summary> /// </summary>
public ReactiveObject<HideCursorMode> HideCursor { get; private set; } public ReactiveObject<HideCursorMode> HideCursor { get; private set; }
/// <summary>
/// How many seconds to wait before hiding the cursor when set to hide on idle
/// </summary>
public ReactiveObject<int> HideCursorIdleTime { get; private set; }
private ConfigurationState() private ConfigurationState()
{ {
UI = new UISection(); UI = new UISection();
@ -656,6 +661,7 @@ namespace Ryujinx.UI.Common.Configuration
RememberWindowState = new ReactiveObject<bool>(); RememberWindowState = new ReactiveObject<bool>();
EnableHardwareAcceleration = new ReactiveObject<bool>(); EnableHardwareAcceleration = new ReactiveObject<bool>();
HideCursor = new ReactiveObject<HideCursorMode>(); HideCursor = new ReactiveObject<HideCursorMode>();
HideCursorIdleTime = new ReactiveObject<int>();
} }
public ConfigurationFileFormat ToFileFormat() public ConfigurationFileFormat ToFileFormat()
@ -694,6 +700,7 @@ namespace Ryujinx.UI.Common.Configuration
RememberWindowState = RememberWindowState, RememberWindowState = RememberWindowState,
EnableHardwareAcceleration = EnableHardwareAcceleration, EnableHardwareAcceleration = EnableHardwareAcceleration,
HideCursor = HideCursor, HideCursor = HideCursor,
HideCursorIdleTime = HideCursorIdleTime,
EnableVsync = Graphics.EnableVsync, EnableVsync = Graphics.EnableVsync,
EnableShaderCache = Graphics.EnableShaderCache, EnableShaderCache = Graphics.EnableShaderCache,
EnableTextureRecompression = Graphics.EnableTextureRecompression, EnableTextureRecompression = Graphics.EnableTextureRecompression,
@ -803,6 +810,7 @@ namespace Ryujinx.UI.Common.Configuration
RememberWindowState.Value = true; RememberWindowState.Value = true;
EnableHardwareAcceleration.Value = true; EnableHardwareAcceleration.Value = true;
HideCursor.Value = HideCursorMode.OnIdle; HideCursor.Value = HideCursorMode.OnIdle;
HideCursorIdleTime.Value = 5;
Graphics.EnableVsync.Value = true; Graphics.EnableVsync.Value = true;
Graphics.EnableShaderCache.Value = true; Graphics.EnableShaderCache.Value = true;
Graphics.EnableTextureRecompression.Value = false; Graphics.EnableTextureRecompression.Value = false;
@ -1510,6 +1518,7 @@ namespace Ryujinx.UI.Common.Configuration
RememberWindowState.Value = configurationFileFormat.RememberWindowState; RememberWindowState.Value = configurationFileFormat.RememberWindowState;
EnableHardwareAcceleration.Value = configurationFileFormat.EnableHardwareAcceleration; EnableHardwareAcceleration.Value = configurationFileFormat.EnableHardwareAcceleration;
HideCursor.Value = configurationFileFormat.HideCursor; HideCursor.Value = configurationFileFormat.HideCursor;
HideCursorIdleTime.Value = configurationFileFormat.HideCursorIdleTime;
Graphics.EnableVsync.Value = configurationFileFormat.EnableVsync; Graphics.EnableVsync.Value = configurationFileFormat.EnableVsync;
Graphics.EnableShaderCache.Value = configurationFileFormat.EnableShaderCache; Graphics.EnableShaderCache.Value = configurationFileFormat.EnableShaderCache;
Graphics.EnableTextureRecompression.Value = configurationFileFormat.EnableTextureRecompression; Graphics.EnableTextureRecompression.Value = configurationFileFormat.EnableTextureRecompression;

View file

@ -133,6 +133,7 @@ namespace Ryujinx.Ava.UI.ViewModels
public bool ShowConfirmExit { get; set; } public bool ShowConfirmExit { get; set; }
public bool RememberWindowState { get; set; } public bool RememberWindowState { get; set; }
public int HideCursor { get; set; } public int HideCursor { get; set; }
public int HideCursorIdleTime { get; set; }
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; }
@ -393,6 +394,7 @@ namespace Ryujinx.Ava.UI.ViewModels
ShowConfirmExit = config.ShowConfirmExit; ShowConfirmExit = config.ShowConfirmExit;
RememberWindowState = config.RememberWindowState; RememberWindowState = config.RememberWindowState;
HideCursor = (int)config.HideCursor.Value; HideCursor = (int)config.HideCursor.Value;
HideCursorIdleTime = (int)config.HideCursorIdleTime.Value;
GameDirectories.Clear(); GameDirectories.Clear();
GameDirectories.AddRange(config.UI.GameDirs.Value); GameDirectories.AddRange(config.UI.GameDirs.Value);
@ -485,6 +487,7 @@ namespace Ryujinx.Ava.UI.ViewModels
config.ShowConfirmExit.Value = ShowConfirmExit; config.ShowConfirmExit.Value = ShowConfirmExit;
config.RememberWindowState.Value = RememberWindowState; config.RememberWindowState.Value = RememberWindowState;
config.HideCursor.Value = (HideCursorMode)HideCursor; config.HideCursor.Value = (HideCursorMode)HideCursor;
config.HideCursorIdleTime.Value = HideCursorIdleTime;
if (_directoryChanged) if (_directoryChanged)
{ {