Adjust naming conventions for Ryujinx and ChocolArm64 projects (#484)

* Change naming convention for Ryujinx project

* Change naming convention for ChocolArm64 project

* Fix NaN

* Remove unneeded this. from Ryujinx project

* Adjust naming from new PRs

* Name changes based on feedback

* How did this get removed?

* Rebasing fix

* Change FP enum case

* Remove prefix from ChocolArm64 classes - Part 1

* Remove prefix from ChocolArm64 classes - Part 2

* Fix alignment from last commit's renaming

* Rename namespaces

* Rename stragglers

* Fix alignment

* Rename OpCode class

* Missed a few

* Adjust alignment
This commit is contained in:
Alex Barney 2018-10-30 19:43:02 -06:00 committed by gdkchan
parent 8be135d2d0
commit 2a6b39d3f6
314 changed files with 19456 additions and 19456 deletions

View file

@ -8,17 +8,17 @@ namespace Ryujinx
{
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()
{
LogColors = new Dictionary<LogLevel, ConsoleColor>()
_logColors = new Dictionary<LogLevel, ConsoleColor>()
{
{ LogLevel.Stub, ConsoleColor.DarkGray },
{ LogLevel.Info, ConsoleColor.White },
@ -26,17 +26,17 @@ namespace Ryujinx
{ 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
{
PrintLog(MessageQueue.Take());
PrintLog(_messageQueue.Take());
}
catch (InvalidOperationException)
{
@ -49,39 +49,39 @@ namespace Ryujinx
}
});
MessageThread.IsBackground = true;
MessageThread.Start();
_messageThread.IsBackground = true;
_messageThread.Start();
}
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();
}
}
else
{
Console.WriteLine(Message);
Console.WriteLine(message);
}
}
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
{
public class GLScreen : GameWindow
public class GlScreen : GameWindow
{
private const int TouchScreenWidth = 1280;
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,
new GraphicsMode(), "Ryujinx", 0,
DisplayDevice.Default, 3, 3,
GraphicsContextFlags.ForwardCompatible)
{
this.Device = Device;
this.Renderer = Renderer;
_device = device;
_renderer = renderer;
Location = new Point(
(DisplayDevice.Default.Width / 2) - (Width / 2),
@ -52,40 +52,40 @@ namespace Ryujinx
{
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)
{
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();
//Queue max. 1 vsync
Ticks = Math.Min(Ticks - TicksPerFrame, TicksPerFrame);
ticks = Math.Min(ticks - ticksPerFrame, ticksPerFrame);
}
}
}
@ -96,14 +96,14 @@ namespace Ryujinx
Visible = true;
Renderer.RenderTarget.SetWindowSize(Width, Height);
_renderer.RenderTarget.SetWindowSize(Width, Height);
Context.MakeCurrent(null);
//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)
{
@ -113,11 +113,11 @@ namespace Ryujinx
{
UpdateFrame();
if (TitleEvent)
if (_titleEvent)
{
TitleEvent = false;
_titleEvent = false;
Title = NewTitle;
Title = _newTitle;
}
}
@ -128,94 +128,94 @@ namespace Ryujinx
private new void UpdateFrame()
{
HidControllerButtons CurrentButton = 0;
HidJoystickPosition LeftJoystick;
HidJoystickPosition RightJoystick;
HidControllerButtons currentButton = 0;
HidJoystickPosition leftJoystick;
HidJoystickPosition rightJoystick;
int LeftJoystickDX = 0;
int LeftJoystickDY = 0;
int RightJoystickDX = 0;
int RightJoystickDY = 0;
int leftJoystickDx = 0;
int leftJoystickDy = 0;
int rightJoystickDx = 0;
int rightJoystickDy = 0;
//Keyboard Input
if (Keyboard.HasValue)
if (_keyboard.HasValue)
{
KeyboardState Keyboard = this.Keyboard.Value;
KeyboardState keyboard = _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
CurrentButton |= Config.JoyConController.GetButtons();
currentButton |= Config.JoyConController.GetButtons();
//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,
DY = LeftJoystickDY
DX = leftJoystickDx,
DY = leftJoystickDy
};
RightJoystick = new HidJoystickPosition
rightJoystick = new HidJoystickPosition
{
DX = RightJoystickDX,
DY = RightJoystickDY
DX = rightJoystickDx,
DY = rightJoystickDy
};
bool HasTouch = false;
bool hasTouch = false;
//Get screen touch position from left mouse click
//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 = _mouse.Value;
int ScrnWidth = Width;
int ScrnHeight = Height;
int scrnWidth = Width;
int scrnHeight = Height;
if (Width > (Height * TouchScreenWidth) / TouchScreenHeight)
{
ScrnWidth = (Height * TouchScreenWidth) / TouchScreenHeight;
scrnWidth = (Height * TouchScreenWidth) / TouchScreenHeight;
}
else
{
ScrnHeight = (Width * TouchScreenHeight) / TouchScreenWidth;
scrnHeight = (Width * TouchScreenHeight) / TouchScreenWidth;
}
int StartX = (Width - ScrnWidth) >> 1;
int StartY = (Height - ScrnHeight) >> 1;
int startX = (Width - scrnWidth) >> 1;
int startY = (Height - scrnHeight) >> 1;
int EndX = StartX + ScrnWidth;
int EndY = StartY + ScrnHeight;
int endX = startX + scrnWidth;
int endY = startY + scrnHeight;
if (Mouse.X >= StartX &&
Mouse.Y >= StartY &&
Mouse.X < EndX &&
Mouse.Y < EndY)
if (mouse.X >= startX &&
mouse.Y >= startY &&
mouse.X < endX &&
mouse.Y < endY)
{
int ScrnMouseX = Mouse.X - StartX;
int ScrnMouseY = Mouse.Y - StartY;
int scrnMouseX = mouse.X - startX;
int scrnMouseY = mouse.Y - startY;
int MX = (ScrnMouseX * TouchScreenWidth) / ScrnWidth;
int MY = (ScrnMouseY * TouchScreenHeight) / ScrnHeight;
int mX = (scrnMouseX * TouchScreenWidth) / scrnWidth;
int mY = (scrnMouseY * TouchScreenHeight) / scrnHeight;
HidTouchPoint CurrentPoint = new HidTouchPoint
HidTouchPoint currentPoint = new HidTouchPoint
{
X = MX,
Y = MY,
X = mX,
Y = mY,
//Placeholder values till more data is acquired
DiameterX = 10,
@ -223,76 +223,76 @@ namespace Ryujinx
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,
HidControllerLayouts.Handheld_Joined,
CurrentButton,
LeftJoystick,
RightJoystick);
currentButton,
leftJoystick,
rightJoystick);
Device.Hid.SetJoyconButton(
_device.Hid.SetJoyconButton(
HidControllerId.CONTROLLER_HANDHELD,
HidControllerLayouts.Main,
CurrentButton,
LeftJoystick,
RightJoystick);
currentButton,
leftJoystick,
rightJoystick);
}
private new void RenderFrame()
{
Renderer.RenderTarget.Render();
_renderer.RenderTarget.Render();
Device.Statistics.RecordSystemFrameTime();
_device.Statistics.RecordSystemFrameTime();
double HostFps = Device.Statistics.GetSystemFrameRate();
double GameFps = Device.Statistics.GetGameFrameRate();
double hostFps = _device.Statistics.GetSystemFrameRate();
double gameFps = _device.Statistics.GetGameFrameRate();
string TitleSection = string.IsNullOrWhiteSpace(Device.System.CurrentTitle) ? string.Empty
: " | " + Device.System.CurrentTitle;
string titleSection = string.IsNullOrWhiteSpace(_device.System.CurrentTitle) ? string.Empty
: " | " + _device.System.CurrentTitle;
NewTitle = $"Ryujinx{TitleSection} | Host FPS: {HostFps:0.0} | Game FPS: {GameFps:0.0} | " +
$"Game Vsync: {(Device.EnableDeviceVsync ? "On" : "Off")}";
_newTitle = $"Ryujinx{titleSection} | Host FPS: {hostFps:0.0} | Game FPS: {gameFps:0.0} | " +
$"Game Vsync: {(_device.EnableDeviceVsync ? "On" : "Off")}";
TitleEvent = true;
_titleEvent = true;
SwapBuffers();
Device.System.SignalVsync();
_device.System.SignalVsync();
Device.VsyncEvent.Set();
_device.VsyncEvent.Set();
}
protected override void OnUnload(EventArgs e)
{
RenderThread.Join();
_renderThread.Join();
base.OnUnload(e);
}
protected override void OnResize(EventArgs e)
{
ResizeEvent = true;
_resizeEvent = true;
}
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);
if (WindowState == WindowState.Fullscreen)
{
if (e.Key == Key.Escape || ToggleFullscreen)
if (e.Key == Key.Escape || toggleFullscreen)
{
WindowState = WindowState.Normal;
}
@ -304,33 +304,33 @@ namespace Ryujinx
Exit();
}
if (ToggleFullscreen)
if (toggleFullscreen)
{
WindowState = WindowState.Fullscreen;
}
}
Keyboard = e.Keyboard;
_keyboard = e.Keyboard;
}
protected override void OnKeyUp(KeyboardKeyEventArgs e)
{
Keyboard = e.Keyboard;
_keyboard = e.Keyboard;
}
protected override void OnMouseDown(MouseButtonEventArgs e)
{
Mouse = e.Mouse;
_mouse = e.Mouse;
}
protected override void OnMouseUp(MouseButtonEventArgs e)
{
Mouse = e.Mouse;
_mouse = e.Mouse;
}
protected override void OnMouseMove(MouseMoveEventArgs e)
{
Mouse = e.Mouse;
_mouse = e.Mouse;
}
}
}

