mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-09 12:19:12 +00:00
Changes in compliance with review
This commit is contained in:
parent
d0be618495
commit
ab5badcf3f
2 changed files with 40 additions and 97 deletions
|
@ -1,7 +1,7 @@
|
||||||
using OpenTK.Input;
|
using Ryujinx.UI.Input;
|
||||||
using Ryujinx.UI.Input;
|
|
||||||
using Ryujinx.HLE.Logging;
|
using Ryujinx.HLE.Logging;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -14,10 +14,10 @@ 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 float GamePadDeadzone;
|
public static float GamePadDeadzone { get; private set; }
|
||||||
public static bool GamePadEnable;
|
public static bool GamePadEnable { get; private set; }
|
||||||
public static int GamePadIndex;
|
public static int GamePadIndex { get; private set; }
|
||||||
public static float GamePadTriggerThreshold;
|
public static float GamePadTriggerThreshold { get; private set; }
|
||||||
|
|
||||||
public static void Read(Logger Log)
|
public static void Read(Logger Log)
|
||||||
{
|
{
|
||||||
|
@ -37,10 +37,8 @@ namespace Ryujinx
|
||||||
|
|
||||||
GamePadEnable = Convert.ToBoolean(Parser.Value("GamePad_Enable"));
|
GamePadEnable = Convert.ToBoolean(Parser.Value("GamePad_Enable"));
|
||||||
GamePadIndex = Convert.ToInt32 (Parser.Value("GamePad_Index"));
|
GamePadIndex = Convert.ToInt32 (Parser.Value("GamePad_Index"));
|
||||||
GamePadDeadzone = (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone"),
|
GamePadDeadzone = (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone"), CultureInfo.InvariantCulture);
|
||||||
System.Globalization.CultureInfo.InvariantCulture); // Remember to use Invariant Culture when dealing with parsing doubles.
|
GamePadTriggerThreshold = (float)Convert.ToDouble (Parser.Value("GamePad_Trigger_Threshold"), CultureInfo.InvariantCulture);
|
||||||
GamePadTriggerThreshold = (float)Convert.ToDouble (Parser.Value("GamePad_Trigger_Threshold"),
|
|
||||||
System.Globalization.CultureInfo.InvariantCulture);
|
|
||||||
|
|
||||||
string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries);
|
string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace Ryujinx
|
||||||
|
|
||||||
private bool IsGamePadButtonPressedFromString(GamePadState GamePad, string Button)
|
private bool IsGamePadButtonPressedFromString(GamePadState GamePad, string Button)
|
||||||
{
|
{
|
||||||
if (Button == "LTrigger" || Button == "RTrigger")
|
if (Button.ToUpper() == "LTRIGGER" || Button.ToUpper() == "RTRIGGER")
|
||||||
{
|
{
|
||||||
return GetGamePadTriggerFromString(GamePad, Button) >= Config.GamePadTriggerThreshold;
|
return GetGamePadTriggerFromString(GamePad, Button) >= Config.GamePadTriggerThreshold;
|
||||||
}
|
}
|
||||||
|
@ -57,112 +57,58 @@ namespace Ryujinx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ButtonState GetGamePadButtonFromString(GamePadState GamePad, string Button) //Please make this prettier if you can.
|
private ButtonState GetGamePadButtonFromString(GamePadState GamePad, string Button)
|
||||||
{
|
{
|
||||||
ButtonState Result = GamePad.Buttons.A;
|
switch (Button.ToUpper())
|
||||||
|
|
||||||
switch (Button)
|
|
||||||
{
|
{
|
||||||
case "A":
|
case "A": return GamePad.Buttons.A;
|
||||||
Result = GamePad.Buttons.A;
|
case "B": return GamePad.Buttons.B;
|
||||||
break;
|
case "X": return GamePad.Buttons.X;
|
||||||
case "B":
|
case "Y": return GamePad.Buttons.Y;
|
||||||
Result = GamePad.Buttons.B;
|
case "LSTICK": return GamePad.Buttons.LeftStick;
|
||||||
break;
|
case "RSTICK": return GamePad.Buttons.RightStick;
|
||||||
case "X":
|
case "LSHOULDER": return GamePad.Buttons.LeftShoulder;
|
||||||
Result = GamePad.Buttons.X;
|
case "RSHOULDER": return GamePad.Buttons.RightShoulder;
|
||||||
break;
|
case "DPADUP": return GamePad.DPad.Up;
|
||||||
case "Y":
|
case "DPADDOWN": return GamePad.DPad.Down;
|
||||||
Result = GamePad.Buttons.Y;
|
case "DPADLEFT": return GamePad.DPad.Left;
|
||||||
break;
|
case "DPADRIGHT": return GamePad.DPad.Right;
|
||||||
case "LStick":
|
case "START": return GamePad.Buttons.Start;
|
||||||
Result = GamePad.Buttons.LeftStick;
|
case "BACK": return GamePad.Buttons.Back;
|
||||||
break;
|
default: throw new ArgumentException();
|
||||||
case "RStick":
|
|
||||||
Result = GamePad.Buttons.RightStick;
|
|
||||||
break;
|
|
||||||
case "LShoulder":
|
|
||||||
Result = GamePad.Buttons.LeftShoulder;
|
|
||||||
break;
|
|
||||||
case "RShoulder":
|
|
||||||
Result = GamePad.Buttons.RightShoulder;
|
|
||||||
break;
|
|
||||||
case "DPadUp":
|
|
||||||
Result = GamePad.DPad.Up;
|
|
||||||
break;
|
|
||||||
case "DPadDown":
|
|
||||||
Result = GamePad.DPad.Down;
|
|
||||||
break;
|
|
||||||
case "DPadLeft":
|
|
||||||
Result = GamePad.DPad.Left;
|
|
||||||
break;
|
|
||||||
case "DPadRight":
|
|
||||||
Result = GamePad.DPad.Right;
|
|
||||||
break;
|
|
||||||
case "Start":
|
|
||||||
Result = GamePad.Buttons.Start;
|
|
||||||
break;
|
|
||||||
case "Back":
|
|
||||||
Result = GamePad.Buttons.Back;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Console.Error.WriteLine("Invalid Button Mapping \"" + Button + "\"! Defaulting to Button A.");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private float GetGamePadTriggerFromString(GamePadState GamePad, string Trigger)
|
private float GetGamePadTriggerFromString(GamePadState GamePad, string Trigger)
|
||||||
{
|
{
|
||||||
float Result = 0;
|
switch (Trigger.ToUpper())
|
||||||
|
|
||||||
switch (Trigger)
|
|
||||||
{
|
{
|
||||||
case "LTrigger":
|
case "LTRIGGER": return GamePad.Triggers.Left;
|
||||||
Result = GamePad.Triggers.Left;
|
case "RTRIGGER": return GamePad.Triggers.Right;
|
||||||
break;
|
default: throw new ArgumentException();
|
||||||
case "RTrigger":
|
|
||||||
Result = GamePad.Triggers.Right;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Console.Error.WriteLine("Invalid Trigger Mapping \"" + Trigger + "\"! Defaulting to 0.");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector2 GetJoystickAxisFromString(GamePadState GamePad, string Joystick)
|
private Vector2 GetJoystickAxisFromString(GamePadState GamePad, string Joystick)
|
||||||
{
|
{
|
||||||
Vector2 Result = new Vector2(0, 0);
|
switch (Joystick.ToUpper())
|
||||||
|
|
||||||
switch (Joystick)
|
|
||||||
{
|
{
|
||||||
case "LJoystick":
|
case "LJOYSTICK": return GamePad.ThumbSticks.Left;
|
||||||
Result = GamePad.ThumbSticks.Left;
|
case "RJOYSTICK": return new Vector2(-GamePad.ThumbSticks.Right.Y, -GamePad.ThumbSticks.Right.X);
|
||||||
break;
|
default: throw new ArgumentException();
|
||||||
case "RJoystick":
|
|
||||||
Result = new Vector2(-GamePad.ThumbSticks.Right.Y, -GamePad.ThumbSticks.Right.X);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Console.Error.WriteLine("Invalid Joystick Axis \"" + Joystick + "\"! Defaulting the Vector2 to 0, 0.");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||||
{
|
{
|
||||||
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;
|
||||||
float AnalogStickDeadzone = Config.GamePadDeadzone;
|
float AnalogStickDeadzone = Config.GamePadDeadzone;
|
||||||
|
|
||||||
//Keyboard Input
|
//Keyboard Input
|
||||||
|
@ -209,7 +155,6 @@ namespace Ryujinx
|
||||||
if (Config.GamePadEnable)
|
if (Config.GamePadEnable)
|
||||||
{
|
{
|
||||||
GamePadState GamePad = OpenTK.Input.GamePad.GetState(Config.GamePadIndex);
|
GamePadState GamePad = OpenTK.Input.GamePad.GetState(Config.GamePadIndex);
|
||||||
|
|
||||||
//LeftButtons
|
//LeftButtons
|
||||||
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.DPadUp)) CurrentButton |= HidControllerButtons.KEY_DUP;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.DPadUp)) CurrentButton |= HidControllerButtons.KEY_DUP;
|
||||||
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.DPadDown)) CurrentButton |= HidControllerButtons.KEY_DDOWN;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.DPadDown)) CurrentButton |= HidControllerButtons.KEY_DDOWN;
|
||||||
|
|
Loading…
Reference in a new issue