diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index f8f2243f4..0f346122a 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -109,8 +109,7 @@ namespace Ryujinx { Left = new JoyConControllerLeft { - Stick_AxisX = Parser.Value("Controls_Left_JoyConController_Stick_AxisX"), - Stick_AxisY = Parser.Value("Controls_Left_JoyConController_Stick_AxisY"), + Stick = Parser.Value("Controls_Left_JoyConController_Stick"), StickButton = Parser.Value("Controls_Left_JoyConController_Stick_Button"), DPadUp = Parser.Value("Controls_Left_JoyConController_DPad_Up"), DPadDown = Parser.Value("Controls_Left_JoyConController_DPad_Down"), @@ -123,8 +122,7 @@ namespace Ryujinx Right = new JoyConControllerRight { - Stick_AxisX = Parser.Value("Controls_Right_JoyConController_Stick_AxisX"), - Stick_AxisY = Parser.Value("Controls_Right_JoyConController_Stick_AxisY"), + Stick = Parser.Value("Controls_Right_JoyConController_Stick"), StickButton = Parser.Value("Controls_Right_JoyConController_Stick_Button"), ButtonA = Parser.Value("Controls_Right_JoyConController_Button_A"), ButtonB = Parser.Value("Controls_Right_JoyConController_Button_B"), diff --git a/Ryujinx/Ryujinx.conf b/Ryujinx/Ryujinx.conf index 4d5fc0b88..063bb2de4 100644 --- a/Ryujinx/Ryujinx.conf +++ b/Ryujinx/Ryujinx.conf @@ -61,7 +61,7 @@ Controls_Right_JoyConKeyboard_Button_Plus = 121 Controls_Right_JoyConKeyboard_Button_R = 103 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_DPad_Up = DPadUp @@ -81,7 +81,5 @@ Controls_Right_JoyConController_Button_Plus = Start Controls_Right_JoyConController_Button_R = RShoulder Controls_Right_JoyConController_Button_ZR = RTrigger -Controls_Left_JoyConController_Stick_AxisX = JoystickAxis0 -Controls_Left_JoyConController_Stick_AxisY = JoystickAxis1 -Controls_Right_JoyConController_Stick_AxisX = -JoystickAxis3 -Controls_Right_JoyConController_Stick_AxisY = -JoystickAxis2 +Controls_Left_JoyConController_Stick = LJoystick +Controls_Right_JoyConController_Stick = RJoystick \ No newline at end of file diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index 856ff6735..9b5dda4f0 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -174,41 +174,13 @@ namespace Ryujinx } } - private float GetJoystickAxisFromString(GamePadState GamePad, string Joystick) + private Vector2 GetJoystickAxisFromString(GamePadState GamePad, string Joystick) { switch (Joystick.ToUpper()) { - 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; - 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; + case "LJOYSTICK": return GamePad.ThumbSticks.Left; + case "RJOYSTICK": return new Vector2(-GamePad.ThumbSticks.Right.Y, -GamePad.ThumbSticks.Right.X); + default: throw new ArgumentException(); } } @@ -222,9 +194,10 @@ namespace Ryujinx int LeftJoystickDY = 0; int RightJoystickDX = 0; int RightJoystickDY = 0; + float AnalogStickDeadzone = Config.GamePadDeadzone; //Keyboard Input - if (Keyboard.HasValue && !IsGamePadActive(Config.GamePadIndex)) + if (Keyboard.HasValue) { KeyboardState Keyboard = this.Keyboard.Value; @@ -264,11 +237,9 @@ namespace Ryujinx } //Controller Input - if (Config.GamePadEnable && !Keyboard.HasValue && IsGamePadActive(Config.GamePadIndex)) + if (Config.GamePadEnable) { GamePadState GamePad = OpenTK.Input.GamePad.GetState(Config.GamePadIndex); - float AnalogStickDeadzone = Config.GamePadDeadzone; - //LeftButtons if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.DPadUp)) CurrentButton |= HidControllerButtons.KEY_DUP; 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; //LeftJoystick - if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick_AxisX) >= AnalogStickDeadzone - || GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick_AxisX) <= -AnalogStickDeadzone) - LeftJoystickDX = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick_AxisX) * short.MaxValue); + if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).X >= AnalogStickDeadzone + || GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).X <= -AnalogStickDeadzone) + LeftJoystickDX = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).X * short.MaxValue); - if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick_AxisY) >= AnalogStickDeadzone - || GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick_AxisY) <= -AnalogStickDeadzone) - LeftJoystickDY = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick_AxisY) * short.MaxValue); + if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).Y >= AnalogStickDeadzone + || GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).Y <= -AnalogStickDeadzone) + LeftJoystickDY = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).Y * short.MaxValue); //RightJoystick - if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisX) >= AnalogStickDeadzone - || GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisX) <= -AnalogStickDeadzone) - RightJoystickDX = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisX) * short.MaxValue); + if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).X >= AnalogStickDeadzone + || GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).X <= -AnalogStickDeadzone) + RightJoystickDX = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).X * short.MaxValue); - if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisY) >= AnalogStickDeadzone - || GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisY) <= -AnalogStickDeadzone) - RightJoystickDY = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisY) * short.MaxValue); + if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).Y >= AnalogStickDeadzone + || GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).Y <= -AnalogStickDeadzone) + RightJoystickDY = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).Y * short.MaxValue); } LeftJoystick = new HidJoystickPosition diff --git a/Ryujinx/Ui/JoyConController.cs b/Ryujinx/Ui/JoyConController.cs index b212dd0e5..e525017d3 100644 --- a/Ryujinx/Ui/JoyConController.cs +++ b/Ryujinx/Ui/JoyConController.cs @@ -6,8 +6,7 @@ namespace Ryujinx.UI.Input { public struct JoyConControllerLeft { - public string Stick_AxisX; - public string Stick_AxisY; + public string Stick; public string StickButton; public string DPadUp; public string DPadDown; @@ -20,8 +19,7 @@ namespace Ryujinx.UI.Input public struct JoyConControllerRight { - public string Stick_AxisX; - public string Stick_AxisY; + public string Stick; public string StickButton; public string ButtonA; public string ButtonB;