diff --git a/src/Ryujinx/UI/ViewModels/Settings/SettingsInputViewModel.cs b/src/Ryujinx/UI/ViewModels/Settings/SettingsInputViewModel.cs index 06da4a55c..32a6c749a 100644 --- a/src/Ryujinx/UI/ViewModels/Settings/SettingsInputViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/Settings/SettingsInputViewModel.cs @@ -54,7 +54,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings private object _configViewModel; private string _profileName; private bool _isLoaded; - private bool _enableDockedMode; private static readonly InputConfigJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions()); @@ -74,16 +73,38 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings public bool IsRight { get; set; } public bool IsLeft { get; set; } + private bool _enableDockedMode; public bool EnableDockedMode { get => _enableDockedMode; set { _enableDockedMode = value; + DirtyEvent?.Invoke(); + } + } + + private bool _enableKeyboard; + public bool EnableKeyboard + { + get => _enableKeyboard; + set + { + _enableKeyboard = value; + DirtyEvent?.Invoke(); + } + } + + private bool _enableMouse; + public bool EnableMouse + { + get => _enableMouse; + set + { + _enableMouse = value; + DirtyEvent?.Invoke(); } } - public bool EnableKeyboard { get; set; } - public bool EnableMouse { get; set; } public event Action NotifyChangesEvent; @@ -811,7 +832,33 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings } } + public bool CheckIfModified(ConfigurationState config) + { + bool isDirty = false; + + isDirty |= config.System.EnableDockedMode.Value != EnableDockedMode; + isDirty |= config.Hid.EnableKeyboard.Value != EnableKeyboard; + isDirty |= config.Hid.EnableMouse.Value != EnableMouse; + + return isDirty; + } + public void Save(ConfigurationState config) + { + var newInputConfig = ConstructInputConfigList(); + + _mainWindow.ViewModel.AppHost?.NpadManager.ReloadConfiguration(newInputConfig, ConfigurationState.Instance.Hid.EnableKeyboard, ConfigurationState.Instance.Hid.EnableMouse); + + // Atomically replace and signal input change. + // NOTE: Do not modify InputConfig.Value directly as other code depends on the on-change event. + config.Hid.InputConfig.Value = newInputConfig; + + config.System.EnableDockedMode.Value = EnableDockedMode; + config.Hid.EnableKeyboard.Value = EnableKeyboard; + config.Hid.EnableMouse.Value = EnableMouse; + } + + public List ConstructInputConfigList() { List newInputConfig = new(); @@ -855,15 +902,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings } } - _mainWindow.ViewModel.AppHost?.NpadManager.ReloadConfiguration(newInputConfig, ConfigurationState.Instance.Hid.EnableKeyboard, ConfigurationState.Instance.Hid.EnableMouse); - - // Atomically replace and signal input change. - // NOTE: Do not modify InputConfig.Value directly as other code depends on the on-change event. - config.Hid.InputConfig.Value = newInputConfig; - - config.System.EnableDockedMode.Value = EnableDockedMode; - config.Hid.EnableKeyboard.Value = EnableKeyboard; - config.Hid.EnableMouse.Value = EnableMouse; + return newInputConfig; } public void NotifyChanges() @@ -875,6 +914,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings OnPropertyChanged(nameof(IsRight)); OnPropertyChanged(nameof(IsLeft)); NotifyChangesEvent?.Invoke(); + DirtyEvent?.Invoke(); } public void Dispose() diff --git a/src/Ryujinx/UI/ViewModels/Settings/SettingsViewModel.cs b/src/Ryujinx/UI/ViewModels/Settings/SettingsViewModel.cs index d3ed3d02d..d72f9a709 100644 --- a/src/Ryujinx/UI/ViewModels/Settings/SettingsViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/Settings/SettingsViewModel.cs @@ -76,8 +76,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings isDirty |= _cpuViewModel?.CheckIfModified(config) ?? false; isDirty |= _graphicsViewModel?.CheckIfModified(config) ?? false; isDirty |= _hotkeysViewModel?.CheckIfModified(config) ?? false; - // TODO: IMPLEMENT THIS!! - // isDirty |= _inputViewModel?.CheckIfModified(config) ?? false; + isDirty |= _inputViewModel?.CheckIfModified(config) ?? false; isDirty |= _loggingViewModel?.CheckIfModified(config) ?? false; isDirty |= _networkViewModel?.CheckIfModified(config) ?? false; isDirty |= _systemViewModel?.CheckIfModified(config) ?? false;