2018-03-03 02:49:17 +01:00
|
|
|
|
using Ryujinx.Core.Input;
|
|
|
|
|
using System;
|
2018-02-09 03:47:32 +01:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
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-02-20 21:09:23 +01:00
|
|
|
|
namespace Ryujinx.Core
|
2018-02-09 03:47:32 +01:00
|
|
|
|
{
|
|
|
|
|
public static class Config
|
|
|
|
|
{
|
2018-04-14 03:02:24 +02:00
|
|
|
|
public static bool EnableMemoryChecks { get; private set; }
|
|
|
|
|
public static bool LoggingEnableInfo { get; private set; }
|
|
|
|
|
public static bool LoggingEnableTrace { get; private set; }
|
|
|
|
|
public static bool LoggingEnableDebug { get; private set; }
|
|
|
|
|
public static bool LoggingEnableWarn { get; private set; }
|
|
|
|
|
public static bool LoggingEnableError { get; private set; }
|
|
|
|
|
public static bool LoggingEnableFatal { get; private set; }
|
|
|
|
|
public static bool LoggingEnableIpc { get; private set; }
|
2018-04-17 02:24:42 +02:00
|
|
|
|
public static bool LoggingEnableStub { get; private set; }
|
2018-04-14 03:02:24 +02:00
|
|
|
|
public static bool LoggingEnableLogFile { get; private set; }
|
|
|
|
|
public static bool LoggingEnableFilter { get; private set; }
|
|
|
|
|
public static bool[] LoggingFilteredClasses { get; private set; }
|
2018-02-09 03:47:32 +01:00
|
|
|
|
|
2018-02-18 00:54:19 +01:00
|
|
|
|
public static JoyCon FakeJoyCon { get; private set; }
|
|
|
|
|
|
2018-02-09 03:47:32 +01:00
|
|
|
|
public static void Read()
|
|
|
|
|
{
|
2018-02-20 11:54:00 +01:00
|
|
|
|
var iniFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
|
|
|
|
var iniPath = Path.Combine(iniFolder, "Ryujinx.conf");
|
|
|
|
|
IniParser Parser = new IniParser(iniPath);
|
2018-02-09 03:47:32 +01:00
|
|
|
|
|
2018-04-14 03:02:24 +02:00
|
|
|
|
EnableMemoryChecks = Convert.ToBoolean(Parser.Value("Enable_Memory_Checks"));
|
|
|
|
|
LoggingEnableInfo = Convert.ToBoolean(Parser.Value("Logging_Enable_Info"));
|
|
|
|
|
LoggingEnableTrace = Convert.ToBoolean(Parser.Value("Logging_Enable_Trace"));
|
|
|
|
|
LoggingEnableDebug = Convert.ToBoolean(Parser.Value("Logging_Enable_Debug"));
|
|
|
|
|
LoggingEnableWarn = Convert.ToBoolean(Parser.Value("Logging_Enable_Warn"));
|
|
|
|
|
LoggingEnableError = Convert.ToBoolean(Parser.Value("Logging_Enable_Error"));
|
|
|
|
|
LoggingEnableFatal = Convert.ToBoolean(Parser.Value("Logging_Enable_Fatal"));
|
|
|
|
|
LoggingEnableIpc = Convert.ToBoolean(Parser.Value("Logging_Enable_Ipc"));
|
2018-04-17 02:24:42 +02:00
|
|
|
|
LoggingEnableStub = Convert.ToBoolean(Parser.Value("Logging_Enable_Stub"));
|
2018-04-14 03:02:24 +02:00
|
|
|
|
LoggingEnableLogFile = Convert.ToBoolean(Parser.Value("Logging_Enable_LogFile"));
|
|
|
|
|
LoggingEnableFilter = Convert.ToBoolean(Parser.Value("Logging_Enable_Filter"));
|
|
|
|
|
LoggingFilteredClasses = new bool[(int)LogClass.Count];
|
|
|
|
|
|
|
|
|
|
string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes", string.Empty).Split(',');
|
|
|
|
|
foreach (string LogClass in FilteredLogClasses)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(LogClass.Trim()))
|
|
|
|
|
{
|
|
|
|
|
foreach (LogClass EnumItemName in Enum.GetValues(typeof(LogClass)))
|
|
|
|
|
{
|
|
|
|
|
if (EnumItemName.ToString().ToLower().Contains(LogClass.Trim().ToLower()))
|
|
|
|
|
{
|
|
|
|
|
LoggingFilteredClasses[(int)EnumItemName] = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-02-18 00:54:19 +01:00
|
|
|
|
|
|
|
|
|
FakeJoyCon = new JoyCon
|
|
|
|
|
{
|
|
|
|
|
Left = new JoyConLeft
|
|
|
|
|
{
|
|
|
|
|
StickUp = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Stick_Up")),
|
|
|
|
|
StickDown = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Stick_Down")),
|
|
|
|
|
StickLeft = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Stick_Left")),
|
|
|
|
|
StickRight = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Stick_Right")),
|
|
|
|
|
StickButton = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Stick_Button")),
|
|
|
|
|
DPadUp = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_DPad_Up")),
|
|
|
|
|
DPadDown = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_DPad_Down")),
|
|
|
|
|
DPadLeft = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_DPad_Left")),
|
|
|
|
|
DPadRight = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_DPad_Right")),
|
|
|
|
|
ButtonMinus = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Button_Minus")),
|
|
|
|
|
ButtonL = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Button_L")),
|
|
|
|
|
ButtonZL = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Button_ZL"))
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Right = new JoyConRight
|
|
|
|
|
{
|
|
|
|
|
StickUp = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Stick_Up")),
|
|
|
|
|
StickDown = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Stick_Down")),
|
|
|
|
|
StickLeft = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Stick_Left")),
|
|
|
|
|
StickRight = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Stick_Right")),
|
|
|
|
|
StickButton = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Stick_Button")),
|
|
|
|
|
ButtonA = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_A")),
|
|
|
|
|
ButtonB = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_B")),
|
|
|
|
|
ButtonX = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_X")),
|
|
|
|
|
ButtonY = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_Y")),
|
|
|
|
|
ButtonPlus = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_Plus")),
|
|
|
|
|
ButtonR = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_R")),
|
|
|
|
|
ButtonZR = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_ZR"))
|
|
|
|
|
}
|
|
|
|
|
};
|
2018-02-09 03:47:32 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// https://stackoverflow.com/a/37772571
|
|
|
|
|
public class IniParser
|
|
|
|
|
{
|
2018-02-20 11:54:00 +01:00
|
|
|
|
private readonly Dictionary<string, string> Values;
|
2018-02-09 03:47:32 +01:00
|
|
|
|
|
|
|
|
|
public IniParser(string Path)
|
|
|
|
|
{
|
|
|
|
|
Values = File.ReadLines(Path)
|
2018-02-20 11:54:00 +01:00
|
|
|
|
.Where(Line => !string.IsNullOrWhiteSpace(Line) && !Line.StartsWith('#'))
|
|
|
|
|
.Select(Line => Line.Split('=', 2))
|
2018-02-09 03:47:32 +01:00
|
|
|
|
.ToDictionary(Parts => Parts[0].Trim(), Parts => Parts.Length > 1 ? Parts[1].Trim() : null);
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-20 11:54:00 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the setting value for the requested setting <see cref="Name"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Name">Setting Name</param>
|
|
|
|
|
/// <param name="defaultValue">Default value of the setting</param>
|
|
|
|
|
public string Value(string Name, string defaultValue = null)
|
2018-02-09 03:47:32 +01:00
|
|
|
|
{
|
2018-02-20 11:54:00 +01:00
|
|
|
|
return Values.TryGetValue(Name, out var value) ? value : defaultValue;
|
2018-02-09 03:47:32 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|