2019-01-05 01:41:49 +01:00
|
|
|
using LibHac.IO;
|
2018-10-17 19:15:50 +02:00
|
|
|
using Ryujinx.Common.Logging;
|
2018-08-15 00:02:42 +02:00
|
|
|
using Ryujinx.HLE;
|
2018-12-27 16:08:34 +01:00
|
|
|
using Ryujinx.HLE.HOS.SystemState;
|
2018-11-20 01:01:36 +01:00
|
|
|
using Ryujinx.HLE.Input;
|
2018-08-15 00:02:42 +02:00
|
|
|
using Ryujinx.UI.Input;
|
2018-03-03 02:49:17 +01:00
|
|
|
using System;
|
2018-02-09 03:47:32 +01:00
|
|
|
using System.Collections.Generic;
|
2018-11-20 01:01:36 +01:00
|
|
|
using System.Globalization;
|
2018-02-09 03:47:32 +01:00
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
2018-02-09 04:23:20 +01:00
|
|
|
using System.Reflection;
|
2018-02-09 03:47:32 +01:00
|
|
|
|
2018-04-24 20:57:39 +02:00
|
|
|
namespace Ryujinx
|
2018-02-09 03:47:32 +01:00
|
|
|
{
|
|
|
|
public static class Config
|
|
|
|
{
|
2018-11-20 01:01:36 +01:00
|
|
|
public static NpadKeyboard NpadKeyboard { get; private set; }
|
|
|
|
public static NpadController NpadController { get; private set; }
|
2018-07-03 00:08:54 +02:00
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
public static void Read(Switch device)
|
2018-02-09 03:47:32 +01:00
|
|
|
{
|
2018-10-31 02:43:02 +01:00
|
|
|
string iniFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
2018-04-24 20:57:39 +02:00
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
string iniPath = Path.Combine(iniFolder, "Ryujinx.conf");
|
2018-04-24 20:57:39 +02:00
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
IniParser parser = new IniParser(iniPath);
|
2018-04-24 20:57:39 +02:00
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
GraphicsConfig.ShadersDumpPath = parser.Value("Graphics_Shaders_Dump_Path");
|
2018-07-16 00:37:27 +02:00
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
Logger.SetEnable(LogLevel.Debug, Convert.ToBoolean(parser.Value("Logging_Enable_Debug")));
|
|
|
|
Logger.SetEnable(LogLevel.Stub, Convert.ToBoolean(parser.Value("Logging_Enable_Stub")));
|
|
|
|
Logger.SetEnable(LogLevel.Info, Convert.ToBoolean(parser.Value("Logging_Enable_Info")));
|
|
|
|
Logger.SetEnable(LogLevel.Warning, Convert.ToBoolean(parser.Value("Logging_Enable_Warn")));
|
|
|
|
Logger.SetEnable(LogLevel.Error, Convert.ToBoolean(parser.Value("Logging_Enable_Error")));
|
2018-08-15 00:02:42 +02:00
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
string[] filteredLogClasses = parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries);
|
2018-04-24 20:57:39 +02:00
|
|
|
|
|
|
|
//When the classes are specified on the list, we only
|
|
|
|
//enable the classes that are on the list.
|
|
|
|
//So, first disable everything, then enable
|
|
|
|
//the classes that the user added to the list.
|
2018-10-31 02:43:02 +01:00
|
|
|
if (filteredLogClasses.Length > 0)
|
2018-04-24 20:57:39 +02:00
|
|
|
{
|
|
|
|
foreach (LogClass Class in Enum.GetValues(typeof(LogClass)))
|
|
|
|
{
|
2018-10-17 19:15:50 +02:00
|
|
|
Logger.SetEnable(Class, false);
|
2018-04-24 20:57:39 +02:00
|
|
|
}
|
|
|
|
}
|
2018-04-14 03:02:24 +02:00
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
foreach (string logClass in filteredLogClasses)
|
2018-04-14 03:02:24 +02:00
|
|
|
{
|
2018-10-31 02:43:02 +01:00
|
|
|
if (!string.IsNullOrEmpty(logClass.Trim()))
|
2018-04-14 03:02:24 +02:00
|
|
|
{
|
2018-04-24 20:57:39 +02:00
|
|
|
foreach (LogClass Class in Enum.GetValues(typeof(LogClass)))
|
2018-04-14 03:02:24 +02:00
|
|
|
{
|
2018-10-31 02:43:02 +01:00
|
|
|
if (Class.ToString().ToLower().Contains(logClass.Trim().ToLower()))
|
2018-04-14 03:02:24 +02:00
|
|
|
{
|
2018-10-17 19:15:50 +02:00
|
|
|
Logger.SetEnable(Class, true);
|
2018-04-14 03:02:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-02-18 00:54:19 +01:00
|
|
|
|
2018-12-27 16:08:34 +01:00
|
|
|
SystemLanguage SetLanguage = Enum.Parse<SystemLanguage>(parser.Value("System_Language"));
|
|
|
|
|
|
|
|
device.System.State.SetLanguage(SetLanguage);
|
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
device.System.State.DockedMode = Convert.ToBoolean(parser.Value("Docked_Mode"));
|
2018-09-19 01:36:43 +02:00
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
device.EnableDeviceVsync = Convert.ToBoolean(parser.Value("Enable_Vsync"));
|
2018-09-19 01:36:43 +02:00
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
if (Convert.ToBoolean(parser.Value("Enable_MultiCore_Scheduling")))
|
2018-09-19 01:36:43 +02:00
|
|
|
{
|
2018-10-31 02:43:02 +01:00
|
|
|
device.System.EnableMultiCoreScheduling();
|
2018-09-19 01:36:43 +02:00
|
|
|
}
|
|
|
|
|
2018-10-31 03:34:27 +01:00
|
|
|
device.System.FsIntegrityCheckLevel = Convert.ToBoolean(parser.Value("Enable_FS_Integrity_Checks"))
|
|
|
|
? IntegrityCheckLevel.ErrorOnInvalid
|
|
|
|
: IntegrityCheckLevel.None;
|
2018-10-06 17:11:47 +02:00
|
|
|
|
2018-11-20 01:01:36 +01:00
|
|
|
HidControllerType ControllerType = Enum.Parse<HidControllerType>(parser.Value("Controller_Type"));
|
|
|
|
|
|
|
|
device.Hid.InitilizePrimaryController(ControllerType);
|
|
|
|
|
|
|
|
NpadKeyboard = new NpadKeyboard(
|
2018-07-29 06:35:36 +02:00
|
|
|
|
2018-11-20 01:01:36 +01:00
|
|
|
new NpadKeyboardLeft
|
2018-07-03 00:08:54 +02:00
|
|
|
{
|
2018-10-31 02:43:02 +01:00
|
|
|
StickUp = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_Stick_Up")),
|
|
|
|
StickDown = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_Stick_Down")),
|
|
|
|
StickLeft = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_Stick_Left")),
|
|
|
|
StickRight = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_Stick_Right")),
|
|
|
|
StickButton = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_Stick_Button")),
|
|
|
|
DPadUp = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_DPad_Up")),
|
|
|
|
DPadDown = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_DPad_Down")),
|
|
|
|
DPadLeft = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_DPad_Left")),
|
|
|
|
DPadRight = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_DPad_Right")),
|
|
|
|
ButtonMinus = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_Button_Minus")),
|
|
|
|
ButtonL = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_Button_L")),
|
|
|
|
ButtonZl = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_Button_ZL"))
|
2018-07-03 00:08:54 +02:00
|
|
|
},
|
|
|
|
|
2018-11-20 01:01:36 +01:00
|
|
|
new NpadKeyboardRight
|
2018-07-03 00:08:54 +02:00
|
|
|
{
|
2018-10-31 02:43:02 +01:00
|
|
|
StickUp = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Stick_Up")),
|
|
|
|
StickDown = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Stick_Down")),
|
|
|
|
StickLeft = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Stick_Left")),
|
|
|
|
StickRight = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Stick_Right")),
|
|
|
|
StickButton = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Stick_Button")),
|
|
|
|
ButtonA = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Button_A")),
|
|
|
|
ButtonB = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Button_B")),
|
|
|
|
ButtonX = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Button_X")),
|
|
|
|
ButtonY = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Button_Y")),
|
|
|
|
ButtonPlus = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Button_Plus")),
|
|
|
|
ButtonR = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Button_R")),
|
|
|
|
ButtonZr = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Button_ZR"))
|
2018-07-29 06:35:36 +02:00
|
|
|
});
|
2018-07-03 00:08:54 +02:00
|
|
|
|
2018-11-20 01:01:36 +01:00
|
|
|
NpadController = new NpadController(
|
2018-07-29 06:35:36 +02:00
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
Convert.ToBoolean(parser.Value("GamePad_Enable")),
|
|
|
|
Convert.ToInt32 (parser.Value("GamePad_Index")),
|
|
|
|
(float)Convert.ToDouble (parser.Value("GamePad_Deadzone"), CultureInfo.InvariantCulture),
|
|
|
|
(float)Convert.ToDouble (parser.Value("GamePad_Trigger_Threshold"), CultureInfo.InvariantCulture),
|
2018-07-29 06:35:36 +02:00
|
|
|
|
2018-11-20 01:01:36 +01:00
|
|
|
new NpadControllerLeft
|
2018-02-18 00:54:19 +01:00
|
|
|
{
|
2018-10-31 02:43:02 +01:00
|
|
|
Stick = ToId(parser.Value("Controls_Left_JoyConController_Stick")),
|
|
|
|
StickButton = ToId(parser.Value("Controls_Left_JoyConController_Stick_Button")),
|
|
|
|
DPadUp = ToId(parser.Value("Controls_Left_JoyConController_DPad_Up")),
|
|
|
|
DPadDown = ToId(parser.Value("Controls_Left_JoyConController_DPad_Down")),
|
|
|
|
DPadLeft = ToId(parser.Value("Controls_Left_JoyConController_DPad_Left")),
|
|
|
|
DPadRight = ToId(parser.Value("Controls_Left_JoyConController_DPad_Right")),
|
|
|
|
ButtonMinus = ToId(parser.Value("Controls_Left_JoyConController_Button_Minus")),
|
|
|
|
ButtonL = ToId(parser.Value("Controls_Left_JoyConController_Button_L")),
|
|
|
|
ButtonZl = ToId(parser.Value("Controls_Left_JoyConController_Button_ZL"))
|
2018-02-18 00:54:19 +01:00
|
|
|
},
|
|
|
|
|
2018-11-20 01:01:36 +01:00
|
|
|
new NpadControllerRight
|
2018-02-18 00:54:19 +01:00
|
|
|
{
|
2018-10-31 02:43:02 +01:00
|
|
|
Stick = ToId(parser.Value("Controls_Right_JoyConController_Stick")),
|
|
|
|
StickButton = ToId(parser.Value("Controls_Right_JoyConController_Stick_Button")),
|
|
|
|
ButtonA = ToId(parser.Value("Controls_Right_JoyConController_Button_A")),
|
|
|
|
ButtonB = ToId(parser.Value("Controls_Right_JoyConController_Button_B")),
|
|
|
|
ButtonX = ToId(parser.Value("Controls_Right_JoyConController_Button_X")),
|
|
|
|
ButtonY = ToId(parser.Value("Controls_Right_JoyConController_Button_Y")),
|
|
|
|
ButtonPlus = ToId(parser.Value("Controls_Right_JoyConController_Button_Plus")),
|
|
|
|
ButtonR = ToId(parser.Value("Controls_Right_JoyConController_Button_R")),
|
|
|
|
ButtonZr = ToId(parser.Value("Controls_Right_JoyConController_Button_ZR"))
|
2018-07-29 06:35:36 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
private static ControllerInputId ToId(string key)
|
2018-07-29 06:35:36 +02:00
|
|
|
{
|
2018-10-31 02:43:02 +01:00
|
|
|
switch (key.ToUpper())
|
2018-07-29 06:35:36 +02:00
|
|
|
{
|
2018-10-31 02:43:02 +01:00
|
|
|
case "LSTICK": return ControllerInputId.LStick;
|
|
|
|
case "DPADUP": return ControllerInputId.DPadUp;
|
|
|
|
case "DPADDOWN": return ControllerInputId.DPadDown;
|
|
|
|
case "DPADLEFT": return ControllerInputId.DPadLeft;
|
|
|
|
case "DPADRIGHT": return ControllerInputId.DPadRight;
|
|
|
|
case "BACK": return ControllerInputId.Back;
|
|
|
|
case "LSHOULDER": return ControllerInputId.LShoulder;
|
|
|
|
case "LTRIGGER": return ControllerInputId.LTrigger;
|
|
|
|
|
|
|
|
case "RSTICK": return ControllerInputId.RStick;
|
|
|
|
case "A": return ControllerInputId.A;
|
|
|
|
case "B": return ControllerInputId.B;
|
|
|
|
case "X": return ControllerInputId.X;
|
|
|
|
case "Y": return ControllerInputId.Y;
|
|
|
|
case "START": return ControllerInputId.Start;
|
|
|
|
case "RSHOULDER": return ControllerInputId.RShoulder;
|
|
|
|
case "RTRIGGER": return ControllerInputId.RTrigger;
|
|
|
|
|
|
|
|
case "LJOYSTICK": return ControllerInputId.LJoystick;
|
|
|
|
case "RJOYSTICK": return ControllerInputId.RJoystick;
|
|
|
|
|
|
|
|
default: return ControllerInputId.Invalid;
|
2018-07-29 06:35:36 +02:00
|
|
|
}
|
2018-02-09 03:47:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-03 00:08:54 +02:00
|
|
|
//https://stackoverflow.com/a/37772571
|
2018-02-09 03:47:32 +01:00
|
|
|
public class IniParser
|
|
|
|
{
|
2018-10-31 02:43:02 +01:00
|
|
|
private readonly Dictionary<string, string> _values;
|
2018-02-09 03:47:32 +01:00
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
public IniParser(string path)
|
2018-02-09 03:47:32 +01:00
|
|
|
{
|
2018-10-31 02:43:02 +01:00
|
|
|
_values = File.ReadLines(path)
|
|
|
|
.Where(line => !string.IsNullOrWhiteSpace(line) && !line.StartsWith('#'))
|
|
|
|
.Select(line => line.Split('=', 2))
|
|
|
|
.ToDictionary(parts => parts[0].Trim(), parts => parts.Length > 1 ? parts[1].Trim() : null);
|
2018-02-09 03:47:32 +01:00
|
|
|
}
|
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
public string Value(string name)
|
2018-02-09 03:47:32 +01:00
|
|
|
{
|
2018-10-31 02:43:02 +01:00
|
|
|
return _values.TryGetValue(name, out string value) ? value : null;
|
2018-02-09 03:47:32 +01:00
|
|
|
}
|
|
|
|
}
|
2018-08-14 02:13:01 +02:00
|
|
|
}
|