From 0cef1e6b5d2f5c4d7f93bcf0dfec347f6566ef3f Mon Sep 17 00:00:00 2001 From: John Clemis Date: Wed, 27 Jun 2018 12:45:15 -0500 Subject: [PATCH 01/22] Added Basic Controller Support --- Ryujinx/Config.cs | 4 ++++ Ryujinx/Ryujinx.conf | 3 +++ Ryujinx/Ui/GLScreen.cs | 41 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index b437a006dd..705c98d119 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -12,6 +12,8 @@ namespace Ryujinx { public static JoyCon FakeJoyCon { get; private set; } + public static float GamePad_Deadzone; + public static void Read(Logger Log) { string IniFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); @@ -28,6 +30,8 @@ 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")); + string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries); //When the classes are specified on the list, we only diff --git a/Ryujinx/Ryujinx.conf b/Ryujinx/Ryujinx.conf index 611f320717..0f04924873 100644 --- a/Ryujinx/Ryujinx.conf +++ b/Ryujinx/Ryujinx.conf @@ -19,6 +19,9 @@ Logging_Enable_Error = true #Filtered log classes, seperated by ", ", eg. `Logging_Filtered_Classes = Loader, ServiceFS` Logging_Filtered_Classes = +#Controller Analog Stick Deadzone +GamePad_Deadzone = 0.05 + #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 ab5eaa0f52..0614d99cde 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -55,6 +55,7 @@ namespace Ryujinx int LeftJoystickDY = 0; int RightJoystickDX = 0; int RightJoystickDY = 0; + float deadzone = Config.GamePad_Deadzone; if (Keyboard.HasValue) { @@ -62,7 +63,7 @@ namespace Ryujinx if (Keyboard[Key.Escape]) this.Exit(); - //RightJoystick + //LeftJoystick if (Keyboard[(Key)Config.FakeJoyCon.Left.StickUp]) LeftJoystickDY = short.MaxValue; if (Keyboard[(Key)Config.FakeJoyCon.Left.StickDown]) LeftJoystickDY = -short.MaxValue; if (Keyboard[(Key)Config.FakeJoyCon.Left.StickLeft]) LeftJoystickDX = -short.MaxValue; @@ -95,6 +96,44 @@ namespace Ryujinx if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonZR]) CurrentButton |= HidControllerButtons.KEY_ZR; } + //Mapping it relative to the positions of the buttons on the controller + + 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; + + //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); + + 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); + + if (gamePad.ThumbSticks.Left.Y >= deadzone || gamePad.ThumbSticks.Left.Y <= -deadzone) + LeftJoystickDY = (int)(gamePad.ThumbSticks.Left.Y * short.MaxValue); + LeftJoystick = new HidJoystickPosition { DX = LeftJoystickDX, From 6cc56bfe7ed473fedf8dfe79c7a888bbe7cfe147 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Wed, 27 Jun 2018 14:25:44 -0500 Subject: [PATCH 02/22] 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 705c98d119..e842fffbc6 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 0f04924873..146bf5efe5 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 0614d99cde..1c68cfc1ff 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 { From 4809e5effe7f54cdb67bc5e2b4f01315ae34efc5 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Wed, 27 Jun 2018 14:26:19 -0500 Subject: [PATCH 03/22] Revert "Added Extra Configuration Options" This reverts commit 6cc56bfe7ed473fedf8dfe79c7a888bbe7cfe147. --- Ryujinx/Config.cs | 9 ++---- Ryujinx/Ryujinx.conf | 6 ---- Ryujinx/Ui/GLScreen.cs | 64 ++++++++++++++++++++---------------------- 3 files changed, 33 insertions(+), 46 deletions(-) diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index e842fffbc6..705c98d119 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -1,5 +1,4 @@ -using OpenTK.Input; -using Ryujinx.HLE.Input; +using Ryujinx.HLE.Input; using Ryujinx.HLE.Logging; using System; using System.Collections.Generic; @@ -14,8 +13,6 @@ 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) { @@ -33,9 +30,7 @@ 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_Enable = Convert.ToBoolean(Parser.Value("GamePad_Enable")); - GamePad_Index = Convert.ToInt32 (Parser.Value("GamePad_Index")); - GamePad_Deadzone = (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone")); + 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 146bf5efe5..0f04924873 100644 --- a/Ryujinx/Ryujinx.conf +++ b/Ryujinx/Ryujinx.conf @@ -19,15 +19,9 @@ 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 1c68cfc1ff..0614d99cde 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -95,46 +95,44 @@ 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 - GamePadState gamePad = GamePad.GetState(0); + //Mapping it relative to the positions of the buttons on the controller - //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; + GamePadState gamePad = GamePad.GetState(0); - //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; + //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; - //RightJoystick - if (gamePad.ThumbSticks.Right.X >= deadzone || gamePad.ThumbSticks.Right.X <= -deadzone) - RightJoystickDY = (int)(-gamePad.ThumbSticks.Right.X * short.MaxValue); + //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; - if (gamePad.ThumbSticks.Right.Y >= deadzone || gamePad.ThumbSticks.Right.Y <= -deadzone) - RightJoystickDX = (int)(-gamePad.ThumbSticks.Right.Y * short.MaxValue); + //RightJoystick + if (gamePad.ThumbSticks.Right.X >= deadzone || gamePad.ThumbSticks.Right.X <= -deadzone) + RightJoystickDY = (int)(-gamePad.ThumbSticks.Right.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.Right.Y >= deadzone || gamePad.ThumbSticks.Right.Y <= -deadzone) + RightJoystickDX = (int)(-gamePad.ThumbSticks.Right.Y * short.MaxValue); - if (gamePad.ThumbSticks.Left.Y >= deadzone || gamePad.ThumbSticks.Left.Y <= -deadzone) - LeftJoystickDY = (int)(gamePad.ThumbSticks.Left.Y * 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); LeftJoystick = new HidJoystickPosition { From 3ef06e6c5d4367e0d1fbfb9cdb95f0613c06a928 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Wed, 27 Jun 2018 14:27:01 -0500 Subject: [PATCH 04/22] Revert "Revert "Added Extra Configuration Options"" This reverts commit 4809e5effe7f54cdb67bc5e2b4f01315ae34efc5. --- 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 705c98d119..e842fffbc6 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 0f04924873..146bf5efe5 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 0614d99cde..1c68cfc1ff 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 { From bb53859cbad1d884bdb58e03da1ee6c5b0411e89 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Wed, 27 Jun 2018 14:29:07 -0500 Subject: [PATCH 05/22] Forgot to change the Gamepad Index --- Ryujinx/Ui/GLScreen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index 1c68cfc1ff..0a580db560 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -99,7 +99,7 @@ namespace Ryujinx { //Mapping it relative to the positions of the buttons on the controller - GamePadState gamePad = GamePad.GetState(0); + GamePadState gamePad = GamePad.GetState(Config.GamePad_Index); //RightButtons if (gamePad.Buttons.B == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_A; From 29d2d32372542b16e18972cebea313be261fe587 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Wed, 27 Jun 2018 17:07:33 -0500 Subject: [PATCH 06/22] Added Configuration for the A B X Y Buttons --- Ryujinx/Config.cs | 10 +++++ Ryujinx/Ryujinx.conf | 8 +++- Ryujinx/Ui/GLScreen.cs | 90 +++++++++++++++++++++++++++++++++++++++--- 3 files changed, 101 insertions(+), 7 deletions(-) diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index e842fffbc6..625571ce9a 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -17,6 +17,11 @@ namespace Ryujinx public static bool GamePad_Enable; public static int GamePad_Index; + public static string Controls_Right_FakeJoycon_GamePadButton_A; + public static string Controls_Right_FakeJoycon_GamePadButton_B; + public static string Controls_Right_FakeJoycon_GamePadButton_X; + public static string Controls_Right_FakeJoycon_GamePadButton_Y; + public static void Read(Logger Log) { string IniFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); @@ -37,6 +42,11 @@ namespace Ryujinx GamePad_Index = Convert.ToInt32 (Parser.Value("GamePad_Index")); GamePad_Deadzone = (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone")); + Controls_Right_FakeJoycon_GamePadButton_A = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_A"); + Controls_Right_FakeJoycon_GamePadButton_B = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_B"); + Controls_Right_FakeJoycon_GamePadButton_X = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_X"); + Controls_Right_FakeJoycon_GamePadButton_Y = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_Y"); + string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries); //When the classes are specified on the list, we only diff --git a/Ryujinx/Ryujinx.conf b/Ryujinx/Ryujinx.conf index 146bf5efe5..3aa14b1284 100644 --- a/Ryujinx/Ryujinx.conf +++ b/Ryujinx/Ryujinx.conf @@ -53,4 +53,10 @@ Controls_Right_FakeJoycon_Button_X = 85 Controls_Right_FakeJoycon_Button_Y = 104 Controls_Right_FakeJoycon_Button_Plus = 121 Controls_Right_FakeJoycon_Button_R = 103 -Controls_Right_FakeJoycon_Button_ZR = 97 \ No newline at end of file +Controls_Right_FakeJoycon_Button_ZR = 97 + +#Controller Controls +Controls_Right_FakeJoycon_GamePadButton_A = B +Controls_Right_FakeJoycon_GamePadButton_B = A +Controls_Right_FakeJoycon_GamePadButton_X = Y +Controls_Right_FakeJoycon_GamePadButton_Y = X \ No newline at end of file diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index 0a580db560..e4a783f230 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -45,6 +45,81 @@ namespace Ryujinx Renderer.FrameBuffer.SetWindowSize(Width, Height); } + private ButtonState getGamePadButtonFromString(GamePadState gamePad, string str) //Please make this prettier if you can. + { + ButtonState result = gamePad.Buttons.A; + + switch (str) + { + case "A": + result = gamePad.Buttons.A; + break; + case "B": + result = gamePad.Buttons.B; + break; + case "X": + result = gamePad.Buttons.X; + break; + case "Y": + result = gamePad.Buttons.Y; + break; + case "LStick": + result = gamePad.Buttons.LeftStick; + break; + 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 \"" + str + "\"! Defaulting to Button A."); + break; + } + + return result; + } + + private float getGamePadTriggerFromString(GamePadState gamePad, string str) { + float result = 0; + + switch (str) + { + case "LTrigger": + result = gamePad.Triggers.Left; + break; + case "RTrigger": + result = gamePad.Triggers.Right; + break; + default: + Console.Error.WriteLine("Invalid Trigger Mapping \"" + str + "\"! Defaulting to 0."); + break; + } + + return result; + } + protected override void OnUpdateFrame(FrameEventArgs e) { HidControllerButtons CurrentButton = 0; @@ -95,17 +170,20 @@ 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 - GamePadState gamePad = GamePad.GetState(Config.GamePad_Index); //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 (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_A) + == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_A; + if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_B) + == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_B; + if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_X) + == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_X; + if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_Y) + == 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; From 50ee597735e3b49fa467c2957b20aad62ec3b5c5 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Wed, 27 Jun 2018 18:31:10 -0500 Subject: [PATCH 07/22] Added Button Configuration for all other Buttons --- Ryujinx/Config.cs | 34 ++++++++++++++++++++++++++++---- Ryujinx/Ryujinx.conf | 15 +++++++++++++- Ryujinx/Ui/GLScreen.cs | 44 ++++++++++++++++++++++++++++-------------- 3 files changed, 73 insertions(+), 20 deletions(-) diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index 625571ce9a..86fe6ec7f3 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -21,6 +21,19 @@ namespace Ryujinx public static string Controls_Right_FakeJoycon_GamePadButton_B; public static string Controls_Right_FakeJoycon_GamePadButton_X; public static string Controls_Right_FakeJoycon_GamePadButton_Y; + public static string Controls_Right_FakeJoycon_GamePadButton_Plus; + public static string Controls_Right_FakeJoycon_GamePadButton_R; + public static string Controls_Right_FakeJoycon_GamePadStick_Button; + public static string Controls_Right_FakeJoycon_GamePadTrigger_ZR; + + public static string Controls_Left_FakeJoycon_GamePadDPad_Up; + public static string Controls_Left_FakeJoycon_GamePadDPad_Down; + public static string Controls_Left_FakeJoycon_GamePadDPad_Left; + public static string Controls_Left_FakeJoycon_GamePadDPad_Right; + public static string Controls_Left_FakeJoycon_GamePadButton_Minus; + public static string Controls_Left_FakeJoycon_GamePadButton_L; + public static string Controls_Left_FakeJoycon_GamePadStick_Button; + public static string Controls_Left_FakeJoycon_GamePadTrigger_ZL; public static void Read(Logger Log) { @@ -42,10 +55,23 @@ namespace Ryujinx GamePad_Index = Convert.ToInt32 (Parser.Value("GamePad_Index")); GamePad_Deadzone = (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone")); - Controls_Right_FakeJoycon_GamePadButton_A = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_A"); - Controls_Right_FakeJoycon_GamePadButton_B = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_B"); - Controls_Right_FakeJoycon_GamePadButton_X = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_X"); - Controls_Right_FakeJoycon_GamePadButton_Y = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_Y"); + Controls_Right_FakeJoycon_GamePadButton_A = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_A"); + Controls_Right_FakeJoycon_GamePadButton_B = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_B"); + Controls_Right_FakeJoycon_GamePadButton_X = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_X"); + Controls_Right_FakeJoycon_GamePadButton_Y = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_Y"); + Controls_Right_FakeJoycon_GamePadButton_Plus = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_Plus"); + Controls_Right_FakeJoycon_GamePadButton_R = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_R"); + Controls_Right_FakeJoycon_GamePadStick_Button = Parser.Value("Controls_Right_FakeJoycon_GamePadStick_Button"); + Controls_Right_FakeJoycon_GamePadTrigger_ZR = Parser.Value("Controls_Right_FakeJoycon_GamePadTrigger_ZR"); + + Controls_Left_FakeJoycon_GamePadDPad_Up = Parser.Value("Controls_Left_FakeJoycon_GamePadDPad_Up"); + Controls_Left_FakeJoycon_GamePadDPad_Down = Parser.Value("Controls_Left_FakeJoycon_GamePadDPad_Down"); + Controls_Left_FakeJoycon_GamePadDPad_Left = Parser.Value("Controls_Left_FakeJoycon_GamePadDPad_Left"); + Controls_Left_FakeJoycon_GamePadDPad_Right = Parser.Value("Controls_Left_FakeJoycon_GamePadDPad_Right"); + Controls_Left_FakeJoycon_GamePadButton_Minus = Parser.Value("Controls_Left_FakeJoycon_GamePadButton_Minus"); + Controls_Left_FakeJoycon_GamePadButton_L = Parser.Value("Controls_Left_FakeJoycon_GamePadButton_L"); + Controls_Left_FakeJoycon_GamePadStick_Button = Parser.Value("Controls_Left_FakeJoycon_GamePadStick_Button"); + Controls_Left_FakeJoycon_GamePadTrigger_ZL = Parser.Value("Controls_Left_FakeJoycon_GamePadTrigger_ZL"); string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries); diff --git a/Ryujinx/Ryujinx.conf b/Ryujinx/Ryujinx.conf index 3aa14b1284..c4e0847c36 100644 --- a/Ryujinx/Ryujinx.conf +++ b/Ryujinx/Ryujinx.conf @@ -59,4 +59,17 @@ Controls_Right_FakeJoycon_Button_ZR = 97 Controls_Right_FakeJoycon_GamePadButton_A = B Controls_Right_FakeJoycon_GamePadButton_B = A Controls_Right_FakeJoycon_GamePadButton_X = Y -Controls_Right_FakeJoycon_GamePadButton_Y = X \ No newline at end of file +Controls_Right_FakeJoycon_GamePadButton_Y = X +Controls_Right_FakeJoycon_GamePadButton_Plus = Start +Controls_Right_FakeJoycon_GamePadButton_R = RShoulder +Controls_Right_FakeJoycon_GamePadStick_Button = RStick +Controls_Right_FakeJoycon_GamePadTrigger_ZR = RTrigger + +Controls_Left_FakeJoycon_GamePadDPad_Up = DPadUp +Controls_Left_FakeJoycon_GamePadDPad_Down = DPadDown +Controls_Left_FakeJoycon_GamePadDPad_Left = DPadLeft +Controls_Left_FakeJoycon_GamePadDPad_Right = DPadRight +Controls_Left_FakeJoycon_GamePadButton_Minus = Back +Controls_Left_FakeJoycon_GamePadButton_L = LShoulder +Controls_Left_FakeJoycon_GamePadStick_Button = LStick +Controls_Left_FakeJoycon_GamePadTrigger_ZL = LTrigger \ No newline at end of file diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index e4a783f230..a114e0521b 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -101,7 +101,8 @@ namespace Ryujinx return result; } - private float getGamePadTriggerFromString(GamePadState gamePad, string str) { + private float getGamePadTriggerFromString(GamePadState gamePad, string str) + { float result = 0; switch (str) @@ -132,6 +133,7 @@ namespace Ryujinx int RightJoystickDY = 0; float deadzone = Config.GamePad_Deadzone; + //Keyboard Input if (Keyboard.HasValue) { KeyboardState Keyboard = this.Keyboard.Value; @@ -171,33 +173,45 @@ namespace Ryujinx if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonZR]) CurrentButton |= HidControllerButtons.KEY_ZR; } + //Controller Input if (Config.GamePad_Enable) { GamePadState gamePad = GamePad.GetState(Config.GamePad_Index); //RightButtons - if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_A) + if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_A) == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_A; if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_B) == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_B; - if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_X) + if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_X) == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_X; - if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_Y) + if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_Y) == 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 (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadStick_Button) + == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_RSTICK; + if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_Plus) + == 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; + if (getGamePadTriggerFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadTrigger_ZR) + >= 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; + if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadDPad_Up) + == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_DUP; + if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadDPad_Down) + == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_DDOWN; + if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadDPad_Left) + == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_DLEFT; + if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadDPad_Right) + == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_DRIGHT; + if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadStick_Button) + == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_LSTICK; + if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadButton_Minus) + == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_MINUS; + if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadButton_L) + == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_L; + if (getGamePadTriggerFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadTrigger_ZL) + >= 0.5) CurrentButton |= HidControllerButtons.KEY_ZL; //RightJoystick if (gamePad.ThumbSticks.Right.X >= deadzone || gamePad.ThumbSticks.Right.X <= -deadzone) From 56dc5005c45649bffca5c9bfe0a54c4d0f3e7ebd Mon Sep 17 00:00:00 2001 From: John Clemis Date: Wed, 27 Jun 2018 19:05:17 -0500 Subject: [PATCH 08/22] Added Basic Joystick Configuration --- Ryujinx/Config.cs | 6 ++++++ Ryujinx/Ryujinx.conf | 5 ++++- Ryujinx/Ui/GLScreen.cs | 49 +++++++++++++++++++++++++++++++----------- 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index 86fe6ec7f3..1a38ffa6e2 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -35,6 +35,9 @@ namespace Ryujinx public static string Controls_Left_FakeJoycon_GamePadStick_Button; public static string Controls_Left_FakeJoycon_GamePadTrigger_ZL; + public static string Controls_Right_FakeJoycon_GamePadJoystick_R; + public static string Controls_Left_FakeJoycon_GamePadJoystick_L; + public static void Read(Logger Log) { string IniFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); @@ -73,6 +76,9 @@ namespace Ryujinx Controls_Left_FakeJoycon_GamePadStick_Button = Parser.Value("Controls_Left_FakeJoycon_GamePadStick_Button"); Controls_Left_FakeJoycon_GamePadTrigger_ZL = Parser.Value("Controls_Left_FakeJoycon_GamePadTrigger_ZL"); + Controls_Right_FakeJoycon_GamePadJoystick_R = Parser.Value("Controls_Right_FakeJoycon_GamePadJoystick_R"); + Controls_Left_FakeJoycon_GamePadJoystick_L = Parser.Value("Controls_Left_FakeJoycon_GamePadJoystick_L"); + string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries); //When the classes are specified on the list, we only diff --git a/Ryujinx/Ryujinx.conf b/Ryujinx/Ryujinx.conf index c4e0847c36..1b41b6380b 100644 --- a/Ryujinx/Ryujinx.conf +++ b/Ryujinx/Ryujinx.conf @@ -72,4 +72,7 @@ Controls_Left_FakeJoycon_GamePadDPad_Right = DPadRight Controls_Left_FakeJoycon_GamePadButton_Minus = Back Controls_Left_FakeJoycon_GamePadButton_L = LShoulder Controls_Left_FakeJoycon_GamePadStick_Button = LStick -Controls_Left_FakeJoycon_GamePadTrigger_ZL = LTrigger \ No newline at end of file +Controls_Left_FakeJoycon_GamePadTrigger_ZL = LTrigger + +Controls_Right_FakeJoycon_GamePadJoystick_R = RJoystick +Controls_Left_FakeJoycon_GamePadJoystick_L = LJoystick \ No newline at end of file diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index a114e0521b..279e6e94ce 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -121,6 +121,26 @@ namespace Ryujinx return result; } + private Vector2 getJoystickAxisFromString(GamePadState gamePad, string str) + { + Vector2 result = new Vector2(0, 0); + + switch (str) + { + case "LJoystick": + result = gamePad.ThumbSticks.Left; + break; + case "RJoystick": + result = gamePad.ThumbSticks.Right; + break; + default: + Console.Error.WriteLine("Invalid Joystick Axis \"" + str + "\"! Defaulting the Vector2 to 0, 0."); + break; + } + + return result; + } + protected override void OnUpdateFrame(FrameEventArgs e) { HidControllerButtons CurrentButton = 0; @@ -187,12 +207,13 @@ namespace Ryujinx == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_X; if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_Y) == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_Y; - if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadStick_Button) + if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadStick_Button) == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_RSTICK; - if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_Plus) + if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_Plus) == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_PLUS; - if (gamePad.Buttons.RightShoulder == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_R; - if (getGamePadTriggerFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadTrigger_ZR) + if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_R) + == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_R; + if (getGamePadTriggerFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadTrigger_ZR) >= 0.5) CurrentButton |= HidControllerButtons.KEY_ZR; //LeftButtons @@ -214,18 +235,22 @@ namespace Ryujinx >= 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); + if (getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).X >= deadzone + || getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).X <= -deadzone) + RightJoystickDY = (int)(-getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).X * short.MaxValue); - if (gamePad.ThumbSticks.Right.Y >= deadzone || gamePad.ThumbSticks.Right.Y <= -deadzone) - RightJoystickDX = (int)(-gamePad.ThumbSticks.Right.Y * short.MaxValue); + if (getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).Y >= deadzone + || getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).Y <= -deadzone) + RightJoystickDX = (int)(-getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).Y * short.MaxValue); //LeftJoystick - if (gamePad.ThumbSticks.Left.X >= deadzone || gamePad.ThumbSticks.Left.X <= -deadzone) - LeftJoystickDX = (int)(gamePad.ThumbSticks.Left.X * short.MaxValue); + if (getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).X >= deadzone + || getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).X <= -deadzone) + LeftJoystickDX = (int)(getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).X * short.MaxValue); - if (gamePad.ThumbSticks.Left.Y >= deadzone || gamePad.ThumbSticks.Left.Y <= -deadzone) - LeftJoystickDY = (int)(gamePad.ThumbSticks.Left.Y * short.MaxValue); + if (getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).Y >= deadzone + || getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).Y <= -deadzone) + LeftJoystickDY = (int)(getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).Y * short.MaxValue); } LeftJoystick = new HidJoystickPosition From 1f492e99d8ab3df543729225fdc5550d3ed2f1c8 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Wed, 27 Jun 2018 19:26:11 -0500 Subject: [PATCH 09/22] Fixed Joystick Axis Problems Fixed Joystick Axis Problems when switching around the Joysticks (Left Stick is Right and Right stick is Left) --- Ryujinx/Ui/GLScreen.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index 279e6e94ce..50dfe70136 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -131,7 +131,7 @@ namespace Ryujinx result = gamePad.ThumbSticks.Left; break; case "RJoystick": - result = gamePad.ThumbSticks.Right; + result = new Vector2(-gamePad.ThumbSticks.Right.Y, -gamePad.ThumbSticks.Right.X); break; default: Console.Error.WriteLine("Invalid Joystick Axis \"" + str + "\"! Defaulting the Vector2 to 0, 0."); @@ -235,13 +235,14 @@ namespace Ryujinx >= 0.5) CurrentButton |= HidControllerButtons.KEY_ZL; //RightJoystick + if (getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).X >= deadzone || getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).X <= -deadzone) - RightJoystickDY = (int)(-getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).X * short.MaxValue); + RightJoystickDX = (int)(getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).X * short.MaxValue); if (getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).Y >= deadzone || getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).Y <= -deadzone) - RightJoystickDX = (int)(-getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).Y * short.MaxValue); + RightJoystickDY = (int)(getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).Y * short.MaxValue); //LeftJoystick if (getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).X >= deadzone From 60ad45cc2912ed6a457a9fb78b375085fab774a2 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Thu, 28 Jun 2018 08:59:36 -0500 Subject: [PATCH 10/22] Refactored all of the button mapping code --- CONFIG.md | 127 +++++++++++---- README.md | 25 ++- Ryujinx/Config.cs | 140 ++++++++--------- Ryujinx/JoyConController.cs | 38 +++++ .../JoyCon.cs => Ryujinx/JoyConKeyboard.cs | 17 +- Ryujinx/JoyConReal.cs | 8 + Ryujinx/Ryujinx.conf | 88 ++++++----- Ryujinx/Ui/GLScreen.cs | 147 +++++++++--------- 8 files changed, 352 insertions(+), 238 deletions(-) create mode 100644 Ryujinx/JoyConController.cs rename Ryujinx.HLE/Hid/JoyCon.cs => Ryujinx/JoyConKeyboard.cs (67%) create mode 100644 Ryujinx/JoyConReal.cs diff --git a/CONFIG.md b/CONFIG.md index 764eb528da..b5de9fa6dc 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -8,23 +8,23 @@ - `Logging_Enable_Trace` *(bool)* - Enable the Trace Logging (Enabled in Debug recommanded). + Enable the Trace Logging (Enabled in Debug recommended). - `Logging_Enable_Debug` *(bool)* - Enable the Debug Logging (Enabled in Debug recommanded). + Enable the Debug Logging (Enabled in Debug recommended). - `Logging_Enable_Warn` *(bool)* - Enable the Warning Logging (Enabled in Debug recommanded). + Enable the Warning Logging (Enabled in Debug recommended). - `Logging_Enable_Error` *(bool)* - Enable the Error Logging (Enabled in Debug recommanded). + Enable the Error Logging (Enabled in Debug recommended). - `Logging_Enable_Fatal` *(bool)* - Enable the Fatal Logging (Enabled in Debug recommanded). + Enable the Fatal Logging (Enabled in Debug recommended). - `Logging_Enable_Ipc` *(bool)* @@ -34,46 +34,107 @@ Enable writing the logging inside a Ryujinx.log file. -- `Controls_Left_FakeJoycon_XX` *(int)* +- `GamePad_Index` *(int)* + + The index of the Controller Device. + +- `GamePad_Deadzone` *(float)* + + The deadzone of both analog sticks on the Controller. + +- `GamePad_Enable` *(bool)* + + Whether or not to enable Controller Support. + +- `Controls_Left_JoyConKeyboard_XX` *(int)* ``` - Controls_Left_FakeJoycon_Stick_Up (int) - Controls_Left_FakeJoycon_Stick_Down (int) - Controls_Left_FakeJoycon_Stick_Left (int) - Controls_Left_FakeJoycon_Stick_Right (int) - Controls_Left_FakeJoycon_Stick_Button (int) - Controls_Left_FakeJoycon_DPad_Up (int) - Controls_Left_FakeJoycon_DPad_Down (int) - Controls_Left_FakeJoycon_DPad_Left (int) - Controls_Left_FakeJoycon_DPad_Right (int) - Controls_Left_FakeJoycon_Button_Minus (int) - Controls_Left_FakeJoycon_Button_L (int) - Controls_Left_FakeJoycon_Button_ZL (int) + Controls_Left_JoyConKeyboard_Stick_Up (int) + Controls_Left_JoyConKeyboard_Stick_Down (int) + Controls_Left_JoyConKeyboard_Stick_Left (int) + Controls_Left_JoyConKeyboard_Stick_Right (int) + Controls_Left_JoyConKeyboard_Stick_Button (int) + Controls_Left_JoyConKeyboard_DPad_Up (int) + Controls_Left_JoyConKeyboard_DPad_Down (int) + Controls_Left_JoyConKeyboard_DPad_Left (int) + Controls_Left_JoyConKeyboard_DPad_Right (int) + Controls_Left_JoyConKeyboard_Button_Minus (int) + Controls_Left_JoyConKeyboard_Button_L (int) + Controls_Left_JoyConKeyboard_Button_ZL (int) ``` Keys of the Left Emulated Joycon, the values depend of the [OpenTK Enum Keys](https://github.com/opentk/opentk/blob/develop/src/OpenTK/Input/Key.cs). OpenTK use a QWERTY layout, so pay attention if you use another Keyboard Layout. - Ex: `Controls_Left_FakeJoycon_Button_Minus = 52` > Tab key (All Layout). + Ex: `Controls_Left_JoyConKeyboard_Button_Minus = 52` > Tab key (All Layout). -- `Controls_Right_FakeJoycon_XX` *(int)* +- `Controls_Right_JoyConKeyboard_XX` *(int)* ``` - Controls_Right_FakeJoycon_Stick_Up (int) - Controls_Right_FakeJoycon_Stick_Down (int) - Controls_Right_FakeJoycon_Stick_Left (int) - Controls_Right_FakeJoycon_Stick_Right (int) - Controls_Right_FakeJoycon_Stick_Button (int) - Controls_Right_FakeJoycon_Button_A (int) - Controls_Right_FakeJoycon_Button_B (int) - Controls_Right_FakeJoycon_Button_X (int) - Controls_Right_FakeJoycon_Button_Y (int) - Controls_Right_FakeJoycon_Button_Plus (int) - Controls_Right_FakeJoycon_Button_R (int) - Controls_Right_FakeJoycon_Button_ZR (int) + Controls_Right_JoyConKeyboard_Stick_Up (int) + Controls_Right_JoyConKeyboard_Stick_Down (int) + Controls_Right_JoyConKeyboard_Stick_Left (int) + Controls_Right_JoyConKeyboard_Stick_Right (int) + Controls_Right_JoyConKeyboard_Stick_Button (int) + Controls_Right_JoyConKeyboard_Button_A (int) + Controls_Right_JoyConKeyboard_Button_B (int) + Controls_Right_JoyConKeyboard_Button_X (int) + Controls_Right_JoyConKeyboard_Button_Y (int) + Controls_Right_JoyConKeyboard_Button_Plus (int) + Controls_Right_JoyConKeyboard_Button_R (int) + Controls_Right_JoyConKeyboard_Button_ZR (int) ``` Keys of the right Emulated Joycon, the values depend of the [OpenTK Enum Keys](https://github.com/opentk/opentk/blob/develop/src/OpenTK/Input/Key.cs). OpenTK use a QWERTY layout, so pay attention if you use another Keyboard Layout. - Ex: `Controls_Right_FakeJoycon_Button_A = 83` > A key (QWERTY Layout) / Q key (AZERTY Layout). + Ex: `Controls_Right_JoyConKeyboard_Button_A = 83` > A key (QWERTY Layout) / Q key (AZERTY Layout). + +- `Controls_Left_JoyConController_XX` *(String)* + ``` + Controls_Left_JoyConController_Stick (String) + Controls_Left_JoyConController_Stick_Button (String) + Controls_Left_JoyConController_DPad_Up (String) + Controls_Left_JoyConController_DPad_Down (String) + Controls_Left_JoyConController_DPad_Left (String) + Controls_Left_JoyConController_DPad_Right (String) + Controls_Left_JoyConController_Button_Minus (String) + Controls_Left_JoyConController_Button_L (String) + Controls_Left_JoyConController_Button_ZL (String) + ``` + +- `Controls_Right_JoyConController_XX` *(String)* + ``` + Controls_Right_JoyConController_Stick (String) + Controls_Right_JoyConController_Stick_Button (String) + Controls_Right_JoyConController_Button_A (String) + Controls_Right_JoyConController_Button_B (String) + Controls_Right_JoyConController_Button_X (String) + Controls_Right_JoyConController_Button_Y (String) + Controls_Right_JoyConController_Button_Plus (String) + Controls_Right_JoyConController_Button_R (String) + Controls_Right_JoyConController_Button_ZR (String) + ``` + +- Valid Button Mappings + - A = The A / Cross Button + - B = The B / Circle Button + - X = The X / Square Button + - Y = The Y / Triangle Button + - LStick = The Left Analog Stick when Pressed Down + - RStick = The Right Analog Stick when Pressed Down + - Start = The Start / Options Button + - Back = The Select / Back / Share Button + - RShoulder = The Right Shoulder Button + - LShoulder = The Left Shoulder Button + - RTrigger = The Right Trigger + - LTrigger = The Left Trigger + - DPadUp = Up on the DPad + - DPadDown = Down on the DPad + - DPadLeft = Left on the DPad + - DpadRight = Right on the DPad +- Valid Joystick Mappings + - LJoystick = The Left Analog Stick + - RJoystick = The Right Analog Stick + + On more obscure / weird controllers this can vary, so if this list doesn't work, trial and error will. \ No newline at end of file diff --git a/README.md b/README.md index 3efd347a85..71dad9ce29 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,32 @@ https://openal.org/downloads/OpenAL11CoreSDK.zip - Plus = + - R = U - ZR = O + - For more information on how to configure these buttons see [CONFIG.md](CONFIG.md) + + - Controller Input is partially supported: + - Left Joycon: + - Analog Stick = Left Analog Stick + - DPad Up = DPad Up + - DPad Down = DPad Down + - DPad Left = DPad Left + - DPad Right = DPad Right + - Minus = Select / Back / Share + - L = Left Shoulder Button + - ZL = Left Trigger + + - Right Joycon: + - Analog Stick = Right Analog Stick + - A = B / Circle + - B = A / Cross + - X = Y / Triangle + - Y = X / Square + - Plus = Start / Options + - R = Right Shoulder Button + - ZR = Right Trigger + - For more information on how to configure these buttons see [CONFIG.md](CONFIG.md) - Config File: `Ryujinx.conf` should be present in executable folder. - For more informations [you can go here](CONFIG.md). + For more information [you can go here](CONFIG.md). - If you are a Windows user, you can configure your keys, the logs, install OpenAL, etc... with Ryujinx-Setting. [Download it, right here](https://github.com/AcK77/Ryujinx-Settings) diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index 1a38ffa6e2..022da24278 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -1,5 +1,5 @@ using OpenTK.Input; -using Ryujinx.HLE.Input; +using Ryujinx.Input; using Ryujinx.HLE.Logging; using System; using System.Collections.Generic; @@ -11,32 +11,13 @@ namespace Ryujinx { public static class Config { - public static JoyCon FakeJoyCon { get; private set; } + public static JoyConKeyboard JoyConKeyboard { get; private set; } + public static JoyConController JoyConController { get; private set; } public static float GamePad_Deadzone; public static bool GamePad_Enable; public static int GamePad_Index; - - public static string Controls_Right_FakeJoycon_GamePadButton_A; - public static string Controls_Right_FakeJoycon_GamePadButton_B; - public static string Controls_Right_FakeJoycon_GamePadButton_X; - public static string Controls_Right_FakeJoycon_GamePadButton_Y; - public static string Controls_Right_FakeJoycon_GamePadButton_Plus; - public static string Controls_Right_FakeJoycon_GamePadButton_R; - public static string Controls_Right_FakeJoycon_GamePadStick_Button; - public static string Controls_Right_FakeJoycon_GamePadTrigger_ZR; - - public static string Controls_Left_FakeJoycon_GamePadDPad_Up; - public static string Controls_Left_FakeJoycon_GamePadDPad_Down; - public static string Controls_Left_FakeJoycon_GamePadDPad_Left; - public static string Controls_Left_FakeJoycon_GamePadDPad_Right; - public static string Controls_Left_FakeJoycon_GamePadButton_Minus; - public static string Controls_Left_FakeJoycon_GamePadButton_L; - public static string Controls_Left_FakeJoycon_GamePadStick_Button; - public static string Controls_Left_FakeJoycon_GamePadTrigger_ZL; - - public static string Controls_Right_FakeJoycon_GamePadJoystick_R; - public static string Controls_Left_FakeJoycon_GamePadJoystick_L; + public static float GamePad_Trigger_Threshold; public static void Read(Logger Log) { @@ -54,30 +35,10 @@ 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_Enable = Convert.ToBoolean(Parser.Value("GamePad_Enable")); - GamePad_Index = Convert.ToInt32 (Parser.Value("GamePad_Index")); - GamePad_Deadzone = (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone")); - - Controls_Right_FakeJoycon_GamePadButton_A = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_A"); - Controls_Right_FakeJoycon_GamePadButton_B = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_B"); - Controls_Right_FakeJoycon_GamePadButton_X = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_X"); - Controls_Right_FakeJoycon_GamePadButton_Y = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_Y"); - Controls_Right_FakeJoycon_GamePadButton_Plus = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_Plus"); - Controls_Right_FakeJoycon_GamePadButton_R = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_R"); - Controls_Right_FakeJoycon_GamePadStick_Button = Parser.Value("Controls_Right_FakeJoycon_GamePadStick_Button"); - Controls_Right_FakeJoycon_GamePadTrigger_ZR = Parser.Value("Controls_Right_FakeJoycon_GamePadTrigger_ZR"); - - Controls_Left_FakeJoycon_GamePadDPad_Up = Parser.Value("Controls_Left_FakeJoycon_GamePadDPad_Up"); - Controls_Left_FakeJoycon_GamePadDPad_Down = Parser.Value("Controls_Left_FakeJoycon_GamePadDPad_Down"); - Controls_Left_FakeJoycon_GamePadDPad_Left = Parser.Value("Controls_Left_FakeJoycon_GamePadDPad_Left"); - Controls_Left_FakeJoycon_GamePadDPad_Right = Parser.Value("Controls_Left_FakeJoycon_GamePadDPad_Right"); - Controls_Left_FakeJoycon_GamePadButton_Minus = Parser.Value("Controls_Left_FakeJoycon_GamePadButton_Minus"); - Controls_Left_FakeJoycon_GamePadButton_L = Parser.Value("Controls_Left_FakeJoycon_GamePadButton_L"); - Controls_Left_FakeJoycon_GamePadStick_Button = Parser.Value("Controls_Left_FakeJoycon_GamePadStick_Button"); - Controls_Left_FakeJoycon_GamePadTrigger_ZL = Parser.Value("Controls_Left_FakeJoycon_GamePadTrigger_ZL"); - - Controls_Right_FakeJoycon_GamePadJoystick_R = Parser.Value("Controls_Right_FakeJoycon_GamePadJoystick_R"); - Controls_Left_FakeJoycon_GamePadJoystick_L = Parser.Value("Controls_Left_FakeJoycon_GamePadJoystick_L"); + 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")); + GamePad_Trigger_Threshold = (float)Convert.ToDouble (Parser.Value("GamePad_Trigger_Threshold")); string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries); @@ -107,44 +68,73 @@ namespace Ryujinx } } - FakeJoyCon = new JoyCon + JoyConKeyboard = new JoyConKeyboard { - Left = new JoyConLeft + Left = new JoyConKeyboardLeft { - StickUp = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Stick_Up")), - StickDown = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Stick_Down")), - StickLeft = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Stick_Left")), - StickRight = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Stick_Right")), - StickButton = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Stick_Button")), - DPadUp = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_DPad_Up")), - DPadDown = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_DPad_Down")), - DPadLeft = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_DPad_Left")), - DPadRight = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_DPad_Right")), - ButtonMinus = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Button_Minus")), - ButtonL = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Button_L")), - ButtonZL = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Button_ZL")) + StickUp = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Stick_Up")), + StickDown = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Stick_Down")), + StickLeft = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Stick_Left")), + StickRight = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Stick_Right")), + StickButton = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Stick_Button")), + DPadUp = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_DPad_Up")), + DPadDown = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_DPad_Down")), + DPadLeft = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_DPad_Left")), + DPadRight = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_DPad_Right")), + ButtonMinus = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Button_Minus")), + ButtonL = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Button_L")), + ButtonZL = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Button_ZL")) }, - Right = new JoyConRight + Right = new JoyConKeyboardRight { - StickUp = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Stick_Up")), - StickDown = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Stick_Down")), - StickLeft = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Stick_Left")), - StickRight = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Stick_Right")), - StickButton = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Stick_Button")), - ButtonA = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_A")), - ButtonB = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_B")), - ButtonX = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_X")), - ButtonY = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_Y")), - ButtonPlus = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_Plus")), - ButtonR = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_R")), - ButtonZR = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_ZR")) + StickUp = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Stick_Up")), + StickDown = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Stick_Down")), + StickLeft = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Stick_Left")), + StickRight = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Stick_Right")), + StickButton = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Stick_Button")), + ButtonA = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_A")), + ButtonB = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_B")), + ButtonX = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_X")), + ButtonY = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_Y")), + ButtonPlus = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_Plus")), + ButtonR = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_R")), + ButtonZR = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_ZR")) + } + }; + + JoyConController = new JoyConController + { + Left = new JoyConControllerLeft + { + 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"), + DPadLeft = Parser.Value("Controls_Left_JoyConController_DPad_Left"), + DPadRight = Parser.Value("Controls_Left_JoyConController_DPad_Right"), + ButtonMinus = Parser.Value("Controls_Left_JoyConController_Button_Minus"), + ButtonL = Parser.Value("Controls_Left_JoyConController_Button_L"), + ButtonZL = Parser.Value("Controls_Left_JoyConController_Button_ZL") + }, + + Right = new JoyConControllerRight + { + 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"), + ButtonX = Parser.Value("Controls_Right_JoyConController_Button_X"), + ButtonY = Parser.Value("Controls_Right_JoyConController_Button_Y"), + ButtonPlus = Parser.Value("Controls_Right_JoyConController_Button_Plus"), + ButtonR = Parser.Value("Controls_Right_JoyConController_Button_R"), + ButtonZR = Parser.Value("Controls_Right_JoyConController_Button_ZR") } }; } } - // https://stackoverflow.com/a/37772571 + //https://stackoverflow.com/a/37772571 public class IniParser { private readonly Dictionary Values; diff --git a/Ryujinx/JoyConController.cs b/Ryujinx/JoyConController.cs new file mode 100644 index 0000000000..d779abf432 --- /dev/null +++ b/Ryujinx/JoyConController.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Ryujinx.Input +{ + public struct JoyConControllerLeft + { + public string Stick; + public string StickButton; + public string DPadUp; + public string DPadDown; + public string DPadLeft; + public string DPadRight; + public string ButtonMinus; + public string ButtonL; + public string ButtonZL; + } + + public struct JoyConControllerRight + { + public string Stick; + public string StickButton; + public string ButtonA; + public string ButtonB; + public string ButtonX; + public string ButtonY; + public string ButtonPlus; + public string ButtonR; + public string ButtonZR; + } + + public struct JoyConController + { + public JoyConControllerLeft Left; + public JoyConControllerRight Right; + } +} diff --git a/Ryujinx.HLE/Hid/JoyCon.cs b/Ryujinx/JoyConKeyboard.cs similarity index 67% rename from Ryujinx.HLE/Hid/JoyCon.cs rename to Ryujinx/JoyConKeyboard.cs index e45e1a47e4..2d57b67a45 100644 --- a/Ryujinx.HLE/Hid/JoyCon.cs +++ b/Ryujinx/JoyConKeyboard.cs @@ -1,7 +1,6 @@ -//TODO: This is only used by Config, it doesn't belong to Core. -namespace Ryujinx.HLE.Input +namespace Ryujinx.Input { - public struct JoyConLeft + public struct JoyConKeyboardLeft { public int StickUp; public int StickDown; @@ -15,11 +14,9 @@ namespace Ryujinx.HLE.Input public int ButtonMinus; public int ButtonL; public int ButtonZL; - public int ButtonSL; - public int ButtonSR; } - public struct JoyConRight + public struct JoyConKeyboardRight { public int StickUp; public int StickDown; @@ -33,13 +30,11 @@ namespace Ryujinx.HLE.Input public int ButtonPlus; public int ButtonR; public int ButtonZR; - public int ButtonSL; - public int ButtonSR; } - public struct JoyCon + public struct JoyConKeyboard { - public JoyConLeft Left; - public JoyConRight Right; + public JoyConKeyboardLeft Left; + public JoyConKeyboardRight Right; } } diff --git a/Ryujinx/JoyConReal.cs b/Ryujinx/JoyConReal.cs new file mode 100644 index 0000000000..9851bb497e --- /dev/null +++ b/Ryujinx/JoyConReal.cs @@ -0,0 +1,8 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Ryujinx.Input +{ + //TODO: Add real Bluetooth Joy Con Support in the far future. +} diff --git a/Ryujinx/Ryujinx.conf b/Ryujinx/Ryujinx.conf index 1b41b6380b..59f7f859e7 100644 --- a/Ryujinx/Ryujinx.conf +++ b/Ryujinx/Ryujinx.conf @@ -25,54 +25,58 @@ GamePad_Index = 0 #Controller Analog Stick Deadzone GamePad_Deadzone = 0.05 +#The value of how pressed down each trigger has to be in order to register a button press +GamePad_Trigger_Threshold = 0.5 + #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 -Controls_Left_FakeJoycon_Stick_Left = 83 -Controls_Left_FakeJoycon_Stick_Right = 86 -Controls_Left_FakeJoycon_Stick_Button = 88 -Controls_Left_FakeJoycon_DPad_Up = 45 -Controls_Left_FakeJoycon_DPad_Down = 46 -Controls_Left_FakeJoycon_DPad_Left = 47 -Controls_Left_FakeJoycon_DPad_Right = 48 -Controls_Left_FakeJoycon_Button_Minus = 120 -Controls_Left_FakeJoycon_Button_L = 87 -Controls_Left_FakeJoycon_Button_ZL = 99 +Controls_Left_JoyConKeyboard_Stick_Up = 105 +Controls_Left_JoyConKeyboard_Stick_Down = 101 +Controls_Left_JoyConKeyboard_Stick_Left = 83 +Controls_Left_JoyConKeyboard_Stick_Right = 86 +Controls_Left_JoyConKeyboard_Stick_Button = 88 +Controls_Left_JoyConKeyboard_DPad_Up = 45 +Controls_Left_JoyConKeyboard_DPad_Down = 46 +Controls_Left_JoyConKeyboard_DPad_Left = 47 +Controls_Left_JoyConKeyboard_DPad_Right = 48 +Controls_Left_JoyConKeyboard_Button_Minus = 120 +Controls_Left_JoyConKeyboard_Button_L = 87 +Controls_Left_JoyConKeyboard_Button_ZL = 99 -Controls_Right_FakeJoycon_Stick_Up = 91 -Controls_Right_FakeJoycon_Stick_Down = 93 -Controls_Right_FakeJoycon_Stick_Left = 92 -Controls_Right_FakeJoycon_Stick_Right = 94 -Controls_Right_FakeJoycon_Stick_Button = 90 -Controls_Right_FakeJoycon_Button_A = 108 -Controls_Right_FakeJoycon_Button_B = 106 -Controls_Right_FakeJoycon_Button_X = 85 -Controls_Right_FakeJoycon_Button_Y = 104 -Controls_Right_FakeJoycon_Button_Plus = 121 -Controls_Right_FakeJoycon_Button_R = 103 -Controls_Right_FakeJoycon_Button_ZR = 97 +Controls_Right_JoyConKeyboard_Stick_Up = 91 +Controls_Right_JoyConKeyboard_Stick_Down = 93 +Controls_Right_JoyConKeyboard_Stick_Left = 92 +Controls_Right_JoyConKeyboard_Stick_Right = 94 +Controls_Right_JoyConKeyboard_Stick_Button = 90 +Controls_Right_JoyConKeyboard_Button_A = 108 +Controls_Right_JoyConKeyboard_Button_B = 106 +Controls_Right_JoyConKeyboard_Button_X = 85 +Controls_Right_JoyConKeyboard_Button_Y = 104 +Controls_Right_JoyConKeyboard_Button_Plus = 121 +Controls_Right_JoyConKeyboard_Button_R = 103 +Controls_Right_JoyConKeyboard_Button_ZR = 97 #Controller Controls -Controls_Right_FakeJoycon_GamePadButton_A = B -Controls_Right_FakeJoycon_GamePadButton_B = A -Controls_Right_FakeJoycon_GamePadButton_X = Y -Controls_Right_FakeJoycon_GamePadButton_Y = X -Controls_Right_FakeJoycon_GamePadButton_Plus = Start -Controls_Right_FakeJoycon_GamePadButton_R = RShoulder -Controls_Right_FakeJoycon_GamePadStick_Button = RStick -Controls_Right_FakeJoycon_GamePadTrigger_ZR = RTrigger -Controls_Left_FakeJoycon_GamePadDPad_Up = DPadUp -Controls_Left_FakeJoycon_GamePadDPad_Down = DPadDown -Controls_Left_FakeJoycon_GamePadDPad_Left = DPadLeft -Controls_Left_FakeJoycon_GamePadDPad_Right = DPadRight -Controls_Left_FakeJoycon_GamePadButton_Minus = Back -Controls_Left_FakeJoycon_GamePadButton_L = LShoulder -Controls_Left_FakeJoycon_GamePadStick_Button = LStick -Controls_Left_FakeJoycon_GamePadTrigger_ZL = LTrigger +Controls_Left_JoyConController_Stick_Button = LStick +Controls_Left_JoyConController_DPad_Up = DPadUp +Controls_Left_JoyConController_DPad_Down = DPadDown +Controls_Left_JoyConController_DPad_Left = DPadLeft +Controls_Left_JoyConController_DPad_Right = DPadRight +Controls_Left_JoyConController_Button_Minus = Back +Controls_Left_JoyConController_Button_L = LShoulder +Controls_Left_JoyConController_Button_ZL = LTrigger -Controls_Right_FakeJoycon_GamePadJoystick_R = RJoystick -Controls_Left_FakeJoycon_GamePadJoystick_L = LJoystick \ No newline at end of file +Controls_Right_JoyConController_Stick_Button = RStick +Controls_Right_JoyConController_Button_A = B +Controls_Right_JoyConController_Button_B = A +Controls_Right_JoyConController_Button_X = Y +Controls_Right_JoyConController_Button_Y = X +Controls_Right_JoyConController_Button_Plus = Start +Controls_Right_JoyConController_Button_R = RShoulder +Controls_Right_JoyConController_Button_ZR = RTrigger + +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 50dfe70136..f042bdc45d 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -44,8 +44,20 @@ namespace Ryujinx Renderer.FrameBuffer.SetWindowSize(Width, Height); } + + private bool IsGamePadButtonPressedFromString(GamePadState gamePad, string str) + { + if (str == "LTrigger" || str == "RTrigger") + { + return GetGamePadTriggerFromString(gamePad, str) >= Config.GamePad_Trigger_Threshold; + } + else + { + return (GetGamePadButtonFromString(gamePad, str) == ButtonState.Pressed); + } + } - private ButtonState getGamePadButtonFromString(GamePadState gamePad, string str) //Please make this prettier if you can. + private ButtonState GetGamePadButtonFromString(GamePadState gamePad, string str) //Please make this prettier if you can. { ButtonState result = gamePad.Buttons.A; @@ -101,7 +113,7 @@ namespace Ryujinx return result; } - private float getGamePadTriggerFromString(GamePadState gamePad, string str) + private float GetGamePadTriggerFromString(GamePadState gamePad, string str) { float result = 0; @@ -121,7 +133,7 @@ namespace Ryujinx return result; } - private Vector2 getJoystickAxisFromString(GamePadState gamePad, string str) + private Vector2 GetJoystickAxisFromString(GamePadState gamePad, string str) { Vector2 result = new Vector2(0, 0); @@ -161,36 +173,36 @@ namespace Ryujinx if (Keyboard[Key.Escape]) this.Exit(); //LeftJoystick - if (Keyboard[(Key)Config.FakeJoyCon.Left.StickUp]) LeftJoystickDY = short.MaxValue; - if (Keyboard[(Key)Config.FakeJoyCon.Left.StickDown]) LeftJoystickDY = -short.MaxValue; - if (Keyboard[(Key)Config.FakeJoyCon.Left.StickLeft]) LeftJoystickDX = -short.MaxValue; - if (Keyboard[(Key)Config.FakeJoyCon.Left.StickRight]) LeftJoystickDX = short.MaxValue; + if (Keyboard[(Key)Config.JoyConKeyboard.Left.StickUp]) LeftJoystickDY = short.MaxValue; + if (Keyboard[(Key)Config.JoyConKeyboard.Left.StickDown]) LeftJoystickDY = -short.MaxValue; + if (Keyboard[(Key)Config.JoyConKeyboard.Left.StickLeft]) LeftJoystickDX = -short.MaxValue; + if (Keyboard[(Key)Config.JoyConKeyboard.Left.StickRight]) LeftJoystickDX = short.MaxValue; //LeftButtons - if (Keyboard[(Key)Config.FakeJoyCon.Left.StickButton]) CurrentButton |= HidControllerButtons.KEY_LSTICK; - if (Keyboard[(Key)Config.FakeJoyCon.Left.DPadUp]) CurrentButton |= HidControllerButtons.KEY_DUP; - if (Keyboard[(Key)Config.FakeJoyCon.Left.DPadDown]) CurrentButton |= HidControllerButtons.KEY_DDOWN; - if (Keyboard[(Key)Config.FakeJoyCon.Left.DPadLeft]) CurrentButton |= HidControllerButtons.KEY_DLEFT; - if (Keyboard[(Key)Config.FakeJoyCon.Left.DPadRight]) CurrentButton |= HidControllerButtons.KEY_DRIGHT; - if (Keyboard[(Key)Config.FakeJoyCon.Left.ButtonMinus]) CurrentButton |= HidControllerButtons.KEY_MINUS; - if (Keyboard[(Key)Config.FakeJoyCon.Left.ButtonL]) CurrentButton |= HidControllerButtons.KEY_L; - if (Keyboard[(Key)Config.FakeJoyCon.Left.ButtonZL]) CurrentButton |= HidControllerButtons.KEY_ZL; + if (Keyboard[(Key)Config.JoyConKeyboard.Left.StickButton]) CurrentButton |= HidControllerButtons.KEY_LSTICK; + if (Keyboard[(Key)Config.JoyConKeyboard.Left.DPadUp]) CurrentButton |= HidControllerButtons.KEY_DUP; + if (Keyboard[(Key)Config.JoyConKeyboard.Left.DPadDown]) CurrentButton |= HidControllerButtons.KEY_DDOWN; + if (Keyboard[(Key)Config.JoyConKeyboard.Left.DPadLeft]) CurrentButton |= HidControllerButtons.KEY_DLEFT; + if (Keyboard[(Key)Config.JoyConKeyboard.Left.DPadRight]) CurrentButton |= HidControllerButtons.KEY_DRIGHT; + if (Keyboard[(Key)Config.JoyConKeyboard.Left.ButtonMinus]) CurrentButton |= HidControllerButtons.KEY_MINUS; + if (Keyboard[(Key)Config.JoyConKeyboard.Left.ButtonL]) CurrentButton |= HidControllerButtons.KEY_L; + if (Keyboard[(Key)Config.JoyConKeyboard.Left.ButtonZL]) CurrentButton |= HidControllerButtons.KEY_ZL; //RightJoystick - if (Keyboard[(Key)Config.FakeJoyCon.Right.StickUp]) RightJoystickDY = short.MaxValue; - if (Keyboard[(Key)Config.FakeJoyCon.Right.StickDown]) RightJoystickDY = -short.MaxValue; - if (Keyboard[(Key)Config.FakeJoyCon.Right.StickLeft]) RightJoystickDX = -short.MaxValue; - if (Keyboard[(Key)Config.FakeJoyCon.Right.StickRight]) RightJoystickDX = short.MaxValue; + if (Keyboard[(Key)Config.JoyConKeyboard.Right.StickUp]) RightJoystickDY = short.MaxValue; + if (Keyboard[(Key)Config.JoyConKeyboard.Right.StickDown]) RightJoystickDY = -short.MaxValue; + if (Keyboard[(Key)Config.JoyConKeyboard.Right.StickLeft]) RightJoystickDX = -short.MaxValue; + if (Keyboard[(Key)Config.JoyConKeyboard.Right.StickRight]) RightJoystickDX = short.MaxValue; //RightButtons - if (Keyboard[(Key)Config.FakeJoyCon.Right.StickButton]) CurrentButton |= HidControllerButtons.KEY_RSTICK; - if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonA]) CurrentButton |= HidControllerButtons.KEY_A; - if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonB]) CurrentButton |= HidControllerButtons.KEY_B; - if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonX]) CurrentButton |= HidControllerButtons.KEY_X; - if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonY]) CurrentButton |= HidControllerButtons.KEY_Y; - if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonPlus]) CurrentButton |= HidControllerButtons.KEY_PLUS; - if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonR]) CurrentButton |= HidControllerButtons.KEY_R; - if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonZR]) CurrentButton |= HidControllerButtons.KEY_ZR; + if (Keyboard[(Key)Config.JoyConKeyboard.Right.StickButton]) CurrentButton |= HidControllerButtons.KEY_RSTICK; + if (Keyboard[(Key)Config.JoyConKeyboard.Right.ButtonA]) CurrentButton |= HidControllerButtons.KEY_A; + if (Keyboard[(Key)Config.JoyConKeyboard.Right.ButtonB]) CurrentButton |= HidControllerButtons.KEY_B; + if (Keyboard[(Key)Config.JoyConKeyboard.Right.ButtonX]) CurrentButton |= HidControllerButtons.KEY_X; + if (Keyboard[(Key)Config.JoyConKeyboard.Right.ButtonY]) CurrentButton |= HidControllerButtons.KEY_Y; + if (Keyboard[(Key)Config.JoyConKeyboard.Right.ButtonPlus]) CurrentButton |= HidControllerButtons.KEY_PLUS; + if (Keyboard[(Key)Config.JoyConKeyboard.Right.ButtonR]) CurrentButton |= HidControllerButtons.KEY_R; + if (Keyboard[(Key)Config.JoyConKeyboard.Right.ButtonZR]) CurrentButton |= HidControllerButtons.KEY_ZR; } //Controller Input @@ -198,60 +210,43 @@ namespace Ryujinx { GamePadState gamePad = GamePad.GetState(Config.GamePad_Index); - //RightButtons - if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_A) - == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_A; - if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_B) - == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_B; - if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_X) - == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_X; - if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_Y) - == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_Y; - if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadStick_Button) - == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_RSTICK; - if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_Plus) - == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_PLUS; - if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_R) - == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_R; - if (getGamePadTriggerFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadTrigger_ZR) - >= 0.5) CurrentButton |= HidControllerButtons.KEY_ZR; - //LeftButtons - if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadDPad_Up) - == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_DUP; - if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadDPad_Down) - == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_DDOWN; - if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadDPad_Left) - == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_DLEFT; - if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadDPad_Right) - == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_DRIGHT; - if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadStick_Button) - == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_LSTICK; - if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadButton_Minus) - == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_MINUS; - if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadButton_L) - == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_L; - if (getGamePadTriggerFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadTrigger_ZL) - >= 0.5) CurrentButton |= HidControllerButtons.KEY_ZL; + 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.DPadLeft)) CurrentButton |= HidControllerButtons.KEY_DLEFT; + 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.ButtonMinus)) CurrentButton |= HidControllerButtons.KEY_MINUS; + if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Left.ButtonL)) CurrentButton |= HidControllerButtons.KEY_L; + if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Left.ButtonZL)) CurrentButton |= HidControllerButtons.KEY_ZL; - //RightJoystick - - if (getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).X >= deadzone - || getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).X <= -deadzone) - RightJoystickDX = (int)(getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).X * short.MaxValue); - - if (getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).Y >= deadzone - || getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).Y <= -deadzone) - RightJoystickDY = (int)(getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).Y * short.MaxValue); + //RightButtons + 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.ButtonX)) CurrentButton |= HidControllerButtons.KEY_X; + 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.ButtonPlus)) CurrentButton |= HidControllerButtons.KEY_PLUS; + if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.ButtonR)) CurrentButton |= HidControllerButtons.KEY_R; + if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.ButtonZR)) CurrentButton |= HidControllerButtons.KEY_ZR; //LeftJoystick - if (getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).X >= deadzone - || getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).X <= -deadzone) - LeftJoystickDX = (int)(getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).X * short.MaxValue); + if (GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).X >= deadzone + || GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).X <= -deadzone) + LeftJoystickDX = (int)(GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).X * short.MaxValue); - if (getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).Y >= deadzone - || getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).Y <= -deadzone) - LeftJoystickDY = (int)(getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).Y * short.MaxValue); + if (GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).Y >= deadzone + || GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).Y <= -deadzone) + LeftJoystickDY = (int)(GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).Y * short.MaxValue); + + //RightJoystick + if (GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).X >= deadzone + || GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).X <= -deadzone) + RightJoystickDX = (int)(GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).X * short.MaxValue); + + if (GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).Y >= deadzone + || GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).Y <= -deadzone) + RightJoystickDY = (int)(GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).Y * short.MaxValue); } LeftJoystick = new HidJoystickPosition From 42c3bde419686538612b557d5ef09c05decb8e75 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Thu, 28 Jun 2018 17:26:29 -0500 Subject: [PATCH 11/22] Changes in compliance with review --- .../Hid}/JoyConController.cs | 2 +- .../Hid}/JoyConKeyboard.cs | 2 +- Ryujinx/Config.cs | 18 +-- Ryujinx/JoyConReal.cs | 8 -- Ryujinx/Ui/GLScreen.cs | 134 +++++++++--------- 5 files changed, 78 insertions(+), 86 deletions(-) rename {Ryujinx => Ryujinx.HLE/Hid}/JoyConController.cs (96%) rename {Ryujinx => Ryujinx.HLE/Hid}/JoyConKeyboard.cs (97%) delete mode 100644 Ryujinx/JoyConReal.cs diff --git a/Ryujinx/JoyConController.cs b/Ryujinx.HLE/Hid/JoyConController.cs similarity index 96% rename from Ryujinx/JoyConController.cs rename to Ryujinx.HLE/Hid/JoyConController.cs index d779abf432..9f8f6ddd9a 100644 --- a/Ryujinx/JoyConController.cs +++ b/Ryujinx.HLE/Hid/JoyConController.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace Ryujinx.Input +namespace Ryujinx.HLE.Input { public struct JoyConControllerLeft { diff --git a/Ryujinx/JoyConKeyboard.cs b/Ryujinx.HLE/Hid/JoyConKeyboard.cs similarity index 97% rename from Ryujinx/JoyConKeyboard.cs rename to Ryujinx.HLE/Hid/JoyConKeyboard.cs index 2d57b67a45..78e76e7f0c 100644 --- a/Ryujinx/JoyConKeyboard.cs +++ b/Ryujinx.HLE/Hid/JoyConKeyboard.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.Input +namespace Ryujinx.HLE.Input { public struct JoyConKeyboardLeft { diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index 022da24278..3fb4504b56 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -1,5 +1,5 @@ using OpenTK.Input; -using Ryujinx.Input; +using Ryujinx.HLE.Input; using Ryujinx.HLE.Logging; using System; using System.Collections.Generic; @@ -14,10 +14,10 @@ namespace Ryujinx public static JoyConKeyboard JoyConKeyboard { get; private set; } public static JoyConController JoyConController { get; private set; } - public static float GamePad_Deadzone; - public static bool GamePad_Enable; - public static int GamePad_Index; - public static float GamePad_Trigger_Threshold; + public static float GamePadDeadzone; + public static bool GamePadEnable; + public static int GamePadIndex; + public static float GamePadTriggerThreshold; 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.Error, Convert.ToBoolean(Parser.Value("Logging_Enable_Error"))); - 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")); - GamePad_Trigger_Threshold = (float)Convert.ToDouble (Parser.Value("GamePad_Trigger_Threshold")); + GamePadEnable = Convert.ToBoolean(Parser.Value("GamePad_Enable")); + GamePadIndex = Convert.ToInt32 (Parser.Value("GamePad_Index")); + GamePadDeadzone = (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone")); + GamePadTriggerThreshold = (float)Convert.ToDouble (Parser.Value("GamePad_Trigger_Threshold")); string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries); diff --git a/Ryujinx/JoyConReal.cs b/Ryujinx/JoyConReal.cs deleted file mode 100644 index 9851bb497e..0000000000 --- a/Ryujinx/JoyConReal.cs +++ /dev/null @@ -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. -} diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index f042bdc45d..fde1971192 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -45,112 +45,112 @@ namespace Ryujinx 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 { - 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": - result = gamePad.Buttons.A; + result = GamePad.Buttons.A; break; case "B": - result = gamePad.Buttons.B; + result = GamePad.Buttons.B; break; case "X": - result = gamePad.Buttons.X; + result = GamePad.Buttons.X; break; case "Y": - result = gamePad.Buttons.Y; + result = GamePad.Buttons.Y; break; case "LStick": - result = gamePad.Buttons.LeftStick; + result = GamePad.Buttons.LeftStick; break; case "RStick": - result = gamePad.Buttons.RightStick; + result = GamePad.Buttons.RightStick; break; case "LShoulder": - result = gamePad.Buttons.LeftShoulder; + result = GamePad.Buttons.LeftShoulder; break; case "RShoulder": - result = gamePad.Buttons.RightShoulder; + result = GamePad.Buttons.RightShoulder; break; case "DPadUp": - result = gamePad.DPad.Up; + result = GamePad.DPad.Up; break; case "DPadDown": - result = gamePad.DPad.Down; + result = GamePad.DPad.Down; break; case "DPadLeft": - result = gamePad.DPad.Left; + result = GamePad.DPad.Left; break; case "DPadRight": - result = gamePad.DPad.Right; + result = GamePad.DPad.Right; break; case "Start": - result = gamePad.Buttons.Start; + result = GamePad.Buttons.Start; break; case "Back": - result = gamePad.Buttons.Back; + result = GamePad.Buttons.Back; break; default: - Console.Error.WriteLine("Invalid Button Mapping \"" + str + "\"! Defaulting to Button A."); + Console.Error.WriteLine("Invalid Button Mapping \"" + Button + "\"! Defaulting to Button A."); break; } 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": - result = gamePad.Triggers.Left; + Result = GamePad.Triggers.Left; break; case "RTrigger": - result = gamePad.Triggers.Right; + Result = GamePad.Triggers.Right; break; default: - Console.Error.WriteLine("Invalid Trigger Mapping \"" + str + "\"! Defaulting to 0."); + Console.Error.WriteLine("Invalid Trigger Mapping \"" + Trigger + "\"! Defaulting to 0."); 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": - result = gamePad.ThumbSticks.Left; + Result = GamePad.ThumbSticks.Left; break; 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; 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; } - return result; + return Result; } protected override void OnUpdateFrame(FrameEventArgs e) @@ -163,7 +163,7 @@ namespace Ryujinx int LeftJoystickDY = 0; int RightJoystickDX = 0; int RightJoystickDY = 0; - float deadzone = Config.GamePad_Deadzone; + float AnalogStickDeadzone = Config.GamePadDeadzone; //Keyboard Input if (Keyboard.HasValue) @@ -206,47 +206,47 @@ namespace Ryujinx } //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 - 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.DPadLeft)) CurrentButton |= HidControllerButtons.KEY_DLEFT; - 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.ButtonMinus)) CurrentButton |= HidControllerButtons.KEY_MINUS; - 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.DPadUp)) CurrentButton |= HidControllerButtons.KEY_DUP; + 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.DPadRight)) CurrentButton |= HidControllerButtons.KEY_DRIGHT; + 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.ButtonL)) CurrentButton |= HidControllerButtons.KEY_L; + if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.ButtonZL)) CurrentButton |= HidControllerButtons.KEY_ZL; //RightButtons - 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.ButtonX)) CurrentButton |= HidControllerButtons.KEY_X; - 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.ButtonPlus)) CurrentButton |= HidControllerButtons.KEY_PLUS; - 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.ButtonA)) CurrentButton |= HidControllerButtons.KEY_A; + 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.ButtonY)) CurrentButton |= HidControllerButtons.KEY_Y; + 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.ButtonR)) CurrentButton |= HidControllerButtons.KEY_R; + if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Right.ButtonZR)) CurrentButton |= HidControllerButtons.KEY_ZR; //LeftJoystick - if (GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).X >= deadzone - || GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).X <= -deadzone) - LeftJoystickDX = (int)(GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).X * 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).Y >= deadzone - || GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).Y <= -deadzone) - LeftJoystickDY = (int)(GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).Y * 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).X >= deadzone - || GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).X <= -deadzone) - RightJoystickDX = (int)(GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).X * 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).Y >= deadzone - || GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).Y <= -deadzone) - RightJoystickDY = (int)(GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).Y * 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 From 6a4cabba1e403150b2349d928b653ad498952f7a Mon Sep 17 00:00:00 2001 From: John Clemis Date: Thu, 28 Jun 2018 17:47:05 -0500 Subject: [PATCH 12/22] Changes in compliance with review --- Ryujinx/Config.cs | 2 +- Ryujinx/Ui/GLScreen.cs | 32 +++++++++---------- .../Hid => Ryujinx/Ui}/JoyConController.cs | 2 +- .../Hid => Ryujinx/Ui}/JoyConKeyboard.cs | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) rename {Ryujinx.HLE/Hid => Ryujinx/Ui}/JoyConController.cs (96%) rename {Ryujinx.HLE/Hid => Ryujinx/Ui}/JoyConKeyboard.cs (97%) diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index 3fb4504b56..7aeaeed061 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -1,5 +1,5 @@ using OpenTK.Input; -using Ryujinx.HLE.Input; +using Ryujinx.UI.Input; using Ryujinx.HLE.Logging; using System; using System.Collections.Generic; diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index fde1971192..6698ad40fc 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -59,58 +59,58 @@ namespace Ryujinx 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 (Button) { case "A": - result = GamePad.Buttons.A; + Result = GamePad.Buttons.A; break; case "B": - result = GamePad.Buttons.B; + Result = GamePad.Buttons.B; break; case "X": - result = GamePad.Buttons.X; + Result = GamePad.Buttons.X; break; case "Y": - result = GamePad.Buttons.Y; + Result = GamePad.Buttons.Y; break; case "LStick": - result = GamePad.Buttons.LeftStick; + Result = GamePad.Buttons.LeftStick; break; case "RStick": - result = GamePad.Buttons.RightStick; + Result = GamePad.Buttons.RightStick; break; case "LShoulder": - result = GamePad.Buttons.LeftShoulder; + Result = GamePad.Buttons.LeftShoulder; break; case "RShoulder": - result = GamePad.Buttons.RightShoulder; + Result = GamePad.Buttons.RightShoulder; break; case "DPadUp": - result = GamePad.DPad.Up; + Result = GamePad.DPad.Up; break; case "DPadDown": - result = GamePad.DPad.Down; + Result = GamePad.DPad.Down; break; case "DPadLeft": - result = GamePad.DPad.Left; + Result = GamePad.DPad.Left; break; case "DPadRight": - result = GamePad.DPad.Right; + Result = GamePad.DPad.Right; break; case "Start": - result = GamePad.Buttons.Start; + Result = GamePad.Buttons.Start; break; case "Back": - result = GamePad.Buttons.Back; + Result = GamePad.Buttons.Back; break; default: Console.Error.WriteLine("Invalid Button Mapping \"" + Button + "\"! Defaulting to Button A."); break; } - return result; + return Result; } private float GetGamePadTriggerFromString(GamePadState GamePad, string Trigger) diff --git a/Ryujinx.HLE/Hid/JoyConController.cs b/Ryujinx/Ui/JoyConController.cs similarity index 96% rename from Ryujinx.HLE/Hid/JoyConController.cs rename to Ryujinx/Ui/JoyConController.cs index 9f8f6ddd9a..e525017d3e 100644 --- a/Ryujinx.HLE/Hid/JoyConController.cs +++ b/Ryujinx/Ui/JoyConController.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace Ryujinx.HLE.Input +namespace Ryujinx.UI.Input { public struct JoyConControllerLeft { diff --git a/Ryujinx.HLE/Hid/JoyConKeyboard.cs b/Ryujinx/Ui/JoyConKeyboard.cs similarity index 97% rename from Ryujinx.HLE/Hid/JoyConKeyboard.cs rename to Ryujinx/Ui/JoyConKeyboard.cs index 78e76e7f0c..b329d9ecd1 100644 --- a/Ryujinx.HLE/Hid/JoyConKeyboard.cs +++ b/Ryujinx/Ui/JoyConKeyboard.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.Input +namespace Ryujinx.UI.Input { public struct JoyConKeyboardLeft { From d0be618495f12c30eb8009db87555b32512183fb Mon Sep 17 00:00:00 2001 From: John Clemis Date: Thu, 28 Jun 2018 18:22:40 -0500 Subject: [PATCH 13/22] Fixed problems in the configuration file with different regions --- Ryujinx/Config.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index 7aeaeed061..7570d410b0 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -37,8 +37,10 @@ namespace Ryujinx GamePadEnable = Convert.ToBoolean(Parser.Value("GamePad_Enable")); GamePadIndex = Convert.ToInt32 (Parser.Value("GamePad_Index")); - GamePadDeadzone = (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone")); - GamePadTriggerThreshold = (float)Convert.ToDouble (Parser.Value("GamePad_Trigger_Threshold")); + GamePadDeadzone = (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone"), + System.Globalization.CultureInfo.InvariantCulture); // Remember to use Invariant Culture when dealing with parsing doubles. + GamePadTriggerThreshold = (float)Convert.ToDouble (Parser.Value("GamePad_Trigger_Threshold"), + System.Globalization.CultureInfo.InvariantCulture); string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries); From ab5badcf3ff7d554738285a94471c351b064b9bd Mon Sep 17 00:00:00 2001 From: John Clemis Date: Thu, 28 Jun 2018 19:09:10 -0500 Subject: [PATCH 14/22] Changes in compliance with review --- Ryujinx/Config.cs | 18 +++---- Ryujinx/Ui/GLScreen.cs | 119 +++++++++++------------------------------ 2 files changed, 40 insertions(+), 97 deletions(-) diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index 7570d410b0..940753ba53 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -1,7 +1,7 @@ -using OpenTK.Input; -using Ryujinx.UI.Input; +using Ryujinx.UI.Input; using Ryujinx.HLE.Logging; using System; +using System.Globalization; using System.Collections.Generic; using System.IO; using System.Linq; @@ -14,10 +14,10 @@ namespace Ryujinx public static JoyConKeyboard JoyConKeyboard { get; private set; } public static JoyConController JoyConController { get; private set; } - public static float GamePadDeadzone; - public static bool GamePadEnable; - public static int GamePadIndex; - public static float GamePadTriggerThreshold; + public static float GamePadDeadzone { get; private set; } + public static bool GamePadEnable { get; private set; } + public static int GamePadIndex { get; private set; } + public static float GamePadTriggerThreshold { get; private set; } public static void Read(Logger Log) { @@ -37,10 +37,8 @@ namespace Ryujinx GamePadEnable = Convert.ToBoolean(Parser.Value("GamePad_Enable")); GamePadIndex = Convert.ToInt32 (Parser.Value("GamePad_Index")); - GamePadDeadzone = (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone"), - System.Globalization.CultureInfo.InvariantCulture); // Remember to use Invariant Culture when dealing with parsing doubles. - GamePadTriggerThreshold = (float)Convert.ToDouble (Parser.Value("GamePad_Trigger_Threshold"), - System.Globalization.CultureInfo.InvariantCulture); + GamePadDeadzone = (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone"), CultureInfo.InvariantCulture); + GamePadTriggerThreshold = (float)Convert.ToDouble (Parser.Value("GamePad_Trigger_Threshold"), CultureInfo.InvariantCulture); string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries); diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index 6698ad40fc..7a4e42e9e2 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -47,7 +47,7 @@ namespace Ryujinx 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; } @@ -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) + switch (Button.ToUpper()) { - case "A": - Result = GamePad.Buttons.A; - break; - case "B": - Result = GamePad.Buttons.B; - break; - case "X": - Result = GamePad.Buttons.X; - break; - case "Y": - Result = GamePad.Buttons.Y; - break; - case "LStick": - Result = GamePad.Buttons.LeftStick; - break; - 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; + case "A": return GamePad.Buttons.A; + case "B": return GamePad.Buttons.B; + case "X": return GamePad.Buttons.X; + case "Y": return GamePad.Buttons.Y; + case "LSTICK": return GamePad.Buttons.LeftStick; + case "RSTICK": return GamePad.Buttons.RightStick; + case "LSHOULDER": return GamePad.Buttons.LeftShoulder; + case "RSHOULDER": return GamePad.Buttons.RightShoulder; + case "DPADUP": return GamePad.DPad.Up; + case "DPADDOWN": return GamePad.DPad.Down; + case "DPADLEFT": return GamePad.DPad.Left; + case "DPADRIGHT": return GamePad.DPad.Right; + case "START": return GamePad.Buttons.Start; + case "BACK": return GamePad.Buttons.Back; + default: throw new ArgumentException(); } - - return Result; } private float GetGamePadTriggerFromString(GamePadState GamePad, string Trigger) { - float Result = 0; - - switch (Trigger) + switch (Trigger.ToUpper()) { - case "LTrigger": - Result = GamePad.Triggers.Left; - break; - case "RTrigger": - Result = GamePad.Triggers.Right; - break; - default: - Console.Error.WriteLine("Invalid Trigger Mapping \"" + Trigger + "\"! Defaulting to 0."); - break; + case "LTRIGGER": return GamePad.Triggers.Left; + case "RTRIGGER": return GamePad.Triggers.Right; + default: throw new ArgumentException(); } - - return Result; } private Vector2 GetJoystickAxisFromString(GamePadState GamePad, string Joystick) { - Vector2 Result = new Vector2(0, 0); - - switch (Joystick) + switch (Joystick.ToUpper()) { - case "LJoystick": - Result = GamePad.ThumbSticks.Left; - break; - 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; + case "LJOYSTICK": return GamePad.ThumbSticks.Left; + case "RJOYSTICK": return new Vector2(-GamePad.ThumbSticks.Right.Y, -GamePad.ThumbSticks.Right.X); + default: throw new ArgumentException(); } - - return Result; } protected override void OnUpdateFrame(FrameEventArgs e) { HidControllerButtons CurrentButton = 0; - HidJoystickPosition LeftJoystick; - HidJoystickPosition RightJoystick; + HidJoystickPosition LeftJoystick; + HidJoystickPosition RightJoystick; - int LeftJoystickDX = 0; - int LeftJoystickDY = 0; - int RightJoystickDX = 0; - int RightJoystickDY = 0; + int LeftJoystickDX = 0; + int LeftJoystickDY = 0; + int RightJoystickDX = 0; + int RightJoystickDY = 0; float AnalogStickDeadzone = Config.GamePadDeadzone; //Keyboard Input @@ -209,7 +155,6 @@ namespace Ryujinx if (Config.GamePadEnable) { GamePadState GamePad = OpenTK.Input.GamePad.GetState(Config.GamePadIndex); - //LeftButtons if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.DPadUp)) CurrentButton |= HidControllerButtons.KEY_DUP; if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.DPadDown)) CurrentButton |= HidControllerButtons.KEY_DDOWN; From b65833448525ee67b11d121ca43ca703970c61d6 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Sat, 14 Jul 2018 14:32:04 -0500 Subject: [PATCH 15/22] Add mapping per Axis + An attempt to fix peoples problems with the Keyboard input acting up with Controller Input enabled. --- Ryujinx/Config.cs | 6 ++- Ryujinx/Ryujinx.conf | 8 ++-- Ryujinx/Ui/GLScreen.cs | 67 ++++++++++++++++++++++++---------- Ryujinx/Ui/JoyConController.cs | 6 ++- 4 files changed, 61 insertions(+), 26 deletions(-) diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index 940753ba53..d96956053c 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -107,7 +107,8 @@ namespace Ryujinx { Left = new JoyConControllerLeft { - Stick = Parser.Value("Controls_Left_JoyConController_Stick"), + Stick_AxisX = Parser.Value("Controls_Left_JoyConController_Stick_AxisX"), + Stick_AxisY = Parser.Value("Controls_Left_JoyConController_Stick_AxisY"), StickButton = Parser.Value("Controls_Left_JoyConController_Stick_Button"), DPadUp = Parser.Value("Controls_Left_JoyConController_DPad_Up"), DPadDown = Parser.Value("Controls_Left_JoyConController_DPad_Down"), @@ -120,7 +121,8 @@ namespace Ryujinx Right = new JoyConControllerRight { - Stick = Parser.Value("Controls_Right_JoyConController_Stick"), + Stick_AxisX = Parser.Value("Controls_Right_JoyConController_Stick_AxisX"), + Stick_AxisY = Parser.Value("Controls_Right_JoyConController_Stick_AxisY"), 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 59f7f859e7..0aec5ed2c7 100644 --- a/Ryujinx/Ryujinx.conf +++ b/Ryujinx/Ryujinx.conf @@ -58,7 +58,7 @@ Controls_Right_JoyConKeyboard_Button_Plus = 121 Controls_Right_JoyConKeyboard_Button_R = 103 Controls_Right_JoyConKeyboard_Button_ZR = 97 -#Controller Controls +#Controller Controls (The default configuration is what works for a PS4 Controller using DS4 Windows) Controls_Left_JoyConController_Stick_Button = LStick Controls_Left_JoyConController_DPad_Up = DPadUp @@ -78,5 +78,7 @@ Controls_Right_JoyConController_Button_Plus = Start Controls_Right_JoyConController_Button_R = RShoulder Controls_Right_JoyConController_Button_ZR = RTrigger -Controls_Left_JoyConController_Stick = LJoystick -Controls_Right_JoyConController_Stick = RJoystick \ No newline at end of file +Controls_Left_JoyConController_Stick_AxisX = JoystickAxis0 +Controls_Left_JoyConController_Stick_AxisY = JoystickAxis1 +Controls_Right_JoyConController_Stick_AxisX = -JoystickAxis3 +Controls_Right_JoyConController_Stick_AxisY = -JoystickAxis2 diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index 9b5dda4f0c..856ff67352 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -174,13 +174,41 @@ namespace Ryujinx } } - private Vector2 GetJoystickAxisFromString(GamePadState GamePad, string Joystick) + private float GetJoystickAxisFromString(GamePadState GamePad, string Joystick) { switch (Joystick.ToUpper()) { - case "LJOYSTICK": return GamePad.ThumbSticks.Left; - case "RJOYSTICK": return new Vector2(-GamePad.ThumbSticks.Right.Y, -GamePad.ThumbSticks.Right.X); - default: throw new ArgumentException(); + 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; } } @@ -194,10 +222,9 @@ namespace Ryujinx int LeftJoystickDY = 0; int RightJoystickDX = 0; int RightJoystickDY = 0; - float AnalogStickDeadzone = Config.GamePadDeadzone; //Keyboard Input - if (Keyboard.HasValue) + if (Keyboard.HasValue && !IsGamePadActive(Config.GamePadIndex)) { KeyboardState Keyboard = this.Keyboard.Value; @@ -237,9 +264,11 @@ namespace Ryujinx } //Controller Input - if (Config.GamePadEnable) + if (Config.GamePadEnable && !Keyboard.HasValue && IsGamePadActive(Config.GamePadIndex)) { 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; @@ -261,22 +290,22 @@ namespace Ryujinx if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Right.ButtonZR)) CurrentButton |= HidControllerButtons.KEY_ZR; //LeftJoystick - 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_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).Y >= AnalogStickDeadzone - || GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).Y <= -AnalogStickDeadzone) - LeftJoystickDY = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).Y * 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); //RightJoystick - 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_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).Y >= AnalogStickDeadzone - || GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).Y <= -AnalogStickDeadzone) - RightJoystickDY = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).Y * 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); } LeftJoystick = new HidJoystickPosition diff --git a/Ryujinx/Ui/JoyConController.cs b/Ryujinx/Ui/JoyConController.cs index e525017d3e..b212dd0e5d 100644 --- a/Ryujinx/Ui/JoyConController.cs +++ b/Ryujinx/Ui/JoyConController.cs @@ -6,7 +6,8 @@ namespace Ryujinx.UI.Input { public struct JoyConControllerLeft { - public string Stick; + public string Stick_AxisX; + public string Stick_AxisY; public string StickButton; public string DPadUp; public string DPadDown; @@ -19,7 +20,8 @@ namespace Ryujinx.UI.Input public struct JoyConControllerRight { - public string Stick; + public string Stick_AxisX; + public string Stick_AxisY; public string StickButton; public string ButtonA; public string ButtonB; From acc89a5d2ef87d8cde541bfb0dc251830820e9c7 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Tue, 17 Jul 2018 20:11:28 -0500 Subject: [PATCH 16/22] Address Feedback --- Ryujinx/Ui/GLScreen.cs | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index 856ff67352..6306c32c3b 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -186,29 +186,7 @@ namespace Ryujinx 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; + default: throw new ArgumentException(nameof(Joystick)); } } @@ -224,7 +202,7 @@ namespace Ryujinx int RightJoystickDY = 0; //Keyboard Input - if (Keyboard.HasValue && !IsGamePadActive(Config.GamePadIndex)) + if (Keyboard.HasValue) { KeyboardState Keyboard = this.Keyboard.Value; @@ -264,7 +242,7 @@ 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; From 8519992473fd0488fe88e7ea4ade6ce86f29d1b7 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Tue, 17 Jul 2018 20:18:50 -0500 Subject: [PATCH 17/22] Address Feedback --- Ryujinx/Ui/GLScreen.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index 6306c32c3b..e063fd9920 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -160,7 +160,7 @@ namespace Ryujinx case "DPADRIGHT": return GamePad.DPad.Right; case "START": return GamePad.Buttons.Start; case "BACK": return GamePad.Buttons.Back; - default: throw new ArgumentException(); + default: throw new ArgumentException(); } } @@ -170,7 +170,7 @@ namespace Ryujinx { case "LTRIGGER": return GamePad.Triggers.Left; case "RTRIGGER": return GamePad.Triggers.Right; - default: throw new ArgumentException(); + default: throw new ArgumentException(); } } @@ -186,7 +186,7 @@ namespace Ryujinx 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(nameof(Joystick)); + default: throw new ArgumentException(nameof(Joystick)); } } From c4c414dd654ba6b56eac4b87b5d13781ef14fc30 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Wed, 8 Aug 2018 20:57:05 -0500 Subject: [PATCH 18/22] Revert "Address Feedback" This reverts commit 8519992473fd0488fe88e7ea4ade6ce86f29d1b7. --- Ryujinx/Ui/GLScreen.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index e063fd9920..6306c32c3b 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -160,7 +160,7 @@ namespace Ryujinx case "DPADRIGHT": return GamePad.DPad.Right; case "START": return GamePad.Buttons.Start; case "BACK": return GamePad.Buttons.Back; - default: throw new ArgumentException(); + default: throw new ArgumentException(); } } @@ -170,7 +170,7 @@ namespace Ryujinx { case "LTRIGGER": return GamePad.Triggers.Left; case "RTRIGGER": return GamePad.Triggers.Right; - default: throw new ArgumentException(); + default: throw new ArgumentException(); } } @@ -186,7 +186,7 @@ namespace Ryujinx 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(nameof(Joystick)); + default: throw new ArgumentException(nameof(Joystick)); } } From bdeebf59d80a0caf2f8a4401d83fbed19152ea00 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Wed, 8 Aug 2018 20:57:10 -0500 Subject: [PATCH 19/22] Revert "Address Feedback" This reverts commit acc89a5d2ef87d8cde541bfb0dc251830820e9c7. --- Ryujinx/Ui/GLScreen.cs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index 6306c32c3b..856ff67352 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -186,7 +186,29 @@ namespace Ryujinx 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(nameof(Joystick)); + 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; } } @@ -202,7 +224,7 @@ namespace Ryujinx int RightJoystickDY = 0; //Keyboard Input - if (Keyboard.HasValue) + if (Keyboard.HasValue && !IsGamePadActive(Config.GamePadIndex)) { KeyboardState Keyboard = this.Keyboard.Value; @@ -242,7 +264,7 @@ namespace Ryujinx } //Controller Input - if (Config.GamePadEnable) + if (Config.GamePadEnable && !Keyboard.HasValue && IsGamePadActive(Config.GamePadIndex)) { GamePadState GamePad = OpenTK.Input.GamePad.GetState(Config.GamePadIndex); float AnalogStickDeadzone = Config.GamePadDeadzone; From 1803b91e49d1db0785598ab0cf3a586839f620d0 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Wed, 8 Aug 2018 20:57:41 -0500 Subject: [PATCH 20/22] Revert "Add mapping per Axis" This reverts commit b65833448525ee67b11d121ca43ca703970c61d6. --- Ryujinx/Config.cs | 6 +-- Ryujinx/Ryujinx.conf | 8 ++-- Ryujinx/Ui/GLScreen.cs | 67 ++++++++++------------------------ Ryujinx/Ui/JoyConController.cs | 6 +-- 4 files changed, 26 insertions(+), 61 deletions(-) diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index f8f2243f4b..0f346122af 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 4d5fc0b889..063bb2de4e 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 856ff67352..9b5dda4f0c 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 b212dd0e5d..e525017d3e 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; From 15ece494b1defe6453f591938a544d9df1adcd39 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Fri, 10 Aug 2018 00:21:43 -0500 Subject: [PATCH 21/22] Initial Multiplayer Support --- CONFIG.md | 64 +++-- README.md | 14 +- Ryujinx.HLE/Hid/Hid.cs | 135 ++++++++++- Ryujinx.HLE/Hid/HidEmulatedDevices.cs | 25 ++ Ryujinx/Config.cs | 93 +++++-- Ryujinx/Ryujinx.conf | 80 +++--- Ryujinx/Ui/GLScreen.cs | 334 +++++++++++++++++++++++--- 7 files changed, 620 insertions(+), 125 deletions(-) create mode 100644 Ryujinx.HLE/Hid/HidEmulatedDevices.cs diff --git a/CONFIG.md b/CONFIG.md index b5de9fa6dc..6978f95c6e 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -46,6 +46,23 @@ Whether or not to enable Controller Support. +- `Handheld_Device` *(String)* + + The specific Device to be the Emulated Handheld Device. + +- `Player(1-8)_Device` *(String)* + + The specific Device to be the Emulated Player(1-8) Device. + +- `PlayerUnknown_Device` *(String)* + + The specific Device to be the Emulated PlayerUnknown Device. (This should basically always be None) + +- Valid Emulated Device Mappings + - None = Disabled + - Keyboard = The Keyboard Device + - GamePad_X = X GamePad Configuration + - `Controls_Left_JoyConKeyboard_XX` *(int)* ``` Controls_Left_JoyConKeyboard_Stick_Up (int) @@ -64,7 +81,7 @@ Keys of the Left Emulated Joycon, the values depend of the [OpenTK Enum Keys](https://github.com/opentk/opentk/blob/develop/src/OpenTK/Input/Key.cs). - OpenTK use a QWERTY layout, so pay attention if you use another Keyboard Layout. + OpenTK uses a QWERTY layout, so pay attention if you use another Keyboard Layout. Ex: `Controls_Left_JoyConKeyboard_Button_Minus = 52` > Tab key (All Layout). @@ -86,36 +103,39 @@ Keys of the right Emulated Joycon, the values depend of the [OpenTK Enum Keys](https://github.com/opentk/opentk/blob/develop/src/OpenTK/Input/Key.cs). - OpenTK use a QWERTY layout, so pay attention if you use another Keyboard Layout. + OpenTK uses a QWERTY layout, so pay attention if you use another Keyboard Layout. Ex: `Controls_Right_JoyConKeyboard_Button_A = 83` > A key (QWERTY Layout) / Q key (AZERTY Layout). -- `Controls_Left_JoyConController_XX` *(String)* +- `X_Controls_Left_JoyConController_XX` *(String)* ``` - Controls_Left_JoyConController_Stick (String) - Controls_Left_JoyConController_Stick_Button (String) - Controls_Left_JoyConController_DPad_Up (String) - Controls_Left_JoyConController_DPad_Down (String) - Controls_Left_JoyConController_DPad_Left (String) - Controls_Left_JoyConController_DPad_Right (String) - Controls_Left_JoyConController_Button_Minus (String) - Controls_Left_JoyConController_Button_L (String) - Controls_Left_JoyConController_Button_ZL (String) + X_Controls_Left_JoyConController_Stick (String) + X_Controls_Left_JoyConController_Stick_Button (String) + X_Controls_Left_JoyConController_DPad_Up (String) + X_Controls_Left_JoyConController_DPad_Down (String) + X_Controls_Left_JoyConController_DPad_Left (String) + X_Controls_Left_JoyConController_DPad_Right (String) + X_Controls_Left_JoyConController_Button_Minus (String) + X_Controls_Left_JoyConController_Button_L (String) + X_Controls_Left_JoyConController_Button_ZL (String) ``` -- `Controls_Right_JoyConController_XX` *(String)* +- `X_Controls_Right_JoyConController_XX` *(String)* ``` - Controls_Right_JoyConController_Stick (String) - Controls_Right_JoyConController_Stick_Button (String) - Controls_Right_JoyConController_Button_A (String) - Controls_Right_JoyConController_Button_B (String) - Controls_Right_JoyConController_Button_X (String) - Controls_Right_JoyConController_Button_Y (String) - Controls_Right_JoyConController_Button_Plus (String) - Controls_Right_JoyConController_Button_R (String) - Controls_Right_JoyConController_Button_ZR (String) + X_Controls_Right_JoyConController_Stick (String) + X_Controls_Right_JoyConController_Stick_Button (String) + X_Controls_Right_JoyConController_Button_A (String) + X_Controls_Right_JoyConController_Button_B (String) + X_Controls_Right_JoyConController_Button_X (String) + X_Controls_Right_JoyConController_Button_Y (String) + X_Controls_Right_JoyConController_Button_Plus (String) + X_Controls_Right_JoyConController_Button_R (String) + X_Controls_Right_JoyConController_Button_ZR (String) ``` + The "X" is the Controller Configuration Number, to add more configurations, copy the first configuration, then increment the Number "X" + change the Button Configuration as you wish. + - Valid Button Mappings - A = The A / Cross Button - B = The B / Circle Button diff --git a/README.md b/README.md index f6bac98c8c..8353db8586 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Experimental Switch emulator written in C# -Don't expect much from this. Some homebrew apps work, Puyo Puyo Tetris shows the intro logo (sometimes), and a handful of games boot / work; but that's about it for now. +Don't expect much from this. Some homebrew apps work, a handful of games boot / work; but that's about it for now. Contributions are always welcome. **Building** @@ -15,10 +15,10 @@ Or just drag'n'drop the *.NRO / *.NSO or the game folder on the executable if yo **Features** - - Audio is partially supported (glitched) on Windows but you need to install the OpenAL Core SDK. + - Audio is supported on Windows, but you need to install the OpenAL Core SDK. https://openal.org/downloads/OpenAL11CoreSDK.zip - - Keyboard Input is partially supported: + - Keyboard Input is supported: - Left Joycon: - Stick Up = W - Stick Down = S @@ -48,7 +48,7 @@ https://openal.org/downloads/OpenAL11CoreSDK.zip - ZR = O - For more information on how to configure these buttons see [CONFIG.md](CONFIG.md) - - Controller Input is partially supported: + - Controller Input is supported: - Left Joycon: - Analog Stick = Left Analog Stick - DPad Up = DPad Up @@ -69,7 +69,8 @@ https://openal.org/downloads/OpenAL11CoreSDK.zip - R = Right Shoulder Button - ZR = Right Trigger - For more information on how to configure these buttons see [CONFIG.md](CONFIG.md) - + - Multiple Players are supported. See [CONFIG.md](CONFIG.md) for more details. + - Config File: `Ryujinx.conf` should be present in executable folder. For more information [you can go here](CONFIG.md). @@ -95,9 +96,10 @@ Run `dotnet run -c Release -- path\to\game_exefs_and_romfs_folder` to run offici **Compatibility** -You can check out the compatibility list within the Wiki. Only a handful of games actually work. +You can check out the compatibility list within the Wiki. **Latest build** These builds are compiled automatically for each commit on the master branch. They may be unstable or might not work at all. The latest automatic build for Windows (64-bit) can be found on the [official website](https://ryujinx.org/#/Build). +However, for opening issues and testing, it is recommended to build the Master Branch as it is much more stable (Though still very experimental) diff --git a/Ryujinx.HLE/Hid/Hid.cs b/Ryujinx.HLE/Hid/Hid.cs index 43c040bb5d..752117f8bd 100644 --- a/Ryujinx.HLE/Hid/Hid.cs +++ b/Ryujinx.HLE/Hid/Hid.cs @@ -2,6 +2,7 @@ using Ryujinx.HLE.Logging; using Ryujinx.HLE.OsHle; using Ryujinx.HLE.OsHle.Handles; +using Ryujinx; using System; namespace Ryujinx.HLE.Input @@ -111,26 +112,148 @@ namespace Ryujinx.HLE.Input private void Init(AMemory Memory, long Position) { - InitializeJoyconPair( + if (HidEmulatedDevices.Devices.Handheld != -2) + { + InitializeJoyconPair( Memory, Position, + HidControllerId.CONTROLLER_HANDHELD, + HidControllerType.ControllerType_Handheld, JoyConColor.Body_Neon_Red, JoyConColor.Buttons_Neon_Red, JoyConColor.Body_Neon_Blue, JoyConColor.Buttons_Neon_Blue); + } + + if (HidEmulatedDevices.Devices.Player1 != -2) + { + InitializeJoyconPair( + Memory, + Position, + HidControllerId.CONTROLLER_PLAYER_1, + HidControllerType.ControllerType_JoyconPair, + JoyConColor.Body_Neon_Red, + JoyConColor.Buttons_Neon_Red, + JoyConColor.Body_Neon_Blue, + JoyConColor.Buttons_Neon_Blue); + } + + if (HidEmulatedDevices.Devices.Player2 != -2) + { + InitializeJoyconPair( + Memory, + Position, + HidControllerId.CONTROLLER_PLAYER_2, + HidControllerType.ControllerType_JoyconPair, + JoyConColor.Body_Neon_Red, + JoyConColor.Buttons_Neon_Red, + JoyConColor.Body_Neon_Blue, + JoyConColor.Buttons_Neon_Blue); + } + + if (HidEmulatedDevices.Devices.Player3 != -2) + { + InitializeJoyconPair( + Memory, + Position, + HidControllerId.CONTROLLER_PLAYER_3, + HidControllerType.ControllerType_JoyconPair, + JoyConColor.Body_Neon_Red, + JoyConColor.Buttons_Neon_Red, + JoyConColor.Body_Neon_Blue, + JoyConColor.Buttons_Neon_Blue); + } + + if (HidEmulatedDevices.Devices.Player4 != -2) + { + InitializeJoyconPair( + Memory, + Position, + HidControllerId.CONTROLLER_PLAYER_4, + HidControllerType.ControllerType_JoyconPair, + JoyConColor.Body_Neon_Red, + JoyConColor.Buttons_Neon_Red, + JoyConColor.Body_Neon_Blue, + JoyConColor.Buttons_Neon_Blue); + } + + if (HidEmulatedDevices.Devices.Player5 != -2) + { + InitializeJoyconPair( + Memory, + Position, + HidControllerId.CONTROLLER_PLAYER_5, + HidControllerType.ControllerType_JoyconPair, + JoyConColor.Body_Neon_Red, + JoyConColor.Buttons_Neon_Red, + JoyConColor.Body_Neon_Blue, + JoyConColor.Buttons_Neon_Blue); + } + + if (HidEmulatedDevices.Devices.Player6 != -2) + { + InitializeJoyconPair( + Memory, + Position, + HidControllerId.CONTROLLER_PLAYER_6, + HidControllerType.ControllerType_JoyconPair, + JoyConColor.Body_Neon_Red, + JoyConColor.Buttons_Neon_Red, + JoyConColor.Body_Neon_Blue, + JoyConColor.Buttons_Neon_Blue); + } + + if (HidEmulatedDevices.Devices.Player7 != -2) + { + InitializeJoyconPair( + Memory, + Position, + HidControllerId.CONTROLLER_PLAYER_7, + HidControllerType.ControllerType_JoyconPair, + JoyConColor.Body_Neon_Red, + JoyConColor.Buttons_Neon_Red, + JoyConColor.Body_Neon_Blue, + JoyConColor.Buttons_Neon_Blue); + } + + if (HidEmulatedDevices.Devices.Player8 != -2) + { + InitializeJoyconPair( + Memory, + Position, + HidControllerId.CONTROLLER_PLAYER_8, + HidControllerType.ControllerType_JoyconPair, + JoyConColor.Body_Neon_Red, + JoyConColor.Buttons_Neon_Red, + JoyConColor.Body_Neon_Blue, + JoyConColor.Buttons_Neon_Blue); + } + + if (HidEmulatedDevices.Devices.PlayerUnknown != -2) + { + InitializeJoyconPair( + Memory, + Position, + HidControllerId.CONTROLLER_UNKNOWN, + HidControllerType.ControllerType_JoyconPair, + JoyConColor.Body_Neon_Red, + JoyConColor.Buttons_Neon_Red, + JoyConColor.Body_Neon_Blue, + JoyConColor.Buttons_Neon_Blue); + } } private void InitializeJoyconPair( - AMemory Memory, - long Position, + AMemory Memory, + long Position, + HidControllerId ControllerId, + HidControllerType Type, JoyConColor LeftColorBody, JoyConColor LeftColorButtons, JoyConColor RightColorBody, JoyConColor RightColorButtons) { - long BaseControllerOffset = Position + HidControllersOffset + 8 * HidControllerSize; - - HidControllerType Type = HidControllerType.ControllerType_Handheld; + long BaseControllerOffset = Position + HidControllersOffset + (int)ControllerId * HidControllerSize; bool IsHalf = false; diff --git a/Ryujinx.HLE/Hid/HidEmulatedDevices.cs b/Ryujinx.HLE/Hid/HidEmulatedDevices.cs new file mode 100644 index 0000000000..a3e67cf437 --- /dev/null +++ b/Ryujinx.HLE/Hid/HidEmulatedDevices.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Ryujinx.HLE.Input +{ + public class HidEmulatedDevices + { + public struct EmulatedDevices + { + public int Handheld; + public int Player1; + public int Player2; + public int Player3; + public int Player4; + public int Player5; + public int Player6; + public int Player7; + public int Player8; + public int PlayerUnknown; + }; + + public static EmulatedDevices Devices; + } +} diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index 4ed35b3d7e..2a9b516e7b 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -1,5 +1,6 @@ using Ryujinx.UI.Input; using Ryujinx.HLE.Logging; +using Ryujinx.HLE.Input; using System; using System.Globalization; using System.Collections.Generic; @@ -11,8 +12,9 @@ namespace Ryujinx { public static class Config { - public static JoyConKeyboard JoyConKeyboard { get; private set; } - public static JoyConController JoyConController { get; private set; } + public static JoyConKeyboard JoyConKeyboard { get; private set; } + public static JoyConController[] JoyConControllers { get; private set; } + public static bool GamePadEnable { get; private set; } public static void Read(Logger Log) { @@ -34,6 +36,20 @@ namespace Ryujinx string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries); + GamePadEnable = Boolean.Parse(Parser.Value("GamePad_Enable")); + + //Device Mappings + HidEmulatedDevices.Devices.Handheld = ToEmulatedDevice(Parser.Value("Handheld_Device")); // -2: None, -1: Keyboard, Everything Else: GamePad Index + HidEmulatedDevices.Devices.Player1 = ToEmulatedDevice(Parser.Value("Player1_Device")); + HidEmulatedDevices.Devices.Player2 = ToEmulatedDevice(Parser.Value("Player2_Device")); + HidEmulatedDevices.Devices.Player3 = ToEmulatedDevice(Parser.Value("Player3_Device")); + HidEmulatedDevices.Devices.Player4 = ToEmulatedDevice(Parser.Value("Player4_Device")); + HidEmulatedDevices.Devices.Player5 = ToEmulatedDevice(Parser.Value("Player5_Device")); + HidEmulatedDevices.Devices.Player6 = ToEmulatedDevice(Parser.Value("Player6_Device")); + HidEmulatedDevices.Devices.Player7 = ToEmulatedDevice(Parser.Value("Player7_Device")); + HidEmulatedDevices.Devices.Player8 = ToEmulatedDevice(Parser.Value("Player8_Device")); + HidEmulatedDevices.Devices.PlayerUnknown = ToEmulatedDevice(Parser.Value("PlayerUnknown_Device")); + //When the classes are specified on the list, we only //enable the classes that are on the list. //So, first disable everything, then enable @@ -94,38 +110,51 @@ namespace Ryujinx ButtonZR = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_ZR")) }); - JoyConController = new JoyConController( - Convert.ToBoolean(Parser.Value("GamePad_Enable")), - Convert.ToInt32 (Parser.Value("GamePad_Index")), - (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone"), CultureInfo.InvariantCulture), - (float)Convert.ToDouble (Parser.Value("GamePad_Trigger_Threshold"), CultureInfo.InvariantCulture), + List JoyConControllerList = new List(); + + //Populate the Controller List + for (int i = 0; i < 255; ++i) + { + if (Parser.Value(i + "_GamePad_Index") == null) break; + + JoyConController Controller = new JoyConController( + Convert.ToBoolean(GamePadEnable), + Convert.ToInt32 (Parser.Value(i + "_GamePad_Index")), + (float)Convert.ToDouble (Parser.Value(i + "_GamePad_Deadzone"), CultureInfo.InvariantCulture), + (float)Convert.ToDouble (Parser.Value(i + "_GamePad_Trigger_Threshold"), CultureInfo.InvariantCulture), new JoyConControllerLeft { - Stick = ToID(Parser.Value("Controls_Left_JoyConController_Stick")), - StickButton = ToID(Parser.Value("Controls_Left_JoyConController_Stick_Button")), - DPadUp = ToID(Parser.Value("Controls_Left_JoyConController_DPad_Up")), - DPadDown = ToID(Parser.Value("Controls_Left_JoyConController_DPad_Down")), - DPadLeft = ToID(Parser.Value("Controls_Left_JoyConController_DPad_Left")), - DPadRight = ToID(Parser.Value("Controls_Left_JoyConController_DPad_Right")), - ButtonMinus = ToID(Parser.Value("Controls_Left_JoyConController_Button_Minus")), - ButtonL = ToID(Parser.Value("Controls_Left_JoyConController_Button_L")), - ButtonZL = ToID(Parser.Value("Controls_Left_JoyConController_Button_ZL")) + Stick = ToID(Parser.Value(i + "_Controls_Left_JoyConController_Stick")), + StickButton = ToID(Parser.Value(i + "_Controls_Left_JoyConController_Stick_Button")), + DPadUp = ToID(Parser.Value(i + "_Controls_Left_JoyConController_DPad_Up")), + DPadDown = ToID(Parser.Value(i + "_Controls_Left_JoyConController_DPad_Down")), + DPadLeft = ToID(Parser.Value(i + "_Controls_Left_JoyConController_DPad_Left")), + DPadRight = ToID(Parser.Value(i + "_Controls_Left_JoyConController_DPad_Right")), + ButtonMinus = ToID(Parser.Value(i + "_Controls_Left_JoyConController_Button_Minus")), + ButtonL = ToID(Parser.Value(i + "_Controls_Left_JoyConController_Button_L")), + ButtonZL = ToID(Parser.Value(i + "_Controls_Left_JoyConController_Button_ZL")) }, new JoyConControllerRight { - Stick = ToID(Parser.Value("Controls_Right_JoyConController_Stick")), - StickButton = ToID(Parser.Value("Controls_Right_JoyConController_Stick_Button")), - ButtonA = ToID(Parser.Value("Controls_Right_JoyConController_Button_A")), - ButtonB = ToID(Parser.Value("Controls_Right_JoyConController_Button_B")), - ButtonX = ToID(Parser.Value("Controls_Right_JoyConController_Button_X")), - ButtonY = ToID(Parser.Value("Controls_Right_JoyConController_Button_Y")), - ButtonPlus = ToID(Parser.Value("Controls_Right_JoyConController_Button_Plus")), - ButtonR = ToID(Parser.Value("Controls_Right_JoyConController_Button_R")), - ButtonZR = ToID(Parser.Value("Controls_Right_JoyConController_Button_ZR")) + Stick = ToID(Parser.Value(i + "_Controls_Right_JoyConController_Stick")), + StickButton = ToID(Parser.Value(i + "_Controls_Right_JoyConController_Stick_Button")), + ButtonA = ToID(Parser.Value(i + "_Controls_Right_JoyConController_Button_A")), + ButtonB = ToID(Parser.Value(i + "_Controls_Right_JoyConController_Button_B")), + ButtonX = ToID(Parser.Value(i + "_Controls_Right_JoyConController_Button_X")), + ButtonY = ToID(Parser.Value(i + "_Controls_Right_JoyConController_Button_Y")), + ButtonPlus = ToID(Parser.Value(i + "_Controls_Right_JoyConController_Button_Plus")), + ButtonR = ToID(Parser.Value(i + "_Controls_Right_JoyConController_Button_R")), + ButtonZR = ToID(Parser.Value(i + "_Controls_Right_JoyConController_Button_ZR")) }); + + JoyConControllerList.Add(Controller); + } + + //Finally, convert that to a regular Array. + JoyConControllers = JoyConControllerList.ToArray(); } private static ControllerInputID ToID(string Key) @@ -156,6 +185,20 @@ namespace Ryujinx default: return ControllerInputID.Invalid; } } + + // -2: None, -1: Keyboard, Everything Else: GamePad Index + private static int ToEmulatedDevice(string Key) + { + switch (Key.ToUpper()) + { + case "NONE": return -2; + case "KEYBOARD": return -1; + } + + if (Key.ToUpper().StartsWith("GAMEPAD_")) return Int32.Parse(Key.Substring(Key.Length - 1)); + + return -2; + } } //https://stackoverflow.com/a/37772571 diff --git a/Ryujinx/Ryujinx.conf b/Ryujinx/Ryujinx.conf index 063bb2de4e..fef59b0dd6 100644 --- a/Ryujinx/Ryujinx.conf +++ b/Ryujinx/Ryujinx.conf @@ -22,18 +22,27 @@ 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 - -#The value of how pressed down each trigger has to be in order to register a button press -GamePad_Trigger_Threshold = 0.5 - #Whether or not to enable Controller support -GamePad_Enable = true +GamePad_Enable = false +#Device Mappings + +#Handheld Devices can not be mixed with any other players (Player 1, Player 2, etc.) +Handheld_Device = Keyboard + +Player1_Device = None +Player2_Device = None +Player3_Device = None +Player4_Device = None +Player5_Device = None +Player6_Device = None +Player7_Device = None +Player8_Device = None + +#This should always be None, as this is a Unknown Property with unknown side effects. +PlayerUnknown_Device = None + +#Keyboard Mappings #https://github.com/opentk/opentk/blob/develop/src/OpenTK/Input/Key.cs Controls_Left_JoyConKeyboard_Stick_Up = 105 Controls_Left_JoyConKeyboard_Stick_Down = 101 @@ -61,25 +70,38 @@ Controls_Right_JoyConKeyboard_Button_Plus = 121 Controls_Right_JoyConKeyboard_Button_R = 103 Controls_Right_JoyConKeyboard_Button_ZR = 97 -#Controller Controls +#Controller Mappings -Controls_Left_JoyConController_Stick_Button = LStick -Controls_Left_JoyConController_DPad_Up = DPadUp -Controls_Left_JoyConController_DPad_Down = DPadDown -Controls_Left_JoyConController_DPad_Left = DPadLeft -Controls_Left_JoyConController_DPad_Right = DPadRight -Controls_Left_JoyConController_Button_Minus = Back -Controls_Left_JoyConController_Button_L = LShoulder -Controls_Left_JoyConController_Button_ZL = LTrigger +#The left most Number ("0"_blah_blahblahblah) is which Controller Configuration the setting applies to. -Controls_Right_JoyConController_Stick_Button = RStick -Controls_Right_JoyConController_Button_A = B -Controls_Right_JoyConController_Button_B = A -Controls_Right_JoyConController_Button_X = Y -Controls_Right_JoyConController_Button_Y = X -Controls_Right_JoyConController_Button_Plus = Start -Controls_Right_JoyConController_Button_R = RShoulder -Controls_Right_JoyConController_Button_ZR = RTrigger +#Controller Configuration 0 -Controls_Left_JoyConController_Stick = LJoystick -Controls_Right_JoyConController_Stick = RJoystick \ No newline at end of file +#Controller Device Index +0_GamePad_Index = 0 + +#Controller Analog Stick Deadzone +0_GamePad_Deadzone = 0.05 + +#The value of how pressed down each trigger has to be in order to register a button press +0_GamePad_Trigger_Threshold = 0.5 + +0_Controls_Left_JoyConController_Stick_Button = LStick +0_Controls_Left_JoyConController_DPad_Up = DPadUp +0_Controls_Left_JoyConController_DPad_Down = DPadDown +0_Controls_Left_JoyConController_DPad_Left = DPadLeft +0_Controls_Left_JoyConController_DPad_Right = DPadRight +0_Controls_Left_JoyConController_Button_Minus = Back +0_Controls_Left_JoyConController_Button_L = LShoulder +0_Controls_Left_JoyConController_Button_ZL = LTrigger + +0_Controls_Right_JoyConController_Stick_Button = RStick +0_Controls_Right_JoyConController_Button_A = B +0_Controls_Right_JoyConController_Button_B = A +0_Controls_Right_JoyConController_Button_X = Y +0_Controls_Right_JoyConController_Button_Y = X +0_Controls_Right_JoyConController_Button_Plus = Start +0_Controls_Right_JoyConController_Button_R = RShoulder +0_Controls_Right_JoyConController_Button_ZR = RTrigger + +0_Controls_Left_JoyConController_Stick = LJoystick +0_Controls_Right_JoyConController_Stick = RJoystick \ No newline at end of file diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index dfc0b9a418..f9ead8ce9e 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -129,51 +129,68 @@ namespace Ryujinx private new void UpdateFrame() { - HidControllerButtons CurrentButton = 0; - HidJoystickPosition LeftJoystick; - HidJoystickPosition RightJoystick; + HidControllerButtons CurrentButtonsKeyboard = new HidControllerButtons(); + HidControllerButtons[] CurrentButtonsGamePad = new HidControllerButtons[Config.JoyConControllers.Length]; + HidJoystickPosition LeftJoystickKeyboard; + HidJoystickPosition RightJoystickKeyboard; + HidJoystickPosition[] LeftJoystickGamePad = new HidJoystickPosition[Config.JoyConControllers.Length]; + HidJoystickPosition[] RightJoystickGamePad = new HidJoystickPosition[Config.JoyConControllers.Length]; - int LeftJoystickDX = 0; - int LeftJoystickDY = 0; - int RightJoystickDX = 0; - int RightJoystickDY = 0; + int LeftJoystickDXKeyboard = 0; + int LeftJoystickDYKeyboard = 0; + int RightJoystickDXKeyboard = 0; + int RightJoystickDYKeyboard = 0; + + int[] LeftJoystickDXGamePad = new int[Config.JoyConControllers.Length]; + int[] LeftJoystickDYGamePad = new int[Config.JoyConControllers.Length]; + int[] RightJoystickDXGamePad = new int[Config.JoyConControllers.Length]; + int[] RightJoystickDYGamePad = new int[Config.JoyConControllers.Length]; //Keyboard Input if (Keyboard.HasValue) { KeyboardState Keyboard = this.Keyboard.Value; - CurrentButton = Config.JoyConKeyboard.GetButtons(Keyboard); + CurrentButtonsKeyboard = Config.JoyConKeyboard.GetButtons(Keyboard); - (LeftJoystickDX, LeftJoystickDY) = Config.JoyConKeyboard.GetLeftStick(Keyboard); - - (RightJoystickDX, RightJoystickDY) = Config.JoyConKeyboard.GetRightStick(Keyboard); + (LeftJoystickDXKeyboard, LeftJoystickDYKeyboard) = Config.JoyConKeyboard.GetLeftStick(Keyboard); + (RightJoystickDXKeyboard, RightJoystickDYKeyboard) = Config.JoyConKeyboard.GetRightStick(Keyboard); } //Controller Input - CurrentButton |= Config.JoyConController.GetButtons(); - - //Keyboard has priority stick-wise - if (LeftJoystickDX == 0 && LeftJoystickDY == 0) + if (Config.GamePadEnable) { - (LeftJoystickDX, LeftJoystickDY) = Config.JoyConController.GetLeftStick(); + for (int i = 0; i < CurrentButtonsGamePad.Length; ++i) + { + CurrentButtonsGamePad[i] |= Config.JoyConControllers[i].GetButtons(); + + (LeftJoystickDXGamePad[i], LeftJoystickDYGamePad[i]) = Config.JoyConControllers[i].GetLeftStick(); + (RightJoystickDXGamePad[i], RightJoystickDYGamePad[i]) = Config.JoyConControllers[i].GetRightStick(); + + LeftJoystickGamePad[i] = new HidJoystickPosition + { + DX = LeftJoystickDXGamePad[i], + DY = LeftJoystickDYGamePad[i] + }; + + RightJoystickGamePad[i] = new HidJoystickPosition + { + DX = RightJoystickDXGamePad[i], + DY = RightJoystickDYGamePad[i] + }; + } } - if (RightJoystickDX == 0 && RightJoystickDY == 0) + LeftJoystickKeyboard = new HidJoystickPosition { - (RightJoystickDX, RightJoystickDY) = Config.JoyConController.GetRightStick(); - } - - LeftJoystick = new HidJoystickPosition - { - DX = LeftJoystickDX, - DY = LeftJoystickDY + DX = LeftJoystickDXKeyboard, + DY = LeftJoystickDYKeyboard }; - RightJoystick = new HidJoystickPosition + RightJoystickKeyboard = new HidJoystickPosition { - DX = RightJoystickDX, - DY = RightJoystickDY + DX = RightJoystickDXKeyboard, + DY = RightJoystickDYKeyboard }; bool HasTouch = false; @@ -235,19 +252,262 @@ namespace Ryujinx Ns.Hid.SetTouchPoints(); } - Ns.Hid.SetJoyconButton( - HidControllerId.CONTROLLER_HANDHELD, - HidControllerLayouts.Handheld_Joined, - CurrentButton, - LeftJoystick, - RightJoystick); + if (HidEmulatedDevices.Devices.Handheld != -2) + { + switch (HidEmulatedDevices.Devices.Handheld) + { + case -1: + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_HANDHELD, + HidControllerLayouts.Handheld_Joined, + CurrentButtonsKeyboard, + LeftJoystickKeyboard, + RightJoystickKeyboard); + break; + default: + if (HidEmulatedDevices.Devices.Handheld < 0) + throw new ArgumentException("Unknown Emulated Device Code: " + HidEmulatedDevices.Devices.Handheld + "."); + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_HANDHELD, + HidControllerLayouts.Handheld_Joined, + CurrentButtonsGamePad[HidEmulatedDevices.Devices.Handheld], + LeftJoystickGamePad[HidEmulatedDevices.Devices.Handheld], + RightJoystickGamePad[HidEmulatedDevices.Devices.Handheld]); + break; + } + } - Ns.Hid.SetJoyconButton( - HidControllerId.CONTROLLER_HANDHELD, - HidControllerLayouts.Main, + if (HidEmulatedDevices.Devices.Player1 != -2) + { + switch (HidEmulatedDevices.Devices.Player1) + { + case -1: + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_PLAYER_1, + HidControllerLayouts.Joined, + CurrentButtonsKeyboard, + LeftJoystickKeyboard, + RightJoystickKeyboard); + break; + default: + if (HidEmulatedDevices.Devices.Player1 < 0) + throw new ArgumentException("Unknown Emulated Device Code: " + HidEmulatedDevices.Devices.Player1 + "."); + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_PLAYER_1, + HidControllerLayouts.Joined, + CurrentButtonsGamePad[HidEmulatedDevices.Devices.Player1], + LeftJoystickGamePad[HidEmulatedDevices.Devices.Player1], + RightJoystickGamePad[HidEmulatedDevices.Devices.Player1]); + break; + } + } + + if (HidEmulatedDevices.Devices.Player2 != -2) + { + switch (HidEmulatedDevices.Devices.Player2) + { + case -1: + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_PLAYER_2, + HidControllerLayouts.Joined, + CurrentButtonsKeyboard, + LeftJoystickKeyboard, + RightJoystickKeyboard); + break; + default: + if (HidEmulatedDevices.Devices.Player2 < 0) + throw new ArgumentException("Unknown Emulated Device Code: " + HidEmulatedDevices.Devices.Player2 + "."); + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_PLAYER_2, + HidControllerLayouts.Joined, + CurrentButtonsGamePad[HidEmulatedDevices.Devices.Player2], + LeftJoystickGamePad[HidEmulatedDevices.Devices.Player2], + RightJoystickGamePad[HidEmulatedDevices.Devices.Player2]); + break; + } + } + + if (HidEmulatedDevices.Devices.Player3 != -2) + { + switch (HidEmulatedDevices.Devices.Player3) + { + case -1: + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_PLAYER_3, + HidControllerLayouts.Joined, + CurrentButtonsKeyboard, + LeftJoystickKeyboard, + RightJoystickKeyboard); + break; + default: + if (HidEmulatedDevices.Devices.Player3 < 0) + throw new ArgumentException("Unknown Emulated Device Code: " + HidEmulatedDevices.Devices.Player3 + "."); + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_PLAYER_3, + HidControllerLayouts.Joined, + CurrentButtonsGamePad[HidEmulatedDevices.Devices.Player3], + LeftJoystickGamePad[HidEmulatedDevices.Devices.Player3], + RightJoystickGamePad[HidEmulatedDevices.Devices.Player3]); + break; + } + } + + if (HidEmulatedDevices.Devices.Player4 != -2) + { + switch (HidEmulatedDevices.Devices.Player4) + { + case -1: + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_PLAYER_4, + HidControllerLayouts.Joined, + CurrentButtonsKeyboard, + LeftJoystickKeyboard, + RightJoystickKeyboard); + break; + default: + if (HidEmulatedDevices.Devices.Player4 < 0) + throw new ArgumentException("Unknown Emulated Device Code: " + HidEmulatedDevices.Devices.Player4 + "."); + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_PLAYER_4, + HidControllerLayouts.Joined, + CurrentButtonsGamePad[HidEmulatedDevices.Devices.Player4], + LeftJoystickGamePad[HidEmulatedDevices.Devices.Player4], + RightJoystickGamePad[HidEmulatedDevices.Devices.Player4]); + break; + } + } + + if (HidEmulatedDevices.Devices.Player5 != -2) + { + switch (HidEmulatedDevices.Devices.Player5) + { + case -1: + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_PLAYER_5, + HidControllerLayouts.Joined, + CurrentButtonsKeyboard, + LeftJoystickKeyboard, + RightJoystickKeyboard); + break; + default: + if (HidEmulatedDevices.Devices.Player5 < 0) + throw new ArgumentException("Unknown Emulated Device Code: " + HidEmulatedDevices.Devices.Player5 + "."); + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_PLAYER_5, + HidControllerLayouts.Joined, + CurrentButtonsGamePad[HidEmulatedDevices.Devices.Player5], + LeftJoystickGamePad[HidEmulatedDevices.Devices.Player5], + RightJoystickGamePad[HidEmulatedDevices.Devices.Player5]); + break; + } + } + + if (HidEmulatedDevices.Devices.Player6 != -2) + { + switch (HidEmulatedDevices.Devices.Player6) + { + case -1: + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_PLAYER_6, + HidControllerLayouts.Joined, + CurrentButtonsKeyboard, + LeftJoystickKeyboard, + RightJoystickKeyboard); + break; + default: + if (HidEmulatedDevices.Devices.Player6 < 0) + throw new ArgumentException("Unknown Emulated Device Code: " + HidEmulatedDevices.Devices.Player6 + "."); + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_PLAYER_6, + HidControllerLayouts.Joined, + CurrentButtonsGamePad[HidEmulatedDevices.Devices.Player6], + LeftJoystickGamePad[HidEmulatedDevices.Devices.Player6], + RightJoystickGamePad[HidEmulatedDevices.Devices.Player6]); + break; + } + } + + if (HidEmulatedDevices.Devices.Player7 != -2) + { + switch (HidEmulatedDevices.Devices.Player7) + { + case -1: + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_PLAYER_7, + HidControllerLayouts.Joined, + CurrentButtonsKeyboard, + LeftJoystickKeyboard, + RightJoystickKeyboard); + break; + default: + if (HidEmulatedDevices.Devices.Player7 < 0) + throw new ArgumentException("Unknown Emulated Device Code: " + HidEmulatedDevices.Devices.Player7 + "."); + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_PLAYER_7, + HidControllerLayouts.Joined, + CurrentButtonsGamePad[HidEmulatedDevices.Devices.Player7], + LeftJoystickGamePad[HidEmulatedDevices.Devices.Player7], + RightJoystickGamePad[HidEmulatedDevices.Devices.Player7]); + break; + } + } + + if (HidEmulatedDevices.Devices.Player8 != -2) + { + switch (HidEmulatedDevices.Devices.Player8) + { + case -1: + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_PLAYER_8, + HidControllerLayouts.Joined, + CurrentButtonsKeyboard, + LeftJoystickKeyboard, + RightJoystickKeyboard); + break; + default: + if (HidEmulatedDevices.Devices.Player8 < 0) + throw new ArgumentException("Unknown Emulated Device Code: " + HidEmulatedDevices.Devices.Player8 + "."); + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_PLAYER_8, + HidControllerLayouts.Joined, + CurrentButtonsGamePad[HidEmulatedDevices.Devices.Player8], + LeftJoystickGamePad[HidEmulatedDevices.Devices.Player8], + RightJoystickGamePad[HidEmulatedDevices.Devices.Player8]); + break; + } + + if (HidEmulatedDevices.Devices.PlayerUnknown != -2) + { + switch (HidEmulatedDevices.Devices.PlayerUnknown) + { + case -1: + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_UNKNOWN, + HidControllerLayouts.Joined, + CurrentButtonsKeyboard, + LeftJoystickKeyboard, + RightJoystickKeyboard); + break; + default: + if (HidEmulatedDevices.Devices.PlayerUnknown < 0) + throw new ArgumentException("Unknown Emulated Device Code: " + HidEmulatedDevices.Devices.PlayerUnknown + "."); + Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_UNKNOWN, + HidControllerLayouts.Joined, + CurrentButtonsGamePad[HidEmulatedDevices.Devices.PlayerUnknown], + LeftJoystickGamePad[HidEmulatedDevices.Devices.PlayerUnknown], + RightJoystickGamePad[HidEmulatedDevices.Devices.PlayerUnknown]); + break; + } + } + } + + /*Ns.Hid.SetJoyconButton( + HidControllerId.CONTROLLER_PLAYER_1, + HidControllerLayouts.Joined, CurrentButton, LeftJoystick, - RightJoystick); + RightJoystick);*/ } private new void RenderFrame() From d61bf8f556bf57fd03f8fb254963ab7a1f303515 Mon Sep 17 00:00:00 2001 From: John Clemis Date: Fri, 10 Aug 2018 02:25:53 -0500 Subject: [PATCH 22/22] Change the Default Configuration to be a bit more clear. --- Ryujinx/Ryujinx.conf | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Ryujinx/Ryujinx.conf b/Ryujinx/Ryujinx.conf index fef59b0dd6..1c9b79f0d6 100644 --- a/Ryujinx/Ryujinx.conf +++ b/Ryujinx/Ryujinx.conf @@ -23,14 +23,20 @@ Logging_Enable_Error = true Logging_Filtered_Classes = #Whether or not to enable Controller support -GamePad_Enable = false +GamePad_Enable = true #Device Mappings -#Handheld Devices can not be mixed with any other players (Player 1, Player 2, etc.) -Handheld_Device = Keyboard +#Valid Mappings: +#None = Disabled +#Keyboard = Keyboard Input +#GamePad_X = X Game Pad Configuration (eg. GamePad_0 is the zeroth Controller Configuration) -Player1_Device = None +#Handheld Devices can not be mixed with any other players (Player 1, Player 2, etc.) +#This can stay at None unless you specifically want to emulate Handheld controllers. +Handheld_Device = None + +Player1_Device = Keyboard Player2_Device = None Player3_Device = None Player4_Device = None