From 6cc56bfe7ed473fedf8dfe79c7a888bbe7cfe147 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Wed, 27 Jun 2018 14:25:44 -0500 Subject: [PATCH] Added Extra Configuration Options Added a GamePad_Enable option and GamePad_Index option --- Ryujinx/Config.cs | 9 ++++-- Ryujinx/Ryujinx.conf | 6 ++++ Ryujinx/Ui/GLScreen.cs | 64 ++++++++++++++++++++++-------------------- 3 files changed, 46 insertions(+), 33 deletions(-) diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index 705c98d11..e842fffbc 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -1,4 +1,5 @@ -using Ryujinx.HLE.Input; +using OpenTK.Input; +using Ryujinx.HLE.Input; using Ryujinx.HLE.Logging; using System; using System.Collections.Generic; @@ -13,6 +14,8 @@ namespace Ryujinx public static JoyCon FakeJoyCon { get; private set; } public static float GamePad_Deadzone; + public static bool GamePad_Enable; + public static int GamePad_Index; public static void Read(Logger Log) { @@ -30,7 +33,9 @@ namespace Ryujinx Log.SetEnable(LogLevel.Warning, Convert.ToBoolean(Parser.Value("Logging_Enable_Warn"))); Log.SetEnable(LogLevel.Error, Convert.ToBoolean(Parser.Value("Logging_Enable_Error"))); - GamePad_Deadzone = (float)Convert.ToDouble(Parser.Value("GamePad_Deadzone")); + GamePad_Enable = Convert.ToBoolean(Parser.Value("GamePad_Enable")); + GamePad_Index = Convert.ToInt32 (Parser.Value("GamePad_Index")); + GamePad_Deadzone = (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone")); string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries); diff --git a/Ryujinx/Ryujinx.conf b/Ryujinx/Ryujinx.conf index 0f0492487..146bf5efe 100644 --- a/Ryujinx/Ryujinx.conf +++ b/Ryujinx/Ryujinx.conf @@ -19,9 +19,15 @@ Logging_Enable_Error = true #Filtered log classes, seperated by ", ", eg. `Logging_Filtered_Classes = Loader, ServiceFS` Logging_Filtered_Classes = +#Controller Device Index +GamePad_Index = 0 + #Controller Analog Stick Deadzone GamePad_Deadzone = 0.05 +#Whether or not to enable Controller support +GamePad_Enable = true + #https://github.com/opentk/opentk/blob/develop/src/OpenTK/Input/Key.cs Controls_Left_FakeJoycon_Stick_Up = 105 Controls_Left_FakeJoycon_Stick_Down = 101 diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index 0614d99cd..1c68cfc1f 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -95,44 +95,46 @@ namespace Ryujinx if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonR]) CurrentButton |= HidControllerButtons.KEY_R; if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonZR]) CurrentButton |= HidControllerButtons.KEY_ZR; } + if (Config.GamePad_Enable) + { + //Mapping it relative to the positions of the buttons on the controller - //Mapping it relative to the positions of the buttons on the controller + GamePadState gamePad = GamePad.GetState(0); - GamePadState gamePad = GamePad.GetState(0); + //RightButtons + if (gamePad.Buttons.B == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_A; + if (gamePad.Buttons.A == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_B; + if (gamePad.Buttons.Y == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_X; + if (gamePad.Buttons.X == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_Y; + if (gamePad.Buttons.RightStick == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_RSTICK; + if (gamePad.Buttons.Start == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_PLUS; + if (gamePad.Buttons.RightShoulder == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_R; + if (gamePad.Triggers.Right >= 0.5) CurrentButton |= HidControllerButtons.KEY_ZR; - //RightButtons - if (gamePad.Buttons.B == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_A; - if (gamePad.Buttons.A == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_B; - if (gamePad.Buttons.Y == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_X; - if (gamePad.Buttons.X == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_Y; - if (gamePad.Buttons.RightStick == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_RSTICK; - if (gamePad.Buttons.Start == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_PLUS; - if (gamePad.Buttons.RightShoulder == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_R; - if (gamePad.Triggers.Right >= 0.5) CurrentButton |= HidControllerButtons.KEY_ZR; + //LeftButtons + if (gamePad.Buttons.LeftStick == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_LSTICK; + if (gamePad.DPad.IsUp) CurrentButton |= HidControllerButtons.KEY_DUP; + if (gamePad.DPad.IsDown) CurrentButton |= HidControllerButtons.KEY_DDOWN; + if (gamePad.DPad.IsLeft) CurrentButton |= HidControllerButtons.KEY_DLEFT; + if (gamePad.DPad.IsRight) CurrentButton |= HidControllerButtons.KEY_DRIGHT; + if (gamePad.Buttons.Back == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_MINUS; + if (gamePad.Buttons.LeftShoulder == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_L; + if (gamePad.Triggers.Left >= 0.5) CurrentButton |= HidControllerButtons.KEY_ZL; - //LeftButtons - if (gamePad.Buttons.LeftStick == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_LSTICK; - if (gamePad.DPad.IsUp) CurrentButton |= HidControllerButtons.KEY_DUP; - if (gamePad.DPad.IsDown) CurrentButton |= HidControllerButtons.KEY_DDOWN; - if (gamePad.DPad.IsLeft) CurrentButton |= HidControllerButtons.KEY_DLEFT; - if (gamePad.DPad.IsRight) CurrentButton |= HidControllerButtons.KEY_DRIGHT; - if (gamePad.Buttons.Back == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_MINUS; - if (gamePad.Buttons.LeftShoulder == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_L; - if (gamePad.Triggers.Left >= 0.5) CurrentButton |= HidControllerButtons.KEY_ZL; + //RightJoystick + if (gamePad.ThumbSticks.Right.X >= deadzone || gamePad.ThumbSticks.Right.X <= -deadzone) + RightJoystickDY = (int)(-gamePad.ThumbSticks.Right.X * short.MaxValue); - //RightJoystick - if (gamePad.ThumbSticks.Right.X >= deadzone || gamePad.ThumbSticks.Right.X <= -deadzone) - RightJoystickDY = (int)(-gamePad.ThumbSticks.Right.X * short.MaxValue); + if (gamePad.ThumbSticks.Right.Y >= deadzone || gamePad.ThumbSticks.Right.Y <= -deadzone) + RightJoystickDX = (int)(-gamePad.ThumbSticks.Right.Y * short.MaxValue); - if (gamePad.ThumbSticks.Right.Y >= deadzone || gamePad.ThumbSticks.Right.Y <= -deadzone) - RightJoystickDX = (int)(-gamePad.ThumbSticks.Right.Y * short.MaxValue); + //LeftJoystick + if (gamePad.ThumbSticks.Left.X >= deadzone || gamePad.ThumbSticks.Left.X <= -deadzone) + LeftJoystickDX = (int)(gamePad.ThumbSticks.Left.X * short.MaxValue); - //LeftJoystick - if (gamePad.ThumbSticks.Left.X >= deadzone || gamePad.ThumbSticks.Left.X <= -deadzone) - LeftJoystickDX = (int)(gamePad.ThumbSticks.Left.X * short.MaxValue); - - if (gamePad.ThumbSticks.Left.Y >= deadzone || gamePad.ThumbSticks.Left.Y <= -deadzone) - LeftJoystickDY = (int)(gamePad.ThumbSticks.Left.Y * short.MaxValue); + if (gamePad.ThumbSticks.Left.Y >= deadzone || gamePad.ThumbSticks.Left.Y <= -deadzone) + LeftJoystickDY = (int)(gamePad.ThumbSticks.Left.Y * short.MaxValue); + } LeftJoystick = new HidJoystickPosition {