diff --git a/src/Ryujinx/UI/ViewModels/Settings/SettingsHotkeysViewModel.cs b/src/Ryujinx/UI/ViewModels/Settings/SettingsHotkeysViewModel.cs
new file mode 100644
index 0000000000..181ec986c4
--- /dev/null
+++ b/src/Ryujinx/UI/ViewModels/Settings/SettingsHotkeysViewModel.cs
@@ -0,0 +1,45 @@
+using Ryujinx.Ava.UI.Models.Input;
+using Ryujinx.UI.Common.Configuration;
+using System;
+
+namespace Ryujinx.Ava.UI.ViewModels.Settings
+{
+ public class SettingsHotkeysViewModel : BaseModel
+ {
+ public event Action DirtyEvent;
+
+ public HotkeyConfig KeyboardHotkey { get; set; }
+
+ public SettingsHotkeysViewModel()
+ {
+ ConfigurationState config = ConfigurationState.Instance;
+
+ KeyboardHotkey = new HotkeyConfig(config.Hid.Hotkeys.Value);
+ KeyboardHotkey.PropertyChanged += (_, _) => DirtyEvent?.Invoke();
+ }
+
+ public bool CheckIfModified(ConfigurationState config)
+ {
+ bool isDirty = false;
+
+ var hotkeys = KeyboardHotkey.GetConfig();
+
+ isDirty |= config.Hid.Hotkeys.Value.ToggleVsync != hotkeys.ToggleVsync;
+ isDirty |= config.Hid.Hotkeys.Value.Screenshot != hotkeys.Screenshot;
+ isDirty |= config.Hid.Hotkeys.Value.ShowUI != hotkeys.ShowUI;
+ isDirty |= config.Hid.Hotkeys.Value.Pause != hotkeys.Pause;
+ isDirty |= config.Hid.Hotkeys.Value.ToggleMute != hotkeys.ToggleMute;
+ isDirty |= config.Hid.Hotkeys.Value.ResScaleUp != hotkeys.ResScaleUp;
+ isDirty |= config.Hid.Hotkeys.Value.ResScaleDown != hotkeys.ResScaleDown;
+ isDirty |= config.Hid.Hotkeys.Value.VolumeUp != hotkeys.VolumeUp;
+ isDirty |= config.Hid.Hotkeys.Value.VolumeDown != hotkeys.VolumeDown;
+
+ return isDirty;
+ }
+
+ public void Save(ConfigurationState config)
+ {
+ config.Hid.Hotkeys.Value = KeyboardHotkey.GetConfig();
+ }
+ }
+}
diff --git a/src/Ryujinx/UI/ViewModels/Settings/SettingsViewModel.cs b/src/Ryujinx/UI/ViewModels/Settings/SettingsViewModel.cs
index 6957e4f09d..f75beae2df 100644
--- a/src/Ryujinx/UI/ViewModels/Settings/SettingsViewModel.cs
+++ b/src/Ryujinx/UI/ViewModels/Settings/SettingsViewModel.cs
@@ -14,7 +14,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
-using System.Runtime.InteropServices;
using System.Threading.Tasks;
using TimeZone = Ryujinx.Ava.UI.Models.TimeZone;
@@ -173,6 +172,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
private readonly SettingsCpuViewModel _cpuViewModel;
private readonly SettingsGraphicsViewModel _graphicsViewModel;
private readonly SettingsLoggingViewModel _loggingViewModel;
+ private readonly SettingsHotkeysViewModel _hotkeysViewModel;
public DateTimeOffset CurrentDate { get; set; }
public TimeSpan CurrentTime { get; set; }
@@ -185,8 +185,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
get => new(_networkInterfaces.Keys);
}
- public HotkeyConfig KeyboardHotkey { get; set; }
-
public int NetworkInterfaceIndex
{
get => _networkInterfaceIndex;
@@ -213,6 +211,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
SettingsAudioViewModel audioViewModel,
SettingsCpuViewModel cpuViewModel,
SettingsGraphicsViewModel graphicsViewModel,
+ SettingsHotkeysViewModel hotkeysViewModel,
SettingsLoggingViewModel loggingViewModel) : this()
{
_virtualFileSystem = virtualFileSystem;
@@ -221,11 +220,13 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
_audioViewModel = audioViewModel;
_cpuViewModel = cpuViewModel;
_graphicsViewModel = graphicsViewModel;
+ _hotkeysViewModel = hotkeysViewModel;
_loggingViewModel = loggingViewModel;
_audioViewModel.DirtyEvent += CheckIfModified;
_cpuViewModel.DirtyEvent += CheckIfModified;
_graphicsViewModel.DirtyEvent += CheckIfModified;
+ _hotkeysViewModel.DirtyEvent += CheckIfModified;
_loggingViewModel.DirtyEvent += CheckIfModified;
if (Program.PreviewerDetached)
@@ -282,6 +283,11 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
isDirty |= config.System.ExpandRam.Value != ExpandDramSize;
isDirty |= config.System.IgnoreMissingServices.Value != IgnoreMissingServices;
+ if (_audioViewModel != null)
+ {
+ isDirty |= _audioViewModel.CheckIfModified(config);
+ }
+
if (_cpuViewModel != null)
{
isDirty |= _cpuViewModel.CheckIfModified(config);
@@ -292,10 +298,11 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
isDirty |= _graphicsViewModel.CheckIfModified(config);
}
- if (_audioViewModel != null)
+ if (_hotkeysViewModel != null)
{
- isDirty |= _audioViewModel.CheckIfModified(config);
+ isDirty |= _hotkeysViewModel.CheckIfModified(config);
}
+
// Network
isDirty |= config.System.EnableInternetAccess.Value != EnableInternetAccess;
@@ -376,9 +383,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
BaseStyleIndex = config.UI.BaseStyle == "Light" ? 0 : 1;
- // Keyboard Hotkeys
- KeyboardHotkey = new HotkeyConfig(config.Hid.Hotkeys.Value);
-
// System
Region = (int)config.System.Region.Value;
Language = (int)config.System.Language.Value;
@@ -419,8 +423,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
config.UI.BaseStyle.Value = BaseStyleIndex == 0 ? "Light" : "Dark";
- // Keyboard Hotkeys
- config.Hid.Hotkeys.Value = KeyboardHotkey.GetConfig();
// System
config.System.Region.Value = (Region)Region;
@@ -440,6 +442,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
_audioViewModel?.Save(config);
_cpuViewModel?.Save(config);
_graphicsViewModel?.Save(config);
+ _hotkeysViewModel?.Save(config);
// Network
config.System.EnableInternetAccess.Value = EnableInternetAccess;
diff --git a/src/Ryujinx/UI/Views/Settings/SettingsHotkeysView.axaml b/src/Ryujinx/UI/Views/Settings/SettingsHotkeysView.axaml
index 795546df61..40b5d1b78b 100644
--- a/src/Ryujinx/UI/Views/Settings/SettingsHotkeysView.axaml
+++ b/src/Ryujinx/UI/Views/Settings/SettingsHotkeysView.axaml
@@ -8,11 +8,11 @@
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels.Settings"
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
mc:Ignorable="d"
- x:DataType="viewModels:SettingsViewModel"
+ x:DataType="viewModels:SettingsHotkeysViewModel"
x:CompileBindings="True"
Focusable="True">
-
+
diff --git a/src/Ryujinx/UI/Views/Settings/SettingsHotkeysView.axaml.cs b/src/Ryujinx/UI/Views/Settings/SettingsHotkeysView.axaml.cs
index 748bb0c6ea..085957eec1 100644
--- a/src/Ryujinx/UI/Views/Settings/SettingsHotkeysView.axaml.cs
+++ b/src/Ryujinx/UI/Views/Settings/SettingsHotkeysView.axaml.cs
@@ -14,18 +14,14 @@ namespace Ryujinx.Ava.UI.Views.Settings
{
public partial class SettingsHotkeysView : UserControl
{
- private readonly SettingsViewModel _viewModel;
+ public SettingsHotkeysViewModel ViewModel;
+
private ButtonKeyAssigner _currentAssigner;
private readonly IGamepadDriver _avaloniaKeyboardDriver;
public SettingsHotkeysView()
{
-
- }
-
- public SettingsHotkeysView(SettingsViewModel viewModel)
- {
- _viewModel = viewModel;
+ DataContext = ViewModel = new SettingsHotkeysViewModel();
InitializeComponent();
@@ -90,31 +86,31 @@ namespace Ryujinx.Ava.UI.Views.Settings
switch (button.Name)
{
case "ToggleVsync":
- _viewModel.KeyboardHotkey.ToggleVsync = buttonValue.AsHidType();
+ ViewModel.KeyboardHotkey.ToggleVsync = buttonValue.AsHidType();
break;
case "Screenshot":
- _viewModel.KeyboardHotkey.Screenshot = buttonValue.AsHidType();
+ ViewModel.KeyboardHotkey.Screenshot = buttonValue.AsHidType();
break;
case "ShowUI":
- _viewModel.KeyboardHotkey.ShowUI = buttonValue.AsHidType();
+ ViewModel.KeyboardHotkey.ShowUI = buttonValue.AsHidType();
break;
case "Pause":
- _viewModel.KeyboardHotkey.Pause = buttonValue.AsHidType();
+ ViewModel.KeyboardHotkey.Pause = buttonValue.AsHidType();
break;
case "ToggleMute":
- _viewModel.KeyboardHotkey.ToggleMute = buttonValue.AsHidType();
+ ViewModel.KeyboardHotkey.ToggleMute = buttonValue.AsHidType();
break;
case "ResScaleUp":
- _viewModel.KeyboardHotkey.ResScaleUp = buttonValue.AsHidType();
+ ViewModel.KeyboardHotkey.ResScaleUp = buttonValue.AsHidType();
break;
case "ResScaleDown":
- _viewModel.KeyboardHotkey.ResScaleDown = buttonValue.AsHidType();
+ ViewModel.KeyboardHotkey.ResScaleDown = buttonValue.AsHidType();
break;
case "VolumeUp":
- _viewModel.KeyboardHotkey.VolumeUp = buttonValue.AsHidType();
+ ViewModel.KeyboardHotkey.VolumeUp = buttonValue.AsHidType();
break;
case "VolumeDown":
- _viewModel.KeyboardHotkey.VolumeDown = buttonValue.AsHidType();
+ ViewModel.KeyboardHotkey.VolumeDown = buttonValue.AsHidType();
break;
}
}
diff --git a/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs b/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs
index ebdbd4a999..55fb70fa35 100644
--- a/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs
+++ b/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs
@@ -32,6 +32,7 @@ namespace Ryujinx.Ava.UI.Windows
AudioPage = new SettingsAudioView();
CpuPage = new SettingsCpuView();
GraphicsPage = new SettingsGraphicsView();
+ HotkeysPage = new SettingsHotkeysView();
LoggingPage = new SettingsLoggingView();
ViewModel = new SettingsViewModel(
@@ -40,11 +41,11 @@ namespace Ryujinx.Ava.UI.Windows
AudioPage.ViewModel,
CpuPage.ViewModel,
GraphicsPage.ViewModel,
+ HotkeysPage.ViewModel,
LoggingPage.ViewModel);
UiPage = new SettingsUiView(ViewModel);
InputPage = new SettingsInputView(ViewModel);
- HotkeysPage = new SettingsHotkeysView(ViewModel);
SystemPage = new SettingsSystemView(ViewModel);
NetworkPage = new SettingsNetworkView();