View file

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

View file

@ -16,7 +16,7 @@ namespace Ryujinx.UI.Input
public int DPadRight;
public int ButtonMinus;
public int ButtonL;
public int ButtonZL;
public int ButtonZl;
}
public struct JoyConKeyboardRight
@ -32,7 +32,7 @@ namespace Ryujinx.UI.Input
public int ButtonY;
public int ButtonPlus;
public int ButtonR;
public int ButtonZR;
public int ButtonZr;
}
public class JoyConKeyboard
@ -41,62 +41,62 @@ namespace Ryujinx.UI.Input
public JoyConKeyboardRight Right;
public JoyConKeyboard(
JoyConKeyboardLeft Left,
JoyConKeyboardRight Right)
JoyConKeyboardLeft left,
JoyConKeyboardRight right)
{
this.Left = Left;
this.Right = Right;
Left = left;
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.DPadUp]) Buttons |= HidControllerButtons.KEY_DUP;
if (Keyboard[(Key)Left.DPadDown]) Buttons |= HidControllerButtons.KEY_DDOWN;
if (Keyboard[(Key)Left.DPadLeft]) Buttons |= HidControllerButtons.KEY_DLEFT;
if (Keyboard[(Key)Left.DPadRight]) Buttons |= HidControllerButtons.KEY_DRIGHT;
if (Keyboard[(Key)Left.ButtonMinus]) Buttons |= HidControllerButtons.KEY_MINUS;
if (Keyboard[(Key)Left.ButtonL]) Buttons |= HidControllerButtons.KEY_L;
if (Keyboard[(Key)Left.ButtonZL]) Buttons |= HidControllerButtons.KEY_ZL;
if (keyboard[(Key)Left.StickButton]) buttons |= HidControllerButtons.KEY_LSTICK;
if (keyboard[(Key)Left.DPadUp]) buttons |= HidControllerButtons.KEY_DUP;
if (keyboard[(Key)Left.DPadDown]) buttons |= HidControllerButtons.KEY_DDOWN;
if (keyboard[(Key)Left.DPadLeft]) buttons |= HidControllerButtons.KEY_DLEFT;
if (keyboard[(Key)Left.DPadRight]) buttons |= HidControllerButtons.KEY_DRIGHT;
if (keyboard[(Key)Left.ButtonMinus]) buttons |= HidControllerButtons.KEY_MINUS;
if (keyboard[(Key)Left.ButtonL]) buttons |= HidControllerButtons.KEY_L;
if (keyboard[(Key)Left.ButtonZl]) buttons |= HidControllerButtons.KEY_ZL;
if (Keyboard[(Key)Right.StickButton]) Buttons |= HidControllerButtons.KEY_RSTICK;
if (Keyboard[(Key)Right.ButtonA]) Buttons |= HidControllerButtons.KEY_A;
if (Keyboard[(Key)Right.ButtonB]) Buttons |= HidControllerButtons.KEY_B;
if (Keyboard[(Key)Right.ButtonX]) Buttons |= HidControllerButtons.KEY_X;
if (Keyboard[(Key)Right.ButtonY]) Buttons |= HidControllerButtons.KEY_Y;
if (Keyboard[(Key)Right.ButtonPlus]) Buttons |= HidControllerButtons.KEY_PLUS;
if (Keyboard[(Key)Right.ButtonR]) Buttons |= HidControllerButtons.KEY_R;
if (Keyboard[(Key)Right.ButtonZR]) Buttons |= HidControllerButtons.KEY_ZR;
if (keyboard[(Key)Right.StickButton]) buttons |= HidControllerButtons.KEY_RSTICK;
if (keyboard[(Key)Right.ButtonA]) buttons |= HidControllerButtons.KEY_A;
if (keyboard[(Key)Right.ButtonB]) buttons |= HidControllerButtons.KEY_B;
if (keyboard[(Key)Right.ButtonX]) buttons |= HidControllerButtons.KEY_X;
if (keyboard[(Key)Right.ButtonY]) buttons |= HidControllerButtons.KEY_Y;
if (keyboard[(Key)Right.ButtonPlus]) buttons |= HidControllerButtons.KEY_PLUS;
if (keyboard[(Key)Right.ButtonR]) buttons |= HidControllerButtons.KEY_R;
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 DY = 0;
short dx = 0;
short dy = 0;
if (Keyboard[(Key)Left.StickUp]) DY = short.MaxValue;
if (Keyboard[(Key)Left.StickDown]) DY = -short.MaxValue;
if (Keyboard[(Key)Left.StickLeft]) DX = -short.MaxValue;
if (Keyboard[(Key)Left.StickRight]) DX = short.MaxValue;
if (keyboard[(Key)Left.StickUp]) dy = short.MaxValue;
if (keyboard[(Key)Left.StickDown]) dy = -short.MaxValue;
if (keyboard[(Key)Left.StickLeft]) 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 DY = 0;
short dx = 0;
short dy = 0;
if (Keyboard[(Key)Right.StickUp]) DY = short.MaxValue;
if (Keyboard[(Key)Right.StickDown]) DY = -short.MaxValue;
if (Keyboard[(Key)Right.StickLeft]) DX = -short.MaxValue;
if (Keyboard[(Key)Right.StickRight]) DX = short.MaxValue;
if (keyboard[(Key)Right.StickUp]) dy = short.MaxValue;
if (keyboard[(Key)Right.StickDown]) dy = -short.MaxValue;
if (keyboard[(Key)Right.StickLeft]) 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";
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;
@ -29,24 +29,24 @@ namespace Ryujinx
{
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.");
Device.LoadCart(args[0], RomFsFiles[0]);
device.LoadCart(args[0], romFsFiles[0]);
}
else
{
Console.WriteLine("Loading as cart WITHOUT RomFS.");
Device.LoadCart(args[0]);
device.LoadCart(args[0]);
}
}
else if (File.Exists(args[0]))
@ -55,19 +55,19 @@ namespace Ryujinx
{
case ".xci":
Console.WriteLine("Loading as XCI.");
Device.LoadXci(args[0]);
device.LoadXci(args[0]);
break;
case ".nca":
Console.WriteLine("Loading as NCA.");
Device.LoadNca(args[0]);
device.LoadNca(args[0]);
break;
case ".nsp":
Console.WriteLine("Loading as NSP.");
Device.LoadNsp(args[0]);
device.LoadNsp(args[0]);
break;
default:
Console.WriteLine("Loading as homebrew.");
Device.LoadProgram(args[0]);
device.LoadProgram(args[0]);
break;
}
}
@ -77,14 +77,14 @@ namespace Ryujinx
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();
}
}
}