mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-08 20:02:39 +00:00
Changes in compliance with review
This commit is contained in:
parent
60ad45cc29
commit
42c3bde419
5 changed files with 78 additions and 86 deletions
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Ryujinx.Input
|
namespace Ryujinx.HLE.Input
|
||||||
{
|
{
|
||||||
public struct JoyConControllerLeft
|
public struct JoyConControllerLeft
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Input
|
namespace Ryujinx.HLE.Input
|
||||||
{
|
{
|
||||||
public struct JoyConKeyboardLeft
|
public struct JoyConKeyboardLeft
|
||||||
{
|
{
|
|
@ -1,5 +1,5 @@
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using Ryujinx.Input;
|
using Ryujinx.HLE.Input;
|
||||||
using Ryujinx.HLE.Logging;
|
using Ryujinx.HLE.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -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 GamePad_Deadzone;
|
public static float GamePadDeadzone;
|
||||||
public static bool GamePad_Enable;
|
public static bool GamePadEnable;
|
||||||
public static int GamePad_Index;
|
public static int GamePadIndex;
|
||||||
public static float GamePad_Trigger_Threshold;
|
public static float GamePadTriggerThreshold;
|
||||||
|
|
||||||
public static void Read(Logger Log)
|
public static void Read(Logger Log)
|
||||||
{
|
{
|
||||||
|
@ -35,10 +35,10 @@ namespace Ryujinx
|
||||||
Log.SetEnable(LogLevel.Warning, Convert.ToBoolean(Parser.Value("Logging_Enable_Warn")));
|
Log.SetEnable(LogLevel.Warning, Convert.ToBoolean(Parser.Value("Logging_Enable_Warn")));
|
||||||
Log.SetEnable(LogLevel.Error, Convert.ToBoolean(Parser.Value("Logging_Enable_Error")));
|
Log.SetEnable(LogLevel.Error, Convert.ToBoolean(Parser.Value("Logging_Enable_Error")));
|
||||||
|
|
||||||
GamePad_Enable = Convert.ToBoolean(Parser.Value("GamePad_Enable"));
|
GamePadEnable = Convert.ToBoolean(Parser.Value("GamePad_Enable"));
|
||||||
GamePad_Index = Convert.ToInt32 (Parser.Value("GamePad_Index"));
|
GamePadIndex = Convert.ToInt32 (Parser.Value("GamePad_Index"));
|
||||||
GamePad_Deadzone = (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone"));
|
GamePadDeadzone = (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone"));
|
||||||
GamePad_Trigger_Threshold = (float)Convert.ToDouble (Parser.Value("GamePad_Trigger_Threshold"));
|
GamePadTriggerThreshold = (float)Convert.ToDouble (Parser.Value("GamePad_Trigger_Threshold"));
|
||||||
|
|
||||||
string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries);
|
string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Ryujinx.Input
|
|
||||||
{
|
|
||||||
//TODO: Add real Bluetooth Joy Con Support in the far future.
|
|
||||||
}
|
|
|
@ -45,112 +45,112 @@ namespace Ryujinx
|
||||||
Renderer.FrameBuffer.SetWindowSize(Width, Height);
|
Renderer.FrameBuffer.SetWindowSize(Width, Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsGamePadButtonPressedFromString(GamePadState gamePad, string str)
|
private bool IsGamePadButtonPressedFromString(GamePadState GamePad, string Button)
|
||||||
{
|
{
|
||||||
if (str == "LTrigger" || str == "RTrigger")
|
if (Button == "LTrigger" || Button == "RTrigger")
|
||||||
{
|
{
|
||||||
return GetGamePadTriggerFromString(gamePad, str) >= Config.GamePad_Trigger_Threshold;
|
return GetGamePadTriggerFromString(GamePad, Button) >= Config.GamePadTriggerThreshold;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return (GetGamePadButtonFromString(gamePad, str) == ButtonState.Pressed);
|
return (GetGamePadButtonFromString(GamePad, Button) == ButtonState.Pressed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ButtonState GetGamePadButtonFromString(GamePadState gamePad, string str) //Please make this prettier if you can.
|
private ButtonState GetGamePadButtonFromString(GamePadState GamePad, string Button) //Please make this prettier if you can.
|
||||||
{
|
{
|
||||||
ButtonState result = gamePad.Buttons.A;
|
ButtonState result = GamePad.Buttons.A;
|
||||||
|
|
||||||
switch (str)
|
switch (Button)
|
||||||
{
|
{
|
||||||
case "A":
|
case "A":
|
||||||
result = gamePad.Buttons.A;
|
result = GamePad.Buttons.A;
|
||||||
break;
|
break;
|
||||||
case "B":
|
case "B":
|
||||||
result = gamePad.Buttons.B;
|
result = GamePad.Buttons.B;
|
||||||
break;
|
break;
|
||||||
case "X":
|
case "X":
|
||||||
result = gamePad.Buttons.X;
|
result = GamePad.Buttons.X;
|
||||||
break;
|
break;
|
||||||
case "Y":
|
case "Y":
|
||||||
result = gamePad.Buttons.Y;
|
result = GamePad.Buttons.Y;
|
||||||
break;
|
break;
|
||||||
case "LStick":
|
case "LStick":
|
||||||
result = gamePad.Buttons.LeftStick;
|
result = GamePad.Buttons.LeftStick;
|
||||||
break;
|
break;
|
||||||
case "RStick":
|
case "RStick":
|
||||||
result = gamePad.Buttons.RightStick;
|
result = GamePad.Buttons.RightStick;
|
||||||
break;
|
break;
|
||||||
case "LShoulder":
|
case "LShoulder":
|
||||||
result = gamePad.Buttons.LeftShoulder;
|
result = GamePad.Buttons.LeftShoulder;
|
||||||
break;
|
break;
|
||||||
case "RShoulder":
|
case "RShoulder":
|
||||||
result = gamePad.Buttons.RightShoulder;
|
result = GamePad.Buttons.RightShoulder;
|
||||||
break;
|
break;
|
||||||
case "DPadUp":
|
case "DPadUp":
|
||||||
result = gamePad.DPad.Up;
|
result = GamePad.DPad.Up;
|
||||||
break;
|
break;
|
||||||
case "DPadDown":
|
case "DPadDown":
|
||||||
result = gamePad.DPad.Down;
|
result = GamePad.DPad.Down;
|
||||||
break;
|
break;
|
||||||
case "DPadLeft":
|
case "DPadLeft":
|
||||||
result = gamePad.DPad.Left;
|
result = GamePad.DPad.Left;
|
||||||
break;
|
break;
|
||||||
case "DPadRight":
|
case "DPadRight":
|
||||||
result = gamePad.DPad.Right;
|
result = GamePad.DPad.Right;
|
||||||
break;
|
break;
|
||||||
case "Start":
|
case "Start":
|
||||||
result = gamePad.Buttons.Start;
|
result = GamePad.Buttons.Start;
|
||||||
break;
|
break;
|
||||||
case "Back":
|
case "Back":
|
||||||
result = gamePad.Buttons.Back;
|
result = GamePad.Buttons.Back;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.Error.WriteLine("Invalid Button Mapping \"" + str + "\"! Defaulting to Button A.");
|
Console.Error.WriteLine("Invalid Button Mapping \"" + Button + "\"! Defaulting to Button A.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float GetGamePadTriggerFromString(GamePadState gamePad, string str)
|
private float GetGamePadTriggerFromString(GamePadState GamePad, string Trigger)
|
||||||
{
|
{
|
||||||
float result = 0;
|
float Result = 0;
|
||||||
|
|
||||||
switch (str)
|
switch (Trigger)
|
||||||
{
|
{
|
||||||
case "LTrigger":
|
case "LTrigger":
|
||||||
result = gamePad.Triggers.Left;
|
Result = GamePad.Triggers.Left;
|
||||||
break;
|
break;
|
||||||
case "RTrigger":
|
case "RTrigger":
|
||||||
result = gamePad.Triggers.Right;
|
Result = GamePad.Triggers.Right;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.Error.WriteLine("Invalid Trigger Mapping \"" + str + "\"! Defaulting to 0.");
|
Console.Error.WriteLine("Invalid Trigger Mapping \"" + Trigger + "\"! Defaulting to 0.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector2 GetJoystickAxisFromString(GamePadState gamePad, string str)
|
private Vector2 GetJoystickAxisFromString(GamePadState GamePad, string Joystick)
|
||||||
{
|
{
|
||||||
Vector2 result = new Vector2(0, 0);
|
Vector2 Result = new Vector2(0, 0);
|
||||||
|
|
||||||
switch (str)
|
switch (Joystick)
|
||||||
{
|
{
|
||||||
case "LJoystick":
|
case "LJoystick":
|
||||||
result = gamePad.ThumbSticks.Left;
|
Result = GamePad.ThumbSticks.Left;
|
||||||
break;
|
break;
|
||||||
case "RJoystick":
|
case "RJoystick":
|
||||||
result = new Vector2(-gamePad.ThumbSticks.Right.Y, -gamePad.ThumbSticks.Right.X);
|
Result = new Vector2(-GamePad.ThumbSticks.Right.Y, -GamePad.ThumbSticks.Right.X);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.Error.WriteLine("Invalid Joystick Axis \"" + str + "\"! Defaulting the Vector2 to 0, 0.");
|
Console.Error.WriteLine("Invalid Joystick Axis \"" + Joystick + "\"! Defaulting the Vector2 to 0, 0.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||||
|
@ -163,7 +163,7 @@ namespace Ryujinx
|
||||||
int LeftJoystickDY = 0;
|
int LeftJoystickDY = 0;
|
||||||
int RightJoystickDX = 0;
|
int RightJoystickDX = 0;
|
||||||
int RightJoystickDY = 0;
|
int RightJoystickDY = 0;
|
||||||
float deadzone = Config.GamePad_Deadzone;
|
float AnalogStickDeadzone = Config.GamePadDeadzone;
|
||||||
|
|
||||||
//Keyboard Input
|
//Keyboard Input
|
||||||
if (Keyboard.HasValue)
|
if (Keyboard.HasValue)
|
||||||
|
@ -206,47 +206,47 @@ namespace Ryujinx
|
||||||
}
|
}
|
||||||
|
|
||||||
//Controller Input
|
//Controller Input
|
||||||
if (Config.GamePad_Enable)
|
if (Config.GamePadEnable)
|
||||||
{
|
{
|
||||||
GamePadState gamePad = GamePad.GetState(Config.GamePad_Index);
|
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;
|
||||||
if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Left.DPadLeft)) CurrentButton |= HidControllerButtons.KEY_DLEFT;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.DPadLeft)) CurrentButton |= HidControllerButtons.KEY_DLEFT;
|
||||||
if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Left.DPadRight)) CurrentButton |= HidControllerButtons.KEY_DRIGHT;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.DPadRight)) CurrentButton |= HidControllerButtons.KEY_DRIGHT;
|
||||||
if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Left.StickButton)) CurrentButton |= HidControllerButtons.KEY_LSTICK;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.StickButton)) CurrentButton |= HidControllerButtons.KEY_LSTICK;
|
||||||
if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Left.ButtonMinus)) CurrentButton |= HidControllerButtons.KEY_MINUS;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.ButtonMinus)) CurrentButton |= HidControllerButtons.KEY_MINUS;
|
||||||
if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Left.ButtonL)) CurrentButton |= HidControllerButtons.KEY_L;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.ButtonL)) CurrentButton |= HidControllerButtons.KEY_L;
|
||||||
if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Left.ButtonZL)) CurrentButton |= HidControllerButtons.KEY_ZL;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.ButtonZL)) CurrentButton |= HidControllerButtons.KEY_ZL;
|
||||||
|
|
||||||
//RightButtons
|
//RightButtons
|
||||||
if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.ButtonA)) CurrentButton |= HidControllerButtons.KEY_A;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Right.ButtonA)) CurrentButton |= HidControllerButtons.KEY_A;
|
||||||
if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.ButtonB)) CurrentButton |= HidControllerButtons.KEY_B;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Right.ButtonB)) CurrentButton |= HidControllerButtons.KEY_B;
|
||||||
if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.ButtonX)) CurrentButton |= HidControllerButtons.KEY_X;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Right.ButtonX)) CurrentButton |= HidControllerButtons.KEY_X;
|
||||||
if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.ButtonY)) CurrentButton |= HidControllerButtons.KEY_Y;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Right.ButtonY)) CurrentButton |= HidControllerButtons.KEY_Y;
|
||||||
if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.StickButton)) CurrentButton |= HidControllerButtons.KEY_RSTICK;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Right.StickButton)) CurrentButton |= HidControllerButtons.KEY_RSTICK;
|
||||||
if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.ButtonPlus)) CurrentButton |= HidControllerButtons.KEY_PLUS;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Right.ButtonPlus)) CurrentButton |= HidControllerButtons.KEY_PLUS;
|
||||||
if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.ButtonR)) CurrentButton |= HidControllerButtons.KEY_R;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Right.ButtonR)) CurrentButton |= HidControllerButtons.KEY_R;
|
||||||
if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.ButtonZR)) CurrentButton |= HidControllerButtons.KEY_ZR;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Right.ButtonZR)) CurrentButton |= HidControllerButtons.KEY_ZR;
|
||||||
|
|
||||||
//LeftJoystick
|
//LeftJoystick
|
||||||
if (GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).X >= deadzone
|
if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).X >= AnalogStickDeadzone
|
||||||
|| GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).X <= -deadzone)
|
|| GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).X <= -AnalogStickDeadzone)
|
||||||
LeftJoystickDX = (int)(GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).X * short.MaxValue);
|
LeftJoystickDX = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).X * short.MaxValue);
|
||||||
|
|
||||||
if (GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).Y >= deadzone
|
if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).Y >= AnalogStickDeadzone
|
||||||
|| GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).Y <= -deadzone)
|
|| GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).Y <= -AnalogStickDeadzone)
|
||||||
LeftJoystickDY = (int)(GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).Y * short.MaxValue);
|
LeftJoystickDY = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).Y * short.MaxValue);
|
||||||
|
|
||||||
//RightJoystick
|
//RightJoystick
|
||||||
if (GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).X >= deadzone
|
if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).X >= AnalogStickDeadzone
|
||||||
|| GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).X <= -deadzone)
|
|| GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).X <= -AnalogStickDeadzone)
|
||||||
RightJoystickDX = (int)(GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).X * short.MaxValue);
|
RightJoystickDX = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).X * short.MaxValue);
|
||||||
|
|
||||||
if (GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).Y >= deadzone
|
if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).Y >= AnalogStickDeadzone
|
||||||
|| GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).Y <= -deadzone)
|
|| GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).Y <= -AnalogStickDeadzone)
|
||||||
RightJoystickDY = (int)(GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).Y * short.MaxValue);
|
RightJoystickDY = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).Y * short.MaxValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
LeftJoystick = new HidJoystickPosition
|
LeftJoystick = new HidJoystickPosition
|
||||||
|
|
Loading…
Reference in a new issue