Revert "Add mapping per Axis"

This reverts commit b658334485.
This commit is contained in:
John Clemis 2018-08-08 20:57:41 -05:00
parent bdeebf59d8
commit 1803b91e49
4 changed files with 26 additions and 61 deletions

View file

@ -109,8 +109,7 @@ namespace Ryujinx
{ {
Left = new JoyConControllerLeft Left = new JoyConControllerLeft
{ {
Stick_AxisX = Parser.Value("Controls_Left_JoyConController_Stick_AxisX"), Stick = Parser.Value("Controls_Left_JoyConController_Stick"),
Stick_AxisY = Parser.Value("Controls_Left_JoyConController_Stick_AxisY"),
StickButton = Parser.Value("Controls_Left_JoyConController_Stick_Button"), StickButton = Parser.Value("Controls_Left_JoyConController_Stick_Button"),
DPadUp = Parser.Value("Controls_Left_JoyConController_DPad_Up"), DPadUp = Parser.Value("Controls_Left_JoyConController_DPad_Up"),
DPadDown = Parser.Value("Controls_Left_JoyConController_DPad_Down"), DPadDown = Parser.Value("Controls_Left_JoyConController_DPad_Down"),
@ -123,8 +122,7 @@ namespace Ryujinx
Right = new JoyConControllerRight Right = new JoyConControllerRight
{ {
Stick_AxisX = Parser.Value("Controls_Right_JoyConController_Stick_AxisX"), Stick = Parser.Value("Controls_Right_JoyConController_Stick"),
Stick_AxisY = Parser.Value("Controls_Right_JoyConController_Stick_AxisY"),
StickButton = Parser.Value("Controls_Right_JoyConController_Stick_Button"), StickButton = Parser.Value("Controls_Right_JoyConController_Stick_Button"),
ButtonA = Parser.Value("Controls_Right_JoyConController_Button_A"), ButtonA = Parser.Value("Controls_Right_JoyConController_Button_A"),
ButtonB = Parser.Value("Controls_Right_JoyConController_Button_B"), ButtonB = Parser.Value("Controls_Right_JoyConController_Button_B"),

View file

@ -61,7 +61,7 @@ Controls_Right_JoyConKeyboard_Button_Plus = 121
Controls_Right_JoyConKeyboard_Button_R = 103 Controls_Right_JoyConKeyboard_Button_R = 103
Controls_Right_JoyConKeyboard_Button_ZR = 97 Controls_Right_JoyConKeyboard_Button_ZR = 97
#Controller Controls (The default configuration is what works for a PS4 Controller using DS4 Windows) #Controller Controls
Controls_Left_JoyConController_Stick_Button = LStick Controls_Left_JoyConController_Stick_Button = LStick
Controls_Left_JoyConController_DPad_Up = DPadUp Controls_Left_JoyConController_DPad_Up = DPadUp
@ -81,7 +81,5 @@ Controls_Right_JoyConController_Button_Plus = Start
Controls_Right_JoyConController_Button_R = RShoulder Controls_Right_JoyConController_Button_R = RShoulder
Controls_Right_JoyConController_Button_ZR = RTrigger Controls_Right_JoyConController_Button_ZR = RTrigger
Controls_Left_JoyConController_Stick_AxisX = JoystickAxis0 Controls_Left_JoyConController_Stick = LJoystick
Controls_Left_JoyConController_Stick_AxisY = JoystickAxis1 Controls_Right_JoyConController_Stick = RJoystick
Controls_Right_JoyConController_Stick_AxisX = -JoystickAxis3
Controls_Right_JoyConController_Stick_AxisY = -JoystickAxis2

View file

@ -174,41 +174,13 @@ namespace Ryujinx
} }
} }
private float GetJoystickAxisFromString(GamePadState GamePad, string Joystick) private Vector2 GetJoystickAxisFromString(GamePadState GamePad, string Joystick)
{ {
switch (Joystick.ToUpper()) switch (Joystick.ToUpper())
{ {
case "JOYSTICKAXIS0": return GamePad.ThumbSticks.Left.X; case "LJOYSTICK": return GamePad.ThumbSticks.Left;
case "JOYSTICKAXIS1": return GamePad.ThumbSticks.Left.Y; case "RJOYSTICK": return new Vector2(-GamePad.ThumbSticks.Right.Y, -GamePad.ThumbSticks.Right.X);
case "JOYSTICKAXIS2": return GamePad.ThumbSticks.Right.X; default: throw new ArgumentException();
case "JOYSTICKAXIS3": return GamePad.ThumbSticks.Right.Y;
case "-JOYSTICKAXIS0": return -GamePad.ThumbSticks.Left.X;
case "-JOYSTICKAXIS1": return -GamePad.ThumbSticks.Left.Y;
case "-JOYSTICKAXIS2": return -GamePad.ThumbSticks.Right.X;
case "-JOYSTICKAXIS3": return -GamePad.ThumbSticks.Right.Y;
default: throw new ArgumentException();
}
}
private bool IsGamePadActive(int Index)
{
return IsGamePadActive(GamePad.GetState(Index));
}
private bool IsGamePadActive(GamePadState GamePad)
{
if (GamePad.IsConnected)
{
return GamePad.Buttons.IsAnyButtonPressed
|| (GamePad.Triggers.Left >= 0.8f || GamePad.Triggers.Right >= 0.8f)
|| ((GamePad.ThumbSticks.Left.X >= 0.1f || GamePad.ThumbSticks.Left.X <= -0.1f)
|| (GamePad.ThumbSticks.Left.Y >= 0.1f || GamePad.ThumbSticks.Left.Y <= -0.1f)
|| (GamePad.ThumbSticks.Right.X >= 0.1f || GamePad.ThumbSticks.Right.X <= -0.1f)
|| (GamePad.ThumbSticks.Right.Y >= 0.1f || GamePad.ThumbSticks.Right.Y <= -0.1f));
}
else
{
return false;
} }
} }
@ -222,9 +194,10 @@ namespace Ryujinx
int LeftJoystickDY = 0; int LeftJoystickDY = 0;
int RightJoystickDX = 0; int RightJoystickDX = 0;
int RightJoystickDY = 0; int RightJoystickDY = 0;
float AnalogStickDeadzone = Config.GamePadDeadzone;
//Keyboard Input //Keyboard Input
if (Keyboard.HasValue && !IsGamePadActive(Config.GamePadIndex)) if (Keyboard.HasValue)
{ {
KeyboardState Keyboard = this.Keyboard.Value; KeyboardState Keyboard = this.Keyboard.Value;
@ -264,11 +237,9 @@ namespace Ryujinx
} }
//Controller Input //Controller Input
if (Config.GamePadEnable && !Keyboard.HasValue && IsGamePadActive(Config.GamePadIndex)) if (Config.GamePadEnable)
{ {
GamePadState GamePad = OpenTK.Input.GamePad.GetState(Config.GamePadIndex); GamePadState GamePad = OpenTK.Input.GamePad.GetState(Config.GamePadIndex);
float AnalogStickDeadzone = Config.GamePadDeadzone;
//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;
@ -290,22 +261,22 @@ namespace Ryujinx
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_AxisX) >= AnalogStickDeadzone if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).X >= AnalogStickDeadzone
|| GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick_AxisX) <= -AnalogStickDeadzone) || GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).X <= -AnalogStickDeadzone)
LeftJoystickDX = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick_AxisX) * short.MaxValue); LeftJoystickDX = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).X * short.MaxValue);
if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick_AxisY) >= AnalogStickDeadzone if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).Y >= AnalogStickDeadzone
|| GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick_AxisY) <= -AnalogStickDeadzone) || GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).Y <= -AnalogStickDeadzone)
LeftJoystickDY = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick_AxisY) * short.MaxValue); LeftJoystickDY = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).Y * short.MaxValue);
//RightJoystick //RightJoystick
if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisX) >= AnalogStickDeadzone if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).X >= AnalogStickDeadzone
|| GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisX) <= -AnalogStickDeadzone) || GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).X <= -AnalogStickDeadzone)
RightJoystickDX = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisX) * short.MaxValue); RightJoystickDX = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).X * short.MaxValue);
if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisY) >= AnalogStickDeadzone if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).Y >= AnalogStickDeadzone
|| GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisY) <= -AnalogStickDeadzone) || GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).Y <= -AnalogStickDeadzone)
RightJoystickDY = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisY) * short.MaxValue); RightJoystickDY = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).Y * short.MaxValue);
} }
LeftJoystick = new HidJoystickPosition LeftJoystick = new HidJoystickPosition

View file

@ -6,8 +6,7 @@ namespace Ryujinx.UI.Input
{ {
public struct JoyConControllerLeft public struct JoyConControllerLeft
{ {
public string Stick_AxisX; public string Stick;
public string Stick_AxisY;
public string StickButton; public string StickButton;
public string DPadUp; public string DPadUp;
public string DPadDown; public string DPadDown;
@ -20,8 +19,7 @@ namespace Ryujinx.UI.Input
public struct JoyConControllerRight public struct JoyConControllerRight
{ {
public string Stick_AxisX; public string Stick;
public string Stick_AxisY;
public string StickButton; public string StickButton;
public string ButtonA; public string ButtonA;
public string ButtonB; public string ButtonB;