misc: Move configuration management to the Ryujinx project (#2269)

* Decouple configuration from Ryujinx.HLE and Ryujinx.Input

* Move Configuration to the Ryujinx project
This commit is contained in:
Mary 2021-05-16 17:12:14 +02:00 committed by GitHub
parent f48828351c
commit bec67dbef7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 387 additions and 215 deletions

View file

@ -131,7 +131,7 @@ namespace Ryujinx.Ui.Applet
public void ExecuteProgram(HLE.Switch device, ProgramSpecifyKind kind, ulong value)
{
device.UserChannelPersistence.ExecuteProgram(kind, value);
device.Configuration.UserChannelPersistence.ExecuteProgram(kind, value);
((MainWindow)_parent).RendererWidget?.Exit();
}

View file

@ -2,12 +2,14 @@ using ARMeilleure.Translation;
using ARMeilleure.Translation.PTC;
using Gtk;
using LibHac.Common;
using LibHac.FsSystem;
using LibHac.Ns;
using Ryujinx.Audio.Backends.Dummy;
using Ryujinx.Audio.Backends.OpenAL;
using Ryujinx.Audio.Backends.SDL2;
using Ryujinx.Audio.Backends.SoundIo;
using Ryujinx.Audio.Integration;
using Ryujinx.Common;
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Logging;
using Ryujinx.Common.System;
@ -18,6 +20,7 @@ using Ryujinx.HLE.FileSystem;
using Ryujinx.HLE.FileSystem.Content;
using Ryujinx.HLE.HOS;
using Ryujinx.HLE.HOS.Services.Account.Acc;
using Ryujinx.HLE.HOS.SystemState;
using Ryujinx.Input.GTK3;
using Ryujinx.Input.HLE;
using Ryujinx.Input.SDL2;
@ -166,6 +169,10 @@ namespace Ryujinx.Ui
RendererWidgetBase.StatusUpdatedEvent += Update_StatusBar;
ConfigurationState.Instance.System.IgnoreMissingServices.Event += UpdateIgnoreMissingServicesState;
ConfigurationState.Instance.Graphics.AspectRatio.Event += UpdateAspectRatioState;
ConfigurationState.Instance.System.EnableDockedMode.Event += UpdateDockedModeState;
if (ConfigurationState.Instance.Ui.StartFullscreen)
{
_startFullScreen.Active = true;
@ -236,6 +243,30 @@ namespace Ryujinx.Ui
InputManager = new InputManager(new GTK3KeyboardDriver(this), new SDL2GamepadDriver());
}
private void UpdateIgnoreMissingServicesState(object sender, ReactiveEventArgs<bool> args)
{
if (_emulationContext != null)
{
_emulationContext.Configuration.IgnoreMissingServices = args.NewValue;
}
}
private void UpdateAspectRatioState(object sender, ReactiveEventArgs<AspectRatio> args)
{
if (_emulationContext != null)
{
_emulationContext.Configuration.AspectRatio = args.NewValue;
}
}
private void UpdateDockedModeState(object sender, ReactiveEventArgs<bool> e)
{
if (_emulationContext != null)
{
_emulationContext.System.ChangeDockedModeState(e.NewValue);
}
}
private void WindowStateEvent_Changed(object o, WindowStateEventArgs args)
{
_fullScreen.Label = args.Event.NewWindowState.HasFlag(Gdk.WindowState.Fullscreen) ? "Exit Fullscreen" : "Enter Fullscreen";
@ -380,19 +411,29 @@ namespace Ryujinx.Ui
? HLE.MemoryConfiguration.MemoryConfiguration6GB
: HLE.MemoryConfiguration.MemoryConfiguration4GB;
_emulationContext = new HLE.Switch(
_virtualFileSystem,
_contentManager,
_accountManager,
_userChannelPersistence,
renderer,
deviceDriver,
memoryConfiguration)
{
UiHandler = _uiHandler
};
IntegrityCheckLevel fsIntegrityCheckLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None;
_emulationContext.Initialize();
HLE.HLEConfiguration configuration = new HLE.HLEConfiguration(_virtualFileSystem,
_contentManager,
_accountManager,
_userChannelPersistence,
renderer,
deviceDriver,
memoryConfiguration,
_uiHandler,
(SystemLanguage)ConfigurationState.Instance.System.Language.Value,
(RegionCode)ConfigurationState.Instance.System.Region.Value,
ConfigurationState.Instance.Graphics.EnableVsync,
ConfigurationState.Instance.System.EnableDockedMode,
ConfigurationState.Instance.System.EnablePtc,
fsIntegrityCheckLevel,
ConfigurationState.Instance.System.FsGlobalAccessLogMode,
ConfigurationState.Instance.System.SystemTimeOffset,
ConfigurationState.Instance.System.TimeZone,
ConfigurationState.Instance.System.IgnoreMissingServices,
ConfigurationState.Instance.Graphics.AspectRatio);
_emulationContext = new HLE.Switch(configuration);
}
private void SetupProgressUiHandlers()

View file

@ -73,8 +73,6 @@ namespace Ryujinx.Ui
NpadManager = _inputManager.CreateNpadManager();
_keyboardInterface = (IKeyboard)_inputManager.KeyboardDriver.GetGamepad("0");
NpadManager.ReloadConfiguration(ConfigurationState.Instance.Hid.InputConfig.Value.ToList());
WaitEvent = new ManualResetEvent(false);
_glLogLevel = glLogLevel;
@ -300,6 +298,8 @@ namespace Ryujinx.Ui
Device = device;
Renderer = Device.Gpu.Renderer;
Renderer?.Window.SetSize(_windowWidth, _windowHeight);
NpadManager.Initialize(device, ConfigurationState.Instance.Hid.InputConfig, ConfigurationState.Instance.Hid.EnableKeyboard);
}
public void Render()
@ -488,7 +488,7 @@ namespace Ryujinx.Ui
});
}
NpadManager.Update(Device.Hid, Device.TamperMachine);
NpadManager.Update();
if (_isFocused)
{

View file

@ -1143,7 +1143,7 @@ namespace Ryujinx.Ui.Windows
if (_mainWindow.RendererWidget != null)
{
_mainWindow.RendererWidget.NpadManager.ReloadConfiguration(newConfig);
_mainWindow.RendererWidget.NpadManager.ReloadConfiguration(newConfig, ConfigurationState.Instance.Hid.EnableKeyboard);
}
// Atomically replace and signal input change.

View file

@ -263,7 +263,7 @@ namespace Ryujinx.Ui.Windows
}
_systemTimeZoneEntry.WidthChars = Math.Max(20, maxLocationLength + 1); // Ensure minimum Entry width
_systemTimeZoneEntry.Text = _timeZoneContentManager.SanityCheckDeviceLocationName();
_systemTimeZoneEntry.Text = _timeZoneContentManager.SanityCheckDeviceLocationName(ConfigurationState.Instance.System.TimeZone);
_systemTimeZoneCompletion.MatchFunc = TimeZoneMatchFunc;
@ -462,7 +462,7 @@ namespace Ryujinx.Ui.Windows
{
if (!_validTzRegions.Contains(_systemTimeZoneEntry.Text))
{
_systemTimeZoneEntry.Text = _timeZoneContentManager.SanityCheckDeviceLocationName();
_systemTimeZoneEntry.Text = _timeZoneContentManager.SanityCheckDeviceLocationName(ConfigurationState.Instance.System.TimeZone);
}
}