2018-03-03 01:49:17 +00:00
|
|
|
|
using Ryujinx.Core.Input;
|
2018-04-24 18:57:39 +00:00
|
|
|
|
using Ryujinx.Core.Logging;
|
2018-03-03 01:49:17 +00:00
|
|
|
|
using System;
|
2018-02-09 02:47:32 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
2018-02-09 03:23:20 +00:00
|
|
|
|
using System.Reflection;
|
2018-02-09 02:47:32 +00:00
|
|
|
|
|
2018-04-24 18:57:39 +00:00
|
|
|
|
namespace Ryujinx
|
2018-02-09 02:47:32 +00:00
|
|
|
|
{
|
|
|
|
|
public static class Config
|
|
|
|
|
{
|
2018-02-17 23:54:19 +00:00
|
|
|
|
public static JoyCon FakeJoyCon { get; private set; }
|
|
|
|
|
|
2018-04-24 18:57:39 +00:00
|
|
|
|
public static void Read(Logger Log)
|
2018-02-09 02:47:32 +00:00
|
|
|
|
{
|
2018-04-24 18:57:39 +00:00
|
|
|
|
string IniFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
|
|
|
|
|
|
|
|
|
string IniPath = Path.Combine(IniFolder, "Ryujinx.conf");
|
|
|
|
|
|
|
|
|
|
IniParser Parser = new IniParser(IniPath);
|
|
|
|
|
|
|
|
|
|
AOptimizations.DisableMemoryChecks = !Convert.ToBoolean(Parser.Value("Enable_Memory_Checks"));
|
|
|
|
|
|
2018-04-26 02:11:26 +00:00
|
|
|
|
Log.SetEnable(LogLevel.Debug, Convert.ToBoolean(Parser.Value("Logging_Enable_Debug")));
|
|
|
|
|
Log.SetEnable(LogLevel.Stub, Convert.ToBoolean(Parser.Value("Logging_Enable_Stub")));
|
|
|
|
|
Log.SetEnable(LogLevel.Info, Convert.ToBoolean(Parser.Value("Logging_Enable_Info")));
|
|
|
|
|
Log.SetEnable(LogLevel.Warning, Convert.ToBoolean(Parser.Value("Logging_Enable_Warn")));
|
|
|
|
|
Log.SetEnable(LogLevel.Error, Convert.ToBoolean(Parser.Value("Logging_Enable_Error")));
|
2018-02-09 02:47:32 +00:00
|
|
|
|
|
2018-04-24 18:57:39 +00: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)))
|
|
|
|
|
{
|
|
|
|
|
Log.SetEnable(Class, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-14 01:02:24 +00:00
|
|
|
|
|
|
|
|
|
foreach (string LogClass in FilteredLogClasses)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(LogClass.Trim()))
|
|
|
|
|
{
|
2018-04-24 18:57:39 +00:00
|
|
|
|
foreach (LogClass Class in Enum.GetValues(typeof(LogClass)))
|
2018-04-14 01:02:24 +00:00
|
|
|
|
{
|
2018-04-24 18:57:39 +00:00
|
|
|
|
if (Class.ToString().ToLower().Contains(LogClass.Trim().ToLower()))
|
2018-04-14 01:02:24 +00:00
|
|
|
|
{
|
2018-04-24 18:57:39 +00:00
|
|
|
|
Log.SetEnable(Class, true);
|
2018-04-14 01:02:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-02-17 23:54:19 +00: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 02:47:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// https://stackoverflow.com/a/37772571
|
|
|
|
|
public class IniParser
|
|
|
|
|
{
|
2018-02-20 10:54:00 +00:00
|
|
|
|
private readonly Dictionary<string, string> Values;
|
2018-02-09 02:47:32 +00:00
|
|
|
|
|
|
|
|
|
public IniParser(string Path)
|
|
|
|
|
{
|
|
|
|
|
Values = File.ReadLines(Path)
|
2018-04-24 18:57:39 +00: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-09 02:47:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-24 18:57:39 +00:00
|
|
|
|
public string Value(string Name)
|
2018-02-09 02:47:32 +00:00
|
|
|
|
{
|
2018-04-24 18:57:39 +00:00
|
|
|
|
return Values.TryGetValue(Name, out string Value) ? Value : null;
|
2018-02-09 02:47:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|