Address some of last TODO

This commit is contained in:
Thog 2019-11-22 17:07:53 +01:00
parent 7ee9a00cf0
commit 72fa78ec8d
No known key found for this signature in database
GPG key ID: 0CD291558FAFDBC6
4 changed files with 38 additions and 55 deletions

View file

@ -75,10 +75,6 @@ namespace Ryujinx.Common.Logging
{
ILogTarget logTarget = GetTarget(target);
// TODO: remove this
if (logTarget == null)
throw new Exception();
if (logTarget != null)
{
Updated -= logTarget.Log;

View file

@ -1,5 +1,7 @@
using Ryujinx.Common;
using Ryujinx.Configuration.Hid;
using Ryujinx.HLE.HOS;
using System;
namespace Ryujinx.HLE.Input
{
@ -47,18 +49,37 @@ namespace Ryujinx.HLE.Input
_keyboardOffset = HidPosition + HidKeyboardOffset;
}
public void InitializePrimaryController(ControllerStatus controllerType)
private static ControllerStatus ConvertControllerTypeToState(ControllerType controllerType)
{
ControllerId controllerId = controllerType == ControllerStatus.Handheld ?
switch (controllerType)
{
case ControllerType.Handheld:
return ControllerStatus.Handheld;
case ControllerType.NpadLeft:
return ControllerStatus.NpadLeft;
case ControllerType.NpadRight:
return ControllerStatus.NpadRight;
case ControllerType.NpadPair:
return ControllerStatus.NpadPair;
case ControllerType.ProController:
return ControllerStatus.ProController;
default:
throw new NotImplementedException();
}
}
public void InitializePrimaryController(ControllerType controllerType)
{
ControllerId controllerId = controllerType == ControllerType.Handheld ?
ControllerId.ControllerHandheld : ControllerId.ControllerPlayer1;
if (controllerType == ControllerStatus.ProController)
if (controllerType == ControllerType.ProController)
{
PrimaryController = new ProController(_device, NpadColor.Black, NpadColor.Black);
}
else
{
PrimaryController = new NpadController(controllerType,
PrimaryController = new NpadController(ConvertControllerTypeToState(controllerType),
_device,
(NpadColor.BodyNeonRed, NpadColor.BodyNeonRed),
(NpadColor.ButtonsNeonBlue, NpadColor.ButtonsNeonBlue));
@ -67,11 +88,6 @@ namespace Ryujinx.HLE.Input
PrimaryController.Connect(controllerId);
}
public void InitializeKeyboard()
{
_device.Memory.FillWithZeros(HidPosition + HidKeyboardOffset, HidKeyboardSize);
}
public ControllerButtons UpdateStickButtons(
JoystickPosition leftStick,
JoystickPosition rightStick)

View file

@ -1,5 +1,6 @@
using LibHac.FsSystem;
using Ryujinx.Audio;
using Ryujinx.Configuration;
using Ryujinx.Graphics;
using Ryujinx.Graphics.Gal;
using Ryujinx.HLE.FileSystem;
@ -63,27 +64,27 @@ namespace Ryujinx.HLE
VsyncEvent = new AutoResetEvent(true);
}
// TODO: Use Configuration when it will be moved to Common.
public void Initialize(SystemLanguage language, bool enableMulticoreScheduling, bool enableDockedMode, bool enableVsync, bool enableFsIntegrityChecks, int fsGlobalAccessLogMode, bool ignoreMissingServices)
public void Initialize()
{
System.State.SetLanguage(language);
System.State.SetLanguage((SystemLanguage)ConfigurationState.Instance.System.Language.Value);
EnableDeviceVsync = enableVsync;
EnableDeviceVsync = ConfigurationState.Instance.Graphics.EnableVsync;
System.State.DockedMode = enableDockedMode;
// TODO: Make this relodable and implement Docking/UnDocking logic.
System.State.DockedMode = ConfigurationState.Instance.System.EnableDockedMode;
if (enableMulticoreScheduling)
if (ConfigurationState.Instance.System.EnableMulticoreScheduling)
{
System.EnableMultiCoreScheduling();
}
System.FsIntegrityCheckLevel = enableFsIntegrityChecks
System.FsIntegrityCheckLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks
? IntegrityCheckLevel.ErrorOnInvalid
: IntegrityCheckLevel.None;
System.GlobalAccessLogMode = fsGlobalAccessLogMode;
System.GlobalAccessLogMode = ConfigurationState.Instance.System.FsGlobalAccessLogMode;
ServiceConfiguration.IgnoreMissingServices = ignoreMissingServices;
ServiceConfiguration.IgnoreMissingServices = ConfigurationState.Instance.System.IgnoreMissingServices;
}
public void LoadCart(string exeFsDir, string romFsFile = null)

View file

@ -11,8 +11,6 @@ using System.Text;
using System.Threading;
using Ryujinx.Configuration;
using System.Diagnostics;
using OpenTK.Input;
using Ryujinx.Ui.Input;
using System.Threading.Tasks;
using Utf8Json;
using JsonPrettyPrinterPlus;
@ -21,9 +19,6 @@ using Ryujinx.HLE.FileSystem;
using GUI = Gtk.Builder.ObjectAttribute;
using Ryujinx.HLE.Input;
using Ryujinx.Configuration.Hid;
using Ryujinx.HLE.HOS.SystemState;
namespace Ryujinx.Ui
{
@ -206,7 +201,8 @@ namespace Ryujinx.Ui
{
HLE.Switch instance = new HLE.Switch(_renderer, _audioOut);
instance.Initialize((SystemLanguage)ConfigurationState.Instance.System.Language.Value, ConfigurationState.Instance.System.EnableMulticoreScheduling, ConfigurationState.Instance.System.EnableDockedMode, ConfigurationState.Instance.Graphics.EnableVsync, ConfigurationState.Instance.System.EnableFsIntegrityChecks, ConfigurationState.Instance.System.FsGlobalAccessLogMode, ConfigurationState.Instance.System.IgnoreMissingServices);
instance.Initialize();
return instance;
}
@ -340,35 +336,9 @@ namespace Ryujinx.Ui
}
}
// TODO: Make HLE.Switch handle the state itself + reloading
private static void ConfigureHid()
{
_device.Hid.InitializePrimaryController(ConvertControllerTypeToState(ConfigurationState.Instance.Hid.ControllerType));
_device.Hid.InitializeKeyboard();
}
private static ControllerStatus ConvertControllerTypeToState(ControllerType controllerType)
{
switch (controllerType)
{
case ControllerType.Handheld:
return ControllerStatus.Handheld;
case ControllerType.NpadLeft:
return ControllerStatus.NpadLeft;
case ControllerType.NpadRight:
return ControllerStatus.NpadRight;
case ControllerType.NpadPair:
return ControllerStatus.NpadPair;
case ControllerType.ProController:
return ControllerStatus.ProController;
default:
throw new NotImplementedException();
}
}
private static void CreateGameWindow()
{
ConfigureHid();
_device.Hid.InitializePrimaryController(ConfigurationState.Instance.Hid.ControllerType);
using (_screen = new GlScreen(_device, _renderer))
{