2018-08-14 18:02:42 -04:00
|
|
|
using Ryujinx.HLE;
|
2018-06-10 20:46:42 -04:00
|
|
|
using Ryujinx.HLE.Logging;
|
2018-08-14 18:02:42 -04:00
|
|
|
using Ryujinx.UI.Input;
|
2018-03-02 20:49:17 -05:00
|
|
|
using System;
|
2018-07-02 18:08:54 -04:00
|
|
|
using System.Globalization;
|
2018-02-08 21:47:32 -05:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
2018-02-08 22:23:20 -05:00
|
|
|
using System.Reflection;
|
2018-02-08 21:47:32 -05:00
|
|
|
|
2018-04-24 14:57:39 -04:00
|
|
|
namespace Ryujinx
|
2018-02-08 21:47:32 -05:00
|
|
|
{
|
|
|
|
public static class Config
|
|
|
|
{
|
2018-07-02 18:08:54 -04:00
|
|
|
public static JoyConKeyboard JoyConKeyboard { get; private set; }
|
|
|
|
public static JoyConController JoyConController { get; private set; }
|
|
|
|
|
2018-08-14 18:02:42 -04:00
|
|
|
public static void Read(Switch Device)
|
2018-02-08 21:47:32 -05:00
|
|
|
{
|
2018-04-24 14:57:39 -04:00
|
|
|
string IniFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
|
|
|
|
|
|
|
string IniPath = Path.Combine(IniFolder, "Ryujinx.conf");
|
|
|
|
|
|
|
|
IniParser Parser = new IniParser(IniPath);
|
|
|
|
|
2018-07-15 18:37:27 -04:00
|
|
|
GraphicsConfig.ShadersDumpPath = Parser.Value("Graphics_Shaders_Dump_Path");
|
|
|
|
|
2018-08-14 18:02:42 -04:00
|
|
|
Device.Log.SetEnable(LogLevel.Debug, Convert.ToBoolean(Parser.Value("Logging_Enable_Debug")));
|
|
|
|
Device.Log.SetEnable(LogLevel.Stub, Convert.ToBoolean(Parser.Value("Logging_Enable_Stub")));
|
|
|
|
Device.Log.SetEnable(LogLevel.Info, Convert.ToBoolean(Parser.Value("Logging_Enable_Info")));
|
|
|
|
Device.Log.SetEnable(LogLevel.Warning, Convert.ToBoolean(Parser.Value("Logging_Enable_Warn")));
|
|
|
|
Device.Log.SetEnable(LogLevel.Error, Convert.ToBoolean(Parser.Value("Logging_Enable_Error")));
|
|
|
|
|
2018-04-24 14:57:39 -04:00
|
|
|
string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
|
|
//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.
|
|
|
|
if (FilteredLogClasses.Length > 0)
|
|
|
|
{
|
|
|
|
foreach (LogClass Class in Enum.GetValues(typeof(LogClass)))
|
|
|
|
{
|
2018-08-14 18:02:42 -04:00
|
|
|
Device.Log.SetEnable(Class, false);
|
2018-04-24 14:57:39 -04:00
|
|
|
}
|
|
|
|
}
|
2018-04-13 21:02:24 -04:00
|
|
|
|
|
|
|
foreach (string LogClass in FilteredLogClasses)
|
|
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(LogClass.Trim()))
|
|
|
|
{
|
2018-04-24 14:57:39 -04:00
|
|
|
foreach (LogClass Class in Enum.GetValues(typeof(LogClass)))
|
2018-04-13 21:02:24 -04:00
|
|
|
{
|
2018-04-24 14:57:39 -04:00
|
|
|
if (Class.ToString().ToLower().Contains(LogClass.Trim().ToLower()))
|
2018-04-13 21:02:24 -04:00
|
|
|
{
|
2018-08-14 18:02:42 -04:00
|
|
|
Device.Log.SetEnable(Class, true);
|
2018-04-13 21:02:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-02-17 18:54:19 -05:00
|
|
|
|
2018-09-18 19:36:43 -04:00
|
|
|
Device.System.State.DockedMode = Convert.ToBoolean(Parser.Value("Docked_Mode"));
|
|
|
|
|
|
|
|
Device.EnableDeviceVsync = Convert.ToBoolean(Parser.Value("Enable_Vsync"));
|
|
|
|
|
|
|
|
if (Convert.ToBoolean(Parser.Value("Enable_MultiCore_Scheduling")))
|
|
|
|
{
|
|
|
|
Device.System.EnableMultiCoreScheduling();
|
|
|
|
}
|
|
|
|
|
2018-07-29 00:35:36 -04:00
|
|
|
JoyConKeyboard = new JoyConKeyboard(
|
|
|
|
|
|
|
|
new JoyConKeyboardLeft
|
2018-07-02 18:08:54 -04: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-29 00:35:36 -04:00
|
|
|
new JoyConKeyboardRight
|
2018-07-02 18:08:54 -04: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 00:35:36 -04:00
|
|
|
});
|
2018-07-02 18:08:54 -04:00
|
|
|
|
2018-07-29 00:35:36 -04:00
|
|
|
JoyConController = new JoyConController(
|
|
|
|
|
|
|
|
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),
|
|
|
|
|
|
|
|
new JoyConControllerLeft
|
2018-02-17 18:54:19 -05:00
|
|
|
{
|
2018-07-29 00:35:36 -04: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-17 18:54:19 -05:00
|
|
|
},
|
|
|
|
|
2018-07-29 00:35:36 -04:00
|
|
|
new JoyConControllerRight
|
2018-02-17 18:54:19 -05:00
|
|
|
{
|
2018-07-29 00:35:36 -04: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"))
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private static ControllerInputID ToID(string Key)
|
|
|
|
{
|
|
|
|
switch (Key.ToUpper())
|
|
|
|
{
|
|
|
|
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-02-08 21:47:32 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-02 18:08:54 -04:00
|
|
|
//https://stackoverflow.com/a/37772571
|
2018-02-08 21:47:32 -05:00
|
|
|
public class IniParser
|
|
|
|
{
|
2018-02-20 05:54:00 -05:00
|
|
|
private readonly Dictionary<string, string> Values;
|
2018-02-08 21:47:32 -05:00
|
|
|
|
|
|
|
public IniParser(string Path)
|
|
|
|
{
|
|
|
|
Values = File.ReadLines(Path)
|
2018-04-24 14:57:39 -04:00
|
|
|
.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-08 21:47:32 -05:00
|
|
|
}
|
|
|
|
|
2018-04-24 14:57:39 -04:00
|
|
|
public string Value(string Name)
|
2018-02-08 21:47:32 -05:00
|
|
|
{
|
2018-04-24 14:57:39 -04:00
|
|
|
return Values.TryGetValue(Name, out string Value) ? Value : null;
|
2018-02-08 21:47:32 -05:00
|
|
|
}
|
|
|
|
}
|
2018-08-13 20:13:01 -04:00
|
|
|
}
|