mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-26 18:43:04 +00:00
Start InputVM Dirty Integration
This commit is contained in:
parent
3145934efc
commit
95e78f6ee1
2 changed files with 53 additions and 14 deletions
|
@ -54,7 +54,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
|
||||||
private object _configViewModel;
|
private object _configViewModel;
|
||||||
private string _profileName;
|
private string _profileName;
|
||||||
private bool _isLoaded;
|
private bool _isLoaded;
|
||||||
private bool _enableDockedMode;
|
|
||||||
|
|
||||||
private static readonly InputConfigJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
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 IsRight { get; set; }
|
||||||
public bool IsLeft { get; set; }
|
public bool IsLeft { get; set; }
|
||||||
|
|
||||||
|
private bool _enableDockedMode;
|
||||||
public bool EnableDockedMode
|
public bool EnableDockedMode
|
||||||
{
|
{
|
||||||
get => _enableDockedMode;
|
get => _enableDockedMode;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_enableDockedMode = value;
|
_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;
|
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)
|
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();
|
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);
|
return newInputConfig;
|
||||||
|
|
||||||
// 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 void NotifyChanges()
|
public void NotifyChanges()
|
||||||
|
@ -875,6 +914,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
|
||||||
OnPropertyChanged(nameof(IsRight));
|
OnPropertyChanged(nameof(IsRight));
|
||||||
OnPropertyChanged(nameof(IsLeft));
|
OnPropertyChanged(nameof(IsLeft));
|
||||||
NotifyChangesEvent?.Invoke();
|
NotifyChangesEvent?.Invoke();
|
||||||
|
DirtyEvent?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
|
@ -76,8 +76,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
|
||||||
isDirty |= _cpuViewModel?.CheckIfModified(config) ?? false;
|
isDirty |= _cpuViewModel?.CheckIfModified(config) ?? false;
|
||||||
isDirty |= _graphicsViewModel?.CheckIfModified(config) ?? false;
|
isDirty |= _graphicsViewModel?.CheckIfModified(config) ?? false;
|
||||||
isDirty |= _hotkeysViewModel?.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 |= _loggingViewModel?.CheckIfModified(config) ?? false;
|
||||||
isDirty |= _networkViewModel?.CheckIfModified(config) ?? false;
|
isDirty |= _networkViewModel?.CheckIfModified(config) ?? false;
|
||||||
isDirty |= _systemViewModel?.CheckIfModified(config) ?? false;
|
isDirty |= _systemViewModel?.CheckIfModified(config) ?? false;
|
||||||
|
|
Loading…
Reference in a new issue