1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-17 22:36:40 +00:00

Start InputVM Dirty Integration

This commit is contained in:
Isaac Marovitz 2024-04-19 17:55:21 -04:00
parent 3145934efc
commit 95e78f6ee1
No known key found for this signature in database
GPG key ID: 97250B2B09A132E1
2 changed files with 53 additions and 14 deletions

View file

@ -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<InputConfig> ConstructInputConfigList()
{
List<InputConfig> 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()

View file

@ -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;