Change naming convention for Ryujinx project

This commit is contained in:
Alex Barney 2018-10-27 16:30:29 -05:00
commit bd6e346b88
6 changed files with 375 additions and 375 deletions

View file

@ -15,29 +15,29 @@ namespace Ryujinx
public static JoyConKeyboard JoyConKeyboard { get; private set; } public static JoyConKeyboard JoyConKeyboard { get; private set; }
public static JoyConController JoyConController { get; private set; } public static JoyConController JoyConController { get; private set; }
public static void Read(Switch Device) public static void Read(Switch device)
{ {
string IniFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); string iniFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
string IniPath = Path.Combine(IniFolder, "Ryujinx.conf"); string iniPath = Path.Combine(iniFolder, "Ryujinx.conf");
IniParser Parser = new IniParser(IniPath); IniParser parser = new IniParser(iniPath);
GraphicsConfig.ShadersDumpPath = Parser.Value("Graphics_Shaders_Dump_Path"); GraphicsConfig.ShadersDumpPath = parser.Value("Graphics_Shaders_Dump_Path");
Logger.SetEnable(LogLevel.Debug, Convert.ToBoolean(Parser.Value("Logging_Enable_Debug"))); 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.Stub, Convert.ToBoolean(parser.Value("Logging_Enable_Stub")));
Logger.SetEnable(LogLevel.Info, Convert.ToBoolean(Parser.Value("Logging_Enable_Info"))); 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.Warning, Convert.ToBoolean(parser.Value("Logging_Enable_Warn")));
Logger.SetEnable(LogLevel.Error, Convert.ToBoolean(Parser.Value("Logging_Enable_Error"))); Logger.SetEnable(LogLevel.Error, Convert.ToBoolean(parser.Value("Logging_Enable_Error")));
string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries); string[] filteredLogClasses = parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries);
//When the classes are specified on the list, we only //When the classes are specified on the list, we only
//enable the classes that are on the list. //enable the classes that are on the list.
//So, first disable everything, then enable //So, first disable everything, then enable
//the classes that the user added to the list. //the classes that the user added to the list.
if (FilteredLogClasses.Length > 0) if (filteredLogClasses.Length > 0)
{ {
foreach (LogClass Class in Enum.GetValues(typeof(LogClass))) foreach (LogClass Class in Enum.GetValues(typeof(LogClass)))
{ {
@ -45,13 +45,13 @@ namespace Ryujinx
} }
} }
foreach (string LogClass in FilteredLogClasses) foreach (string logClass in filteredLogClasses)
{ {
if (!string.IsNullOrEmpty(LogClass.Trim())) if (!string.IsNullOrEmpty(logClass.Trim()))
{ {
foreach (LogClass Class in Enum.GetValues(typeof(LogClass))) foreach (LogClass Class in Enum.GetValues(typeof(LogClass)))
{ {
if (Class.ToString().ToLower().Contains(LogClass.Trim().ToLower())) if (Class.ToString().ToLower().Contains(logClass.Trim().ToLower()))
{ {
Logger.SetEnable(Class, true); Logger.SetEnable(Class, true);
} }
@ -59,111 +59,111 @@ namespace Ryujinx
} }
} }
Device.System.State.DockedMode = Convert.ToBoolean(Parser.Value("Docked_Mode")); device.System.State.DockedMode = Convert.ToBoolean(parser.Value("Docked_Mode"));
Device.EnableDeviceVsync = Convert.ToBoolean(Parser.Value("Enable_Vsync")); device.EnableDeviceVsync = Convert.ToBoolean(parser.Value("Enable_Vsync"));
if (Convert.ToBoolean(Parser.Value("Enable_MultiCore_Scheduling"))) if (Convert.ToBoolean(parser.Value("Enable_MultiCore_Scheduling")))
{ {
Device.System.EnableMultiCoreScheduling(); device.System.EnableMultiCoreScheduling();
} }
Device.System.EnableFsIntegrityChecks = Convert.ToBoolean(Parser.Value("Enable_FS_Integrity_Checks")); device.System.EnableFsIntegrityChecks = Convert.ToBoolean(parser.Value("Enable_FS_Integrity_Checks"));
JoyConKeyboard = new JoyConKeyboard( JoyConKeyboard = new JoyConKeyboard(
new JoyConKeyboardLeft new JoyConKeyboardLeft
{ {
StickUp = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Stick_Up")), StickUp = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_Stick_Up")),
StickDown = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Stick_Down")), StickDown = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_Stick_Down")),
StickLeft = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Stick_Left")), StickLeft = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_Stick_Left")),
StickRight = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Stick_Right")), StickRight = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_Stick_Right")),
StickButton = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Stick_Button")), StickButton = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_Stick_Button")),
DPadUp = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_DPad_Up")), DPadUp = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_DPad_Up")),
DPadDown = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_DPad_Down")), DPadDown = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_DPad_Down")),
DPadLeft = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_DPad_Left")), DPadLeft = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_DPad_Left")),
DPadRight = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_DPad_Right")), DPadRight = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_DPad_Right")),
ButtonMinus = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Button_Minus")), ButtonMinus = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_Button_Minus")),
ButtonL = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Button_L")), ButtonL = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_Button_L")),
ButtonZL = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Button_ZL")) ButtonZl = Convert.ToInt16(parser.Value("Controls_Left_JoyConKeyboard_Button_ZL"))
}, },
new JoyConKeyboardRight new JoyConKeyboardRight
{ {
StickUp = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Stick_Up")), StickUp = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Stick_Up")),
StickDown = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Stick_Down")), StickDown = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Stick_Down")),
StickLeft = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Stick_Left")), StickLeft = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Stick_Left")),
StickRight = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Stick_Right")), StickRight = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Stick_Right")),
StickButton = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Stick_Button")), StickButton = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Stick_Button")),
ButtonA = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_A")), ButtonA = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Button_A")),
ButtonB = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_B")), ButtonB = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Button_B")),
ButtonX = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_X")), ButtonX = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Button_X")),
ButtonY = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_Y")), ButtonY = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Button_Y")),
ButtonPlus = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_Plus")), ButtonPlus = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Button_Plus")),
ButtonR = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_R")), ButtonR = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Button_R")),
ButtonZR = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_ZR")) ButtonZr = Convert.ToInt16(parser.Value("Controls_Right_JoyConKeyboard_Button_ZR"))
}); });
JoyConController = new JoyConController( JoyConController = new JoyConController(
Convert.ToBoolean(Parser.Value("GamePad_Enable")), Convert.ToBoolean(parser.Value("GamePad_Enable")),
Convert.ToInt32 (Parser.Value("GamePad_Index")), Convert.ToInt32 (parser.Value("GamePad_Index")),
(float)Convert.ToDouble (Parser.Value("GamePad_Deadzone"), CultureInfo.InvariantCulture), (float)Convert.ToDouble (parser.Value("GamePad_Deadzone"), CultureInfo.InvariantCulture),
(float)Convert.ToDouble (Parser.Value("GamePad_Trigger_Threshold"), CultureInfo.InvariantCulture), (float)Convert.ToDouble (parser.Value("GamePad_Trigger_Threshold"), CultureInfo.InvariantCulture),
new JoyConControllerLeft new JoyConControllerLeft
{ {
Stick = ToID(Parser.Value("Controls_Left_JoyConController_Stick")), Stick = ToId(parser.Value("Controls_Left_JoyConController_Stick")),
StickButton = ToID(Parser.Value("Controls_Left_JoyConController_Stick_Button")), StickButton = ToId(parser.Value("Controls_Left_JoyConController_Stick_Button")),
DPadUp = ToID(Parser.Value("Controls_Left_JoyConController_DPad_Up")), DPadUp = ToId(parser.Value("Controls_Left_JoyConController_DPad_Up")),
DPadDown = ToID(Parser.Value("Controls_Left_JoyConController_DPad_Down")), DPadDown = ToId(parser.Value("Controls_Left_JoyConController_DPad_Down")),
DPadLeft = ToID(Parser.Value("Controls_Left_JoyConController_DPad_Left")), DPadLeft = ToId(parser.Value("Controls_Left_JoyConController_DPad_Left")),
DPadRight = ToID(Parser.Value("Controls_Left_JoyConController_DPad_Right")), DPadRight = ToId(parser.Value("Controls_Left_JoyConController_DPad_Right")),
ButtonMinus = ToID(Parser.Value("Controls_Left_JoyConController_Button_Minus")), ButtonMinus = ToId(parser.Value("Controls_Left_JoyConController_Button_Minus")),
ButtonL = ToID(Parser.Value("Controls_Left_JoyConController_Button_L")), ButtonL = ToId(parser.Value("Controls_Left_JoyConController_Button_L")),
ButtonZL = ToID(Parser.Value("Controls_Left_JoyConController_Button_ZL")) ButtonZl = ToId(parser.Value("Controls_Left_JoyConController_Button_ZL"))
}, },
new JoyConControllerRight new JoyConControllerRight
{ {
Stick = ToID(Parser.Value("Controls_Right_JoyConController_Stick")), Stick = ToId(parser.Value("Controls_Right_JoyConController_Stick")),
StickButton = ToID(Parser.Value("Controls_Right_JoyConController_Stick_Button")), StickButton = ToId(parser.Value("Controls_Right_JoyConController_Stick_Button")),
ButtonA = ToID(Parser.Value("Controls_Right_JoyConController_Button_A")), ButtonA = ToId(parser.Value("Controls_Right_JoyConController_Button_A")),
ButtonB = ToID(Parser.Value("Controls_Right_JoyConController_Button_B")), ButtonB = ToId(parser.Value("Controls_Right_JoyConController_Button_B")),
ButtonX = ToID(Parser.Value("Controls_Right_JoyConController_Button_X")), ButtonX = ToId(parser.Value("Controls_Right_JoyConController_Button_X")),
ButtonY = ToID(Parser.Value("Controls_Right_JoyConController_Button_Y")), ButtonY = ToId(parser.Value("Controls_Right_JoyConController_Button_Y")),
ButtonPlus = ToID(Parser.Value("Controls_Right_JoyConController_Button_Plus")), ButtonPlus = ToId(parser.Value("Controls_Right_JoyConController_Button_Plus")),
ButtonR = ToID(Parser.Value("Controls_Right_JoyConController_Button_R")), ButtonR = ToId(parser.Value("Controls_Right_JoyConController_Button_R")),
ButtonZR = ToID(Parser.Value("Controls_Right_JoyConController_Button_ZR")) ButtonZr = ToId(parser.Value("Controls_Right_JoyConController_Button_ZR"))
}); });
} }
private static ControllerInputID ToID(string Key) private static ControllerInputId ToId(string key)
{ {
switch (Key.ToUpper()) switch (key.ToUpper())
{ {
case "LSTICK": return ControllerInputID.LStick; case "LSTICK": return ControllerInputId.LStick;
case "DPADUP": return ControllerInputID.DPadUp; case "DPADUP": return ControllerInputId.DPadUp;
case "DPADDOWN": return ControllerInputID.DPadDown; case "DPADDOWN": return ControllerInputId.DPadDown;
case "DPADLEFT": return ControllerInputID.DPadLeft; case "DPADLEFT": return ControllerInputId.DPadLeft;
case "DPADRIGHT": return ControllerInputID.DPadRight; case "DPADRIGHT": return ControllerInputId.DPadRight;
case "BACK": return ControllerInputID.Back; case "BACK": return ControllerInputId.Back;
case "LSHOULDER": return ControllerInputID.LShoulder; case "LSHOULDER": return ControllerInputId.LShoulder;
case "LTRIGGER": return ControllerInputID.LTrigger; case "LTRIGGER": return ControllerInputId.LTrigger;
case "RSTICK": return ControllerInputID.RStick; case "RSTICK": return ControllerInputId.RStick;
case "A": return ControllerInputID.A; case "A": return ControllerInputId.A;
case "B": return ControllerInputID.B; case "B": return ControllerInputId.B;
case "X": return ControllerInputID.X; case "X": return ControllerInputId.X;
case "Y": return ControllerInputID.Y; case "Y": return ControllerInputId.Y;
case "START": return ControllerInputID.Start; case "START": return ControllerInputId.Start;
case "RSHOULDER": return ControllerInputID.RShoulder; case "RSHOULDER": return ControllerInputId.RShoulder;
case "RTRIGGER": return ControllerInputID.RTrigger; case "RTRIGGER": return ControllerInputId.RTrigger;
case "LJOYSTICK": return ControllerInputID.LJoystick; case "LJOYSTICK": return ControllerInputId.LJoystick;
case "RJOYSTICK": return ControllerInputID.RJoystick; case "RJOYSTICK": return ControllerInputId.RJoystick;
default: return ControllerInputID.Invalid; default: return ControllerInputId.Invalid;
} }
} }
} }
@ -171,19 +171,19 @@ namespace Ryujinx
//https://stackoverflow.com/a/37772571 //https://stackoverflow.com/a/37772571
public class IniParser public class IniParser
{ {
private readonly Dictionary<string, string> Values; private readonly Dictionary<string, string> _values;
public IniParser(string Path) public IniParser(string path)
{ {
Values = File.ReadLines(Path) _values = File.ReadLines(path)
.Where(Line => !string.IsNullOrWhiteSpace(Line) && !Line.StartsWith('#')) .Where(line => !string.IsNullOrWhiteSpace(line) && !line.StartsWith('#'))
.Select(Line => Line.Split('=', 2)) .Select(line => line.Split('=', 2))
.ToDictionary(Parts => Parts[0].Trim(), Parts => Parts.Length > 1 ? Parts[1].Trim() : null); .ToDictionary(parts => parts[0].Trim(), parts => parts.Length > 1 ? parts[1].Trim() : null);
} }
public string Value(string Name) public string Value(string name)
{ {
return Values.TryGetValue(Name, out string Value) ? Value : null; return _values.TryGetValue(name, out string value) ? value : null;
} }
} }
} }

View file

@ -8,17 +8,17 @@ namespace Ryujinx
{ {
static class ConsoleLog static class ConsoleLog
{ {
private static Thread MessageThread; private static Thread _messageThread;
private static BlockingCollection<LogEventArgs> MessageQueue; private static BlockingCollection<LogEventArgs> _messageQueue;
private static Dictionary<LogLevel, ConsoleColor> LogColors; private static Dictionary<LogLevel, ConsoleColor> _logColors;
private static object ConsoleLock; private static object _consoleLock;
static ConsoleLog() static ConsoleLog()
{ {
LogColors = new Dictionary<LogLevel, ConsoleColor>() _logColors = new Dictionary<LogLevel, ConsoleColor>()
{ {
{ LogLevel.Stub, ConsoleColor.DarkGray }, { LogLevel.Stub, ConsoleColor.DarkGray },
{ LogLevel.Info, ConsoleColor.White }, { LogLevel.Info, ConsoleColor.White },
@ -26,17 +26,17 @@ namespace Ryujinx
{ LogLevel.Error, ConsoleColor.Red } { LogLevel.Error, ConsoleColor.Red }
}; };
MessageQueue = new BlockingCollection<LogEventArgs>(); _messageQueue = new BlockingCollection<LogEventArgs>();
ConsoleLock = new object(); _consoleLock = new object();
MessageThread = new Thread(() => _messageThread = new Thread(() =>
{ {
while (!MessageQueue.IsCompleted) while (!_messageQueue.IsCompleted)
{ {
try try
{ {
PrintLog(MessageQueue.Take()); PrintLog(_messageQueue.Take());
} }
catch (InvalidOperationException) catch (InvalidOperationException)
{ {
@ -49,39 +49,39 @@ namespace Ryujinx
} }
}); });
MessageThread.IsBackground = true; _messageThread.IsBackground = true;
MessageThread.Start(); _messageThread.Start();
} }
private static void PrintLog(LogEventArgs e) private static void PrintLog(LogEventArgs e)
{ {
string FormattedTime = e.Time.ToString(@"hh\:mm\:ss\.fff"); string formattedTime = e.Time.ToString(@"hh\:mm\:ss\.fff");
string CurrentThread = Thread.CurrentThread.ManagedThreadId.ToString("d4"); string currentThread = Thread.CurrentThread.ManagedThreadId.ToString("d4");
string Message = FormattedTime + " | " + CurrentThread + " " + e.Message; string message = formattedTime + " | " + currentThread + " " + e.Message;
if (LogColors.TryGetValue(e.Level, out ConsoleColor Color)) if (_logColors.TryGetValue(e.Level, out ConsoleColor color))
{ {
lock (ConsoleLock) lock (_consoleLock)
{ {
Console.ForegroundColor = Color; Console.ForegroundColor = color;
Console.WriteLine(Message); Console.WriteLine(message);
Console.ResetColor(); Console.ResetColor();
} }
} }
else else
{ {
Console.WriteLine(Message); Console.WriteLine(message);
} }
} }
public static void Log(object sender, LogEventArgs e) public static void Log(object sender, LogEventArgs e)
{ {
if (!MessageQueue.IsAddingCompleted) if (!_messageQueue.IsAddingCompleted)
{ {
MessageQueue.Add(e); _messageQueue.Add(e);
} }
} }
} }

View file

@ -11,37 +11,37 @@ using Stopwatch = System.Diagnostics.Stopwatch;
namespace Ryujinx namespace Ryujinx
{ {
public class GLScreen : GameWindow public class GlScreen : GameWindow
{ {
private const int TouchScreenWidth = 1280; private const int TouchScreenWidth = 1280;
private const int TouchScreenHeight = 720; private const int TouchScreenHeight = 720;
private const int TargetFPS = 60; private const int TargetFps = 60;
private Switch Device; private Switch _device;
private IGalRenderer Renderer; private IGalRenderer _renderer;
private KeyboardState? Keyboard = null; private KeyboardState? _keyboard = null;
private MouseState? Mouse = null; private MouseState? _mouse = null;
private Thread RenderThread; private Thread _renderThread;
private bool ResizeEvent; private bool _resizeEvent;
private bool TitleEvent; private bool _titleEvent;
private string NewTitle; private string _newTitle;
public GLScreen(Switch Device, IGalRenderer Renderer) public GlScreen(Switch device, IGalRenderer renderer)
: base(1280, 720, : base(1280, 720,
new GraphicsMode(), "Ryujinx", 0, new GraphicsMode(), "Ryujinx", 0,
DisplayDevice.Default, 3, 3, DisplayDevice.Default, 3, 3,
GraphicsContextFlags.ForwardCompatible) GraphicsContextFlags.ForwardCompatible)
{ {
this.Device = Device; this._device = device;
this.Renderer = Renderer; this._renderer = renderer;
Location = new Point( Location = new Point(
(DisplayDevice.Default.Width / 2) - (Width / 2), (DisplayDevice.Default.Width / 2) - (Width / 2),
@ -52,40 +52,40 @@ namespace Ryujinx
{ {
MakeCurrent(); MakeCurrent();
Stopwatch Chrono = new Stopwatch(); Stopwatch chrono = new Stopwatch();
Chrono.Start(); chrono.Start();
long TicksPerFrame = Stopwatch.Frequency / TargetFPS; long ticksPerFrame = Stopwatch.Frequency / TargetFps;
long Ticks = 0; long ticks = 0;
while (Exists && !IsExiting) while (Exists && !IsExiting)
{ {
if (Device.WaitFifo()) if (_device.WaitFifo())
{ {
Device.ProcessFrame(); _device.ProcessFrame();
} }
Renderer.RunActions(); _renderer.RunActions();
if (ResizeEvent) if (_resizeEvent)
{ {
ResizeEvent = false; _resizeEvent = false;
Renderer.RenderTarget.SetWindowSize(Width, Height); _renderer.RenderTarget.SetWindowSize(Width, Height);
} }
Ticks += Chrono.ElapsedTicks; ticks += chrono.ElapsedTicks;
Chrono.Restart(); chrono.Restart();
if (Ticks >= TicksPerFrame) if (ticks >= ticksPerFrame)
{ {
RenderFrame(); RenderFrame();
//Queue max. 1 vsync //Queue max. 1 vsync
Ticks = Math.Min(Ticks - TicksPerFrame, TicksPerFrame); ticks = Math.Min(ticks - ticksPerFrame, ticksPerFrame);
} }
} }
} }
@ -96,14 +96,14 @@ namespace Ryujinx
Visible = true; Visible = true;
Renderer.RenderTarget.SetWindowSize(Width, Height); _renderer.RenderTarget.SetWindowSize(Width, Height);
Context.MakeCurrent(null); Context.MakeCurrent(null);
//OpenTK doesn't like sleeps in its thread, to avoid this a renderer thread is created //OpenTK doesn't like sleeps in its thread, to avoid this a renderer thread is created
RenderThread = new Thread(RenderLoop); _renderThread = new Thread(RenderLoop);
RenderThread.Start(); _renderThread.Start();
while (Exists && !IsExiting) while (Exists && !IsExiting)
{ {
@ -113,11 +113,11 @@ namespace Ryujinx
{ {
UpdateFrame(); UpdateFrame();
if (TitleEvent) if (_titleEvent)
{ {
TitleEvent = false; _titleEvent = false;
Title = NewTitle; Title = _newTitle;
} }
} }
@ -128,94 +128,94 @@ namespace Ryujinx
private new void UpdateFrame() private new void UpdateFrame()
{ {
HidControllerButtons CurrentButton = 0; HidControllerButtons currentButton = 0;
HidJoystickPosition LeftJoystick; HidJoystickPosition leftJoystick;
HidJoystickPosition RightJoystick; HidJoystickPosition rightJoystick;
int LeftJoystickDX = 0; int leftJoystickDx = 0;
int LeftJoystickDY = 0; int leftJoystickDy = 0;
int RightJoystickDX = 0; int rightJoystickDx = 0;
int RightJoystickDY = 0; int rightJoystickDy = 0;
//Keyboard Input //Keyboard Input
if (Keyboard.HasValue) if (_keyboard.HasValue)
{ {
KeyboardState Keyboard = this.Keyboard.Value; KeyboardState keyboard = this._keyboard.Value;
CurrentButton = Config.JoyConKeyboard.GetButtons(Keyboard); currentButton = Config.JoyConKeyboard.GetButtons(keyboard);
(LeftJoystickDX, LeftJoystickDY) = Config.JoyConKeyboard.GetLeftStick(Keyboard); (leftJoystickDx, leftJoystickDy) = Config.JoyConKeyboard.GetLeftStick(keyboard);
(RightJoystickDX, RightJoystickDY) = Config.JoyConKeyboard.GetRightStick(Keyboard); (rightJoystickDx, rightJoystickDy) = Config.JoyConKeyboard.GetRightStick(keyboard);
} }
//Controller Input //Controller Input
CurrentButton |= Config.JoyConController.GetButtons(); currentButton |= Config.JoyConController.GetButtons();
//Keyboard has priority stick-wise //Keyboard has priority stick-wise
if (LeftJoystickDX == 0 && LeftJoystickDY == 0) if (leftJoystickDx == 0 && leftJoystickDy == 0)
{ {
(LeftJoystickDX, LeftJoystickDY) = Config.JoyConController.GetLeftStick(); (leftJoystickDx, leftJoystickDy) = Config.JoyConController.GetLeftStick();
} }
if (RightJoystickDX == 0 && RightJoystickDY == 0) if (rightJoystickDx == 0 && rightJoystickDy == 0)
{ {
(RightJoystickDX, RightJoystickDY) = Config.JoyConController.GetRightStick(); (rightJoystickDx, rightJoystickDy) = Config.JoyConController.GetRightStick();
} }
LeftJoystick = new HidJoystickPosition leftJoystick = new HidJoystickPosition
{ {
DX = LeftJoystickDX, DX = leftJoystickDx,
DY = LeftJoystickDY DY = leftJoystickDy
}; };
RightJoystick = new HidJoystickPosition rightJoystick = new HidJoystickPosition
{ {
DX = RightJoystickDX, DX = rightJoystickDx,
DY = RightJoystickDY DY = rightJoystickDy
}; };
bool HasTouch = false; bool hasTouch = false;
//Get screen touch position from left mouse click //Get screen touch position from left mouse click
//OpenTK always captures mouse events, even if out of focus, so check if window is focused. //OpenTK always captures mouse events, even if out of focus, so check if window is focused.
if (Focused && Mouse?.LeftButton == ButtonState.Pressed) if (Focused && _mouse?.LeftButton == ButtonState.Pressed)
{ {
MouseState Mouse = this.Mouse.Value; MouseState mouse = this._mouse.Value;
int ScrnWidth = Width; int scrnWidth = Width;
int ScrnHeight = Height; int scrnHeight = Height;
if (Width > (Height * TouchScreenWidth) / TouchScreenHeight) if (Width > (Height * TouchScreenWidth) / TouchScreenHeight)
{ {
ScrnWidth = (Height * TouchScreenWidth) / TouchScreenHeight; scrnWidth = (Height * TouchScreenWidth) / TouchScreenHeight;
} }
else else
{ {
ScrnHeight = (Width * TouchScreenHeight) / TouchScreenWidth; scrnHeight = (Width * TouchScreenHeight) / TouchScreenWidth;
} }
int StartX = (Width - ScrnWidth) >> 1; int startX = (Width - scrnWidth) >> 1;
int StartY = (Height - ScrnHeight) >> 1; int startY = (Height - scrnHeight) >> 1;
int EndX = StartX + ScrnWidth; int endX = startX + scrnWidth;
int EndY = StartY + ScrnHeight; int endY = startY + scrnHeight;
if (Mouse.X >= StartX && if (mouse.X >= startX &&
Mouse.Y >= StartY && mouse.Y >= startY &&
Mouse.X < EndX && mouse.X < endX &&
Mouse.Y < EndY) mouse.Y < endY)
{ {
int ScrnMouseX = Mouse.X - StartX; int scrnMouseX = mouse.X - startX;
int ScrnMouseY = Mouse.Y - StartY; int scrnMouseY = mouse.Y - startY;
int MX = (ScrnMouseX * TouchScreenWidth) / ScrnWidth; int mx = (scrnMouseX * TouchScreenWidth) / scrnWidth;
int MY = (ScrnMouseY * TouchScreenHeight) / ScrnHeight; int my = (scrnMouseY * TouchScreenHeight) / scrnHeight;
HidTouchPoint CurrentPoint = new HidTouchPoint HidTouchPoint currentPoint = new HidTouchPoint
{ {
X = MX, X = mx,
Y = MY, Y = my,
//Placeholder values till more data is acquired //Placeholder values till more data is acquired
DiameterX = 10, DiameterX = 10,
@ -223,76 +223,76 @@ namespace Ryujinx
Angle = 90 Angle = 90
}; };
HasTouch = true; hasTouch = true;
Device.Hid.SetTouchPoints(CurrentPoint); _device.Hid.SetTouchPoints(currentPoint);
} }
} }
if (!HasTouch) if (!hasTouch)
{ {
Device.Hid.SetTouchPoints(); _device.Hid.SetTouchPoints();
} }
Device.Hid.SetJoyconButton( _device.Hid.SetJoyconButton(
HidControllerId.CONTROLLER_HANDHELD, HidControllerId.CONTROLLER_HANDHELD,
HidControllerLayouts.Handheld_Joined, HidControllerLayouts.Handheld_Joined,
CurrentButton, currentButton,
LeftJoystick, leftJoystick,
RightJoystick); rightJoystick);
Device.Hid.SetJoyconButton( _device.Hid.SetJoyconButton(
HidControllerId.CONTROLLER_HANDHELD, HidControllerId.CONTROLLER_HANDHELD,
HidControllerLayouts.Main, HidControllerLayouts.Main,
CurrentButton, currentButton,
LeftJoystick, leftJoystick,
RightJoystick); rightJoystick);
} }
private new void RenderFrame() private new void RenderFrame()
{ {
Renderer.RenderTarget.Render(); _renderer.RenderTarget.Render();
Device.Statistics.RecordSystemFrameTime(); _device.Statistics.RecordSystemFrameTime();
double HostFps = Device.Statistics.GetSystemFrameRate(); double hostFps = _device.Statistics.GetSystemFrameRate();
double GameFps = Device.Statistics.GetGameFrameRate(); double gameFps = _device.Statistics.GetGameFrameRate();
string TitleSection = string.IsNullOrWhiteSpace(Device.System.CurrentTitle) ? string.Empty string titleSection = string.IsNullOrWhiteSpace(_device.System.CurrentTitle) ? string.Empty
: " | " + Device.System.CurrentTitle; : " | " + _device.System.CurrentTitle;
NewTitle = $"Ryujinx{TitleSection} | Host FPS: {HostFps:0.0} | Game FPS: {GameFps:0.0} | " + _newTitle = $"Ryujinx{titleSection} | Host FPS: {hostFps:0.0} | Game FPS: {gameFps:0.0} | " +
$"Game Vsync: {(Device.EnableDeviceVsync ? "On" : "Off")}"; $"Game Vsync: {(_device.EnableDeviceVsync ? "On" : "Off")}";
TitleEvent = true; _titleEvent = true;
SwapBuffers(); SwapBuffers();
Device.System.SignalVsync(); _device.System.SignalVsync();
Device.VsyncEvent.Set(); _device.VsyncEvent.Set();
} }
protected override void OnUnload(EventArgs e) protected override void OnUnload(EventArgs e)
{ {
RenderThread.Join(); _renderThread.Join();
base.OnUnload(e); base.OnUnload(e);
} }
protected override void OnResize(EventArgs e) protected override void OnResize(EventArgs e)
{ {
ResizeEvent = true; _resizeEvent = true;
} }
protected override void OnKeyDown(KeyboardKeyEventArgs e) protected override void OnKeyDown(KeyboardKeyEventArgs e)
{ {
bool ToggleFullscreen = e.Key == Key.F11 || bool toggleFullscreen = e.Key == Key.F11 ||
(e.Modifiers.HasFlag(KeyModifiers.Alt) && e.Key == Key.Enter); (e.Modifiers.HasFlag(KeyModifiers.Alt) && e.Key == Key.Enter);
if (WindowState == WindowState.Fullscreen) if (WindowState == WindowState.Fullscreen)
{ {
if (e.Key == Key.Escape || ToggleFullscreen) if (e.Key == Key.Escape || toggleFullscreen)
{ {
WindowState = WindowState.Normal; WindowState = WindowState.Normal;
} }
@ -304,33 +304,33 @@ namespace Ryujinx
Exit(); Exit();
} }
if (ToggleFullscreen) if (toggleFullscreen)
{ {
WindowState = WindowState.Fullscreen; WindowState = WindowState.Fullscreen;
} }
} }
Keyboard = e.Keyboard; _keyboard = e.Keyboard;
} }
protected override void OnKeyUp(KeyboardKeyEventArgs e) protected override void OnKeyUp(KeyboardKeyEventArgs e)
{ {
Keyboard = e.Keyboard; _keyboard = e.Keyboard;
} }
protected override void OnMouseDown(MouseButtonEventArgs e) protected override void OnMouseDown(MouseButtonEventArgs e)
{ {
Mouse = e.Mouse; _mouse = e.Mouse;
} }
protected override void OnMouseUp(MouseButtonEventArgs e) protected override void OnMouseUp(MouseButtonEventArgs e)
{ {
Mouse = e.Mouse; _mouse = e.Mouse;
} }
protected override void OnMouseMove(MouseMoveEventArgs e) protected override void OnMouseMove(MouseMoveEventArgs e)
{ {
Mouse = e.Mouse; _mouse = e.Mouse;
} }
} }
} }

View file

@ -5,7 +5,7 @@ using System;
namespace Ryujinx.UI.Input namespace Ryujinx.UI.Input
{ {
public enum ControllerInputID public enum ControllerInputId
{ {
Invalid, Invalid,
@ -34,28 +34,28 @@ namespace Ryujinx.UI.Input
public struct JoyConControllerLeft public struct JoyConControllerLeft
{ {
public ControllerInputID Stick; public ControllerInputId Stick;
public ControllerInputID StickButton; public ControllerInputId StickButton;
public ControllerInputID DPadUp; public ControllerInputId DPadUp;
public ControllerInputID DPadDown; public ControllerInputId DPadDown;
public ControllerInputID DPadLeft; public ControllerInputId DPadLeft;
public ControllerInputID DPadRight; public ControllerInputId DPadRight;
public ControllerInputID ButtonMinus; public ControllerInputId ButtonMinus;
public ControllerInputID ButtonL; public ControllerInputId ButtonL;
public ControllerInputID ButtonZL; public ControllerInputId ButtonZl;
} }
public struct JoyConControllerRight public struct JoyConControllerRight
{ {
public ControllerInputID Stick; public ControllerInputId Stick;
public ControllerInputID StickButton; public ControllerInputId StickButton;
public ControllerInputID ButtonA; public ControllerInputId ButtonA;
public ControllerInputID ButtonB; public ControllerInputId ButtonB;
public ControllerInputID ButtonX; public ControllerInputId ButtonX;
public ControllerInputID ButtonY; public ControllerInputId ButtonY;
public ControllerInputID ButtonPlus; public ControllerInputId ButtonPlus;
public ControllerInputID ButtonR; public ControllerInputId ButtonR;
public ControllerInputID ButtonZR; public ControllerInputId ButtonZr;
} }
public class JoyConController public class JoyConController
@ -69,22 +69,22 @@ namespace Ryujinx.UI.Input
public JoyConControllerRight Right { private set; get; } public JoyConControllerRight Right { private set; get; }
public JoyConController( public JoyConController(
bool Enabled, bool enabled,
int Index, int index,
float Deadzone, float deadzone,
float TriggerThreshold, float triggerThreshold,
JoyConControllerLeft Left, JoyConControllerLeft left,
JoyConControllerRight Right) JoyConControllerRight right)
{ {
this.Enabled = Enabled; this.Enabled = enabled;
this.Index = Index; this.Index = index;
this.Deadzone = Deadzone; this.Deadzone = deadzone;
this.TriggerThreshold = TriggerThreshold; this.TriggerThreshold = triggerThreshold;
this.Left = Left; this.Left = left;
this.Right = Right; this.Right = right;
//Unmapped controllers are problematic, skip them //Unmapped controllers are problematic, skip them
if (GamePad.GetName(Index) == "Unmapped Controller") if (GamePad.GetName(index) == "Unmapped Controller")
{ {
this.Enabled = false; this.Enabled = false;
} }
@ -97,29 +97,29 @@ namespace Ryujinx.UI.Input
return 0; return 0;
} }
GamePadState GpState = GamePad.GetState(Index); GamePadState gpState = GamePad.GetState(Index);
HidControllerButtons Buttons = 0; HidControllerButtons buttons = 0;
if (IsPressed(GpState, Left.DPadUp)) Buttons |= HidControllerButtons.KEY_DUP; if (IsPressed(gpState, Left.DPadUp)) buttons |= HidControllerButtons.KEY_DUP;
if (IsPressed(GpState, Left.DPadDown)) Buttons |= HidControllerButtons.KEY_DDOWN; if (IsPressed(gpState, Left.DPadDown)) buttons |= HidControllerButtons.KEY_DDOWN;
if (IsPressed(GpState, Left.DPadLeft)) Buttons |= HidControllerButtons.KEY_DLEFT; if (IsPressed(gpState, Left.DPadLeft)) buttons |= HidControllerButtons.KEY_DLEFT;
if (IsPressed(GpState, Left.DPadRight)) Buttons |= HidControllerButtons.KEY_DRIGHT; if (IsPressed(gpState, Left.DPadRight)) buttons |= HidControllerButtons.KEY_DRIGHT;
if (IsPressed(GpState, Left.StickButton)) Buttons |= HidControllerButtons.KEY_LSTICK; if (IsPressed(gpState, Left.StickButton)) buttons |= HidControllerButtons.KEY_LSTICK;
if (IsPressed(GpState, Left.ButtonMinus)) Buttons |= HidControllerButtons.KEY_MINUS; if (IsPressed(gpState, Left.ButtonMinus)) buttons |= HidControllerButtons.KEY_MINUS;
if (IsPressed(GpState, Left.ButtonL)) Buttons |= HidControllerButtons.KEY_L; if (IsPressed(gpState, Left.ButtonL)) buttons |= HidControllerButtons.KEY_L;
if (IsPressed(GpState, Left.ButtonZL)) Buttons |= HidControllerButtons.KEY_ZL; if (IsPressed(gpState, Left.ButtonZl)) buttons |= HidControllerButtons.KEY_ZL;
if (IsPressed(GpState, Right.ButtonA)) Buttons |= HidControllerButtons.KEY_A; if (IsPressed(gpState, Right.ButtonA)) buttons |= HidControllerButtons.KEY_A;
if (IsPressed(GpState, Right.ButtonB)) Buttons |= HidControllerButtons.KEY_B; if (IsPressed(gpState, Right.ButtonB)) buttons |= HidControllerButtons.KEY_B;
if (IsPressed(GpState, Right.ButtonX)) Buttons |= HidControllerButtons.KEY_X; if (IsPressed(gpState, Right.ButtonX)) buttons |= HidControllerButtons.KEY_X;
if (IsPressed(GpState, Right.ButtonY)) Buttons |= HidControllerButtons.KEY_Y; if (IsPressed(gpState, Right.ButtonY)) buttons |= HidControllerButtons.KEY_Y;
if (IsPressed(GpState, Right.StickButton)) Buttons |= HidControllerButtons.KEY_RSTICK; if (IsPressed(gpState, Right.StickButton)) buttons |= HidControllerButtons.KEY_RSTICK;
if (IsPressed(GpState, Right.ButtonPlus)) Buttons |= HidControllerButtons.KEY_PLUS; if (IsPressed(gpState, Right.ButtonPlus)) buttons |= HidControllerButtons.KEY_PLUS;
if (IsPressed(GpState, Right.ButtonR)) Buttons |= HidControllerButtons.KEY_R; if (IsPressed(gpState, Right.ButtonR)) buttons |= HidControllerButtons.KEY_R;
if (IsPressed(GpState, Right.ButtonZR)) Buttons |= HidControllerButtons.KEY_ZR; if (IsPressed(gpState, Right.ButtonZr)) buttons |= HidControllerButtons.KEY_ZR;
return Buttons; return buttons;
} }
public (short, short) GetLeftStick() public (short, short) GetLeftStick()
@ -142,71 +142,71 @@ namespace Ryujinx.UI.Input
return GetStick(Right.Stick); return GetStick(Right.Stick);
} }
private (short, short) GetStick(ControllerInputID Joystick) private (short, short) GetStick(ControllerInputId joystick)
{ {
GamePadState GpState = GamePad.GetState(Index); GamePadState gpState = GamePad.GetState(Index);
switch (Joystick) switch (joystick)
{ {
case ControllerInputID.LJoystick: case ControllerInputId.LJoystick:
return ApplyDeadzone(GpState.ThumbSticks.Left); return ApplyDeadzone(gpState.ThumbSticks.Left);
case ControllerInputID.RJoystick: case ControllerInputId.RJoystick:
return ApplyDeadzone(GpState.ThumbSticks.Right); return ApplyDeadzone(gpState.ThumbSticks.Right);
default: default:
return (0, 0); return (0, 0);
} }
} }
private (short, short) ApplyDeadzone(Vector2 Axis) private (short, short) ApplyDeadzone(Vector2 axis)
{ {
return (ClampAxis(MathF.Abs(Axis.X) > Deadzone ? Axis.X : 0f), return (ClampAxis(MathF.Abs(axis.X) > Deadzone ? axis.X : 0f),
ClampAxis(MathF.Abs(Axis.Y) > Deadzone ? Axis.Y : 0f)); ClampAxis(MathF.Abs(axis.Y) > Deadzone ? axis.Y : 0f));
} }
private static short ClampAxis(float Value) private static short ClampAxis(float value)
{ {
if (Value <= -short.MaxValue) if (value <= -short.MaxValue)
{ {
return -short.MaxValue; return -short.MaxValue;
} }
else else
{ {
return (short)(Value * short.MaxValue); return (short)(value * short.MaxValue);
} }
} }
private bool IsPressed(GamePadState GpState, ControllerInputID Button) private bool IsPressed(GamePadState gpState, ControllerInputId button)
{ {
switch (Button) switch (button)
{ {
case ControllerInputID.A: return GpState.Buttons.A == ButtonState.Pressed; case ControllerInputId.A: return gpState.Buttons.A == ButtonState.Pressed;
case ControllerInputID.B: return GpState.Buttons.B == ButtonState.Pressed; case ControllerInputId.B: return gpState.Buttons.B == ButtonState.Pressed;
case ControllerInputID.X: return GpState.Buttons.X == ButtonState.Pressed; case ControllerInputId.X: return gpState.Buttons.X == ButtonState.Pressed;
case ControllerInputID.Y: return GpState.Buttons.Y == ButtonState.Pressed; case ControllerInputId.Y: return gpState.Buttons.Y == ButtonState.Pressed;
case ControllerInputID.LStick: return GpState.Buttons.LeftStick == ButtonState.Pressed; case ControllerInputId.LStick: return gpState.Buttons.LeftStick == ButtonState.Pressed;
case ControllerInputID.RStick: return GpState.Buttons.RightStick == ButtonState.Pressed; case ControllerInputId.RStick: return gpState.Buttons.RightStick == ButtonState.Pressed;
case ControllerInputID.LShoulder: return GpState.Buttons.LeftShoulder == ButtonState.Pressed; case ControllerInputId.LShoulder: return gpState.Buttons.LeftShoulder == ButtonState.Pressed;
case ControllerInputID.RShoulder: return GpState.Buttons.RightShoulder == ButtonState.Pressed; case ControllerInputId.RShoulder: return gpState.Buttons.RightShoulder == ButtonState.Pressed;
case ControllerInputID.DPadUp: return GpState.DPad.Up == ButtonState.Pressed; case ControllerInputId.DPadUp: return gpState.DPad.Up == ButtonState.Pressed;
case ControllerInputID.DPadDown: return GpState.DPad.Down == ButtonState.Pressed; case ControllerInputId.DPadDown: return gpState.DPad.Down == ButtonState.Pressed;
case ControllerInputID.DPadLeft: return GpState.DPad.Left == ButtonState.Pressed; case ControllerInputId.DPadLeft: return gpState.DPad.Left == ButtonState.Pressed;
case ControllerInputID.DPadRight: return GpState.DPad.Right == ButtonState.Pressed; case ControllerInputId.DPadRight: return gpState.DPad.Right == ButtonState.Pressed;
case ControllerInputID.Start: return GpState.Buttons.Start == ButtonState.Pressed; case ControllerInputId.Start: return gpState.Buttons.Start == ButtonState.Pressed;
case ControllerInputID.Back: return GpState.Buttons.Back == ButtonState.Pressed; case ControllerInputId.Back: return gpState.Buttons.Back == ButtonState.Pressed;
case ControllerInputID.LTrigger: return GpState.Triggers.Left >= TriggerThreshold; case ControllerInputId.LTrigger: return gpState.Triggers.Left >= TriggerThreshold;
case ControllerInputID.RTrigger: return GpState.Triggers.Right >= TriggerThreshold; case ControllerInputId.RTrigger: return gpState.Triggers.Right >= TriggerThreshold;
//Using thumbsticks as buttons is not common, but it would be nice not to ignore them //Using thumbsticks as buttons is not common, but it would be nice not to ignore them
case ControllerInputID.LJoystick: case ControllerInputId.LJoystick:
return GpState.ThumbSticks.Left.X >= Deadzone || return gpState.ThumbSticks.Left.X >= Deadzone ||
GpState.ThumbSticks.Left.Y >= Deadzone; gpState.ThumbSticks.Left.Y >= Deadzone;
case ControllerInputID.RJoystick: case ControllerInputId.RJoystick:
return GpState.ThumbSticks.Right.X >= Deadzone || return gpState.ThumbSticks.Right.X >= Deadzone ||
GpState.ThumbSticks.Right.Y >= Deadzone; gpState.ThumbSticks.Right.Y >= Deadzone;
default: default:
return false; return false;

View file

@ -16,7 +16,7 @@ namespace Ryujinx.UI.Input
public int DPadRight; public int DPadRight;
public int ButtonMinus; public int ButtonMinus;
public int ButtonL; public int ButtonL;
public int ButtonZL; public int ButtonZl;
} }
public struct JoyConKeyboardRight public struct JoyConKeyboardRight
@ -32,7 +32,7 @@ namespace Ryujinx.UI.Input
public int ButtonY; public int ButtonY;
public int ButtonPlus; public int ButtonPlus;
public int ButtonR; public int ButtonR;
public int ButtonZR; public int ButtonZr;
} }
public class JoyConKeyboard public class JoyConKeyboard
@ -41,62 +41,62 @@ namespace Ryujinx.UI.Input
public JoyConKeyboardRight Right; public JoyConKeyboardRight Right;
public JoyConKeyboard( public JoyConKeyboard(
JoyConKeyboardLeft Left, JoyConKeyboardLeft left,
JoyConKeyboardRight Right) JoyConKeyboardRight right)
{ {
this.Left = Left; this.Left = left;
this.Right = Right; this.Right = right;
} }
public HidControllerButtons GetButtons(KeyboardState Keyboard) public HidControllerButtons GetButtons(KeyboardState keyboard)
{ {
HidControllerButtons Buttons = 0; HidControllerButtons buttons = 0;
if (Keyboard[(Key)Left.StickButton]) Buttons |= HidControllerButtons.KEY_LSTICK; if (keyboard[(Key)Left.StickButton]) buttons |= HidControllerButtons.KEY_LSTICK;
if (Keyboard[(Key)Left.DPadUp]) Buttons |= HidControllerButtons.KEY_DUP; if (keyboard[(Key)Left.DPadUp]) buttons |= HidControllerButtons.KEY_DUP;
if (Keyboard[(Key)Left.DPadDown]) Buttons |= HidControllerButtons.KEY_DDOWN; if (keyboard[(Key)Left.DPadDown]) buttons |= HidControllerButtons.KEY_DDOWN;
if (Keyboard[(Key)Left.DPadLeft]) Buttons |= HidControllerButtons.KEY_DLEFT; if (keyboard[(Key)Left.DPadLeft]) buttons |= HidControllerButtons.KEY_DLEFT;
if (Keyboard[(Key)Left.DPadRight]) Buttons |= HidControllerButtons.KEY_DRIGHT; if (keyboard[(Key)Left.DPadRight]) buttons |= HidControllerButtons.KEY_DRIGHT;
if (Keyboard[(Key)Left.ButtonMinus]) Buttons |= HidControllerButtons.KEY_MINUS; if (keyboard[(Key)Left.ButtonMinus]) buttons |= HidControllerButtons.KEY_MINUS;
if (Keyboard[(Key)Left.ButtonL]) Buttons |= HidControllerButtons.KEY_L; if (keyboard[(Key)Left.ButtonL]) buttons |= HidControllerButtons.KEY_L;
if (Keyboard[(Key)Left.ButtonZL]) Buttons |= HidControllerButtons.KEY_ZL; if (keyboard[(Key)Left.ButtonZl]) buttons |= HidControllerButtons.KEY_ZL;
if (Keyboard[(Key)Right.StickButton]) Buttons |= HidControllerButtons.KEY_RSTICK; if (keyboard[(Key)Right.StickButton]) buttons |= HidControllerButtons.KEY_RSTICK;
if (Keyboard[(Key)Right.ButtonA]) Buttons |= HidControllerButtons.KEY_A; if (keyboard[(Key)Right.ButtonA]) buttons |= HidControllerButtons.KEY_A;
if (Keyboard[(Key)Right.ButtonB]) Buttons |= HidControllerButtons.KEY_B; if (keyboard[(Key)Right.ButtonB]) buttons |= HidControllerButtons.KEY_B;
if (Keyboard[(Key)Right.ButtonX]) Buttons |= HidControllerButtons.KEY_X; if (keyboard[(Key)Right.ButtonX]) buttons |= HidControllerButtons.KEY_X;
if (Keyboard[(Key)Right.ButtonY]) Buttons |= HidControllerButtons.KEY_Y; if (keyboard[(Key)Right.ButtonY]) buttons |= HidControllerButtons.KEY_Y;
if (Keyboard[(Key)Right.ButtonPlus]) Buttons |= HidControllerButtons.KEY_PLUS; if (keyboard[(Key)Right.ButtonPlus]) buttons |= HidControllerButtons.KEY_PLUS;
if (Keyboard[(Key)Right.ButtonR]) Buttons |= HidControllerButtons.KEY_R; if (keyboard[(Key)Right.ButtonR]) buttons |= HidControllerButtons.KEY_R;
if (Keyboard[(Key)Right.ButtonZR]) Buttons |= HidControllerButtons.KEY_ZR; if (keyboard[(Key)Right.ButtonZr]) buttons |= HidControllerButtons.KEY_ZR;
return Buttons; return buttons;
} }
public (short, short) GetLeftStick(KeyboardState Keyboard) public (short, short) GetLeftStick(KeyboardState keyboard)
{ {
short DX = 0; short dx = 0;
short DY = 0; short dy = 0;
if (Keyboard[(Key)Left.StickUp]) DY = short.MaxValue; if (keyboard[(Key)Left.StickUp]) dy = short.MaxValue;
if (Keyboard[(Key)Left.StickDown]) DY = -short.MaxValue; if (keyboard[(Key)Left.StickDown]) dy = -short.MaxValue;
if (Keyboard[(Key)Left.StickLeft]) DX = -short.MaxValue; if (keyboard[(Key)Left.StickLeft]) dx = -short.MaxValue;
if (Keyboard[(Key)Left.StickRight]) DX = short.MaxValue; if (keyboard[(Key)Left.StickRight]) dx = short.MaxValue;
return (DX, DY); return (dx, dy);
} }
public (short, short) GetRightStick(KeyboardState Keyboard) public (short, short) GetRightStick(KeyboardState keyboard)
{ {
short DX = 0; short dx = 0;
short DY = 0; short dy = 0;
if (Keyboard[(Key)Right.StickUp]) DY = short.MaxValue; if (keyboard[(Key)Right.StickUp]) dy = short.MaxValue;
if (Keyboard[(Key)Right.StickDown]) DY = -short.MaxValue; if (keyboard[(Key)Right.StickDown]) dy = -short.MaxValue;
if (Keyboard[(Key)Right.StickLeft]) DX = -short.MaxValue; if (keyboard[(Key)Right.StickLeft]) dx = -short.MaxValue;
if (Keyboard[(Key)Right.StickRight]) DX = short.MaxValue; if (keyboard[(Key)Right.StickRight]) dx = short.MaxValue;
return (DX, DY); return (dx, dy);
} }
} }
} }

View file

@ -15,13 +15,13 @@ namespace Ryujinx
{ {
Console.Title = "Ryujinx Console"; Console.Title = "Ryujinx Console";
IGalRenderer Renderer = new OGLRenderer(); IGalRenderer renderer = new OGLRenderer();
IAalOutput AudioOut = new OpenALAudioOut(); IAalOutput audioOut = new OpenALAudioOut();
Switch Device = new Switch(Renderer, AudioOut); Switch device = new Switch(renderer, audioOut);
Config.Read(Device); Config.Read(device);
Logger.Updated += ConsoleLog.Log; Logger.Updated += ConsoleLog.Log;
@ -29,24 +29,24 @@ namespace Ryujinx
{ {
if (Directory.Exists(args[0])) if (Directory.Exists(args[0]))
{ {
string[] RomFsFiles = Directory.GetFiles(args[0], "*.istorage"); string[] romFsFiles = Directory.GetFiles(args[0], "*.istorage");
if (RomFsFiles.Length == 0) if (romFsFiles.Length == 0)
{ {
RomFsFiles = Directory.GetFiles(args[0], "*.romfs"); romFsFiles = Directory.GetFiles(args[0], "*.romfs");
} }
if (RomFsFiles.Length > 0) if (romFsFiles.Length > 0)
{ {
Console.WriteLine("Loading as cart with RomFS."); Console.WriteLine("Loading as cart with RomFS.");
Device.LoadCart(args[0], RomFsFiles[0]); device.LoadCart(args[0], romFsFiles[0]);
} }
else else
{ {
Console.WriteLine("Loading as cart WITHOUT RomFS."); Console.WriteLine("Loading as cart WITHOUT RomFS.");
Device.LoadCart(args[0]); device.LoadCart(args[0]);
} }
} }
else if (File.Exists(args[0])) else if (File.Exists(args[0]))
@ -55,19 +55,19 @@ namespace Ryujinx
{ {
case ".xci": case ".xci":
Console.WriteLine("Loading as XCI."); Console.WriteLine("Loading as XCI.");
Device.LoadXci(args[0]); device.LoadXci(args[0]);
break; break;
case ".nca": case ".nca":
Console.WriteLine("Loading as NCA."); Console.WriteLine("Loading as NCA.");
Device.LoadNca(args[0]); device.LoadNca(args[0]);
break; break;
case ".nsp": case ".nsp":
Console.WriteLine("Loading as NSP."); Console.WriteLine("Loading as NSP.");
Device.LoadNsp(args[0]); device.LoadNsp(args[0]);
break; break;
default: default:
Console.WriteLine("Loading as homebrew."); Console.WriteLine("Loading as homebrew.");
Device.LoadProgram(args[0]); device.LoadProgram(args[0]);
break; break;
} }
} }
@ -77,14 +77,14 @@ namespace Ryujinx
Console.WriteLine("Please specify the folder with the NSOs/IStorage or a NSO/NRO."); Console.WriteLine("Please specify the folder with the NSOs/IStorage or a NSO/NRO.");
} }
using (GLScreen Screen = new GLScreen(Device, Renderer)) using (GlScreen screen = new GlScreen(device, renderer))
{ {
Screen.MainLoop(); screen.MainLoop();
Device.Dispose(); device.Dispose();
} }
AudioOut.Dispose(); audioOut.Dispose();
} }
} }
} }