mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-08 00:43:04 +00:00
Add mapping per Axis
+ An attempt to fix peoples problems with the Keyboard input acting up with Controller Input enabled.
This commit is contained in:
parent
c2620241a8
commit
b658334485
4 changed files with 61 additions and 26 deletions
|
@ -107,7 +107,8 @@ namespace Ryujinx
|
||||||
{
|
{
|
||||||
Left = new JoyConControllerLeft
|
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"),
|
StickButton = Parser.Value("Controls_Left_JoyConController_Stick_Button"),
|
||||||
DPadUp = Parser.Value("Controls_Left_JoyConController_DPad_Up"),
|
DPadUp = Parser.Value("Controls_Left_JoyConController_DPad_Up"),
|
||||||
DPadDown = Parser.Value("Controls_Left_JoyConController_DPad_Down"),
|
DPadDown = Parser.Value("Controls_Left_JoyConController_DPad_Down"),
|
||||||
|
@ -120,7 +121,8 @@ namespace Ryujinx
|
||||||
|
|
||||||
Right = new JoyConControllerRight
|
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"),
|
StickButton = Parser.Value("Controls_Right_JoyConController_Stick_Button"),
|
||||||
ButtonA = Parser.Value("Controls_Right_JoyConController_Button_A"),
|
ButtonA = Parser.Value("Controls_Right_JoyConController_Button_A"),
|
||||||
ButtonB = Parser.Value("Controls_Right_JoyConController_Button_B"),
|
ButtonB = Parser.Value("Controls_Right_JoyConController_Button_B"),
|
||||||
|
|
|
@ -58,7 +58,7 @@ Controls_Right_JoyConKeyboard_Button_Plus = 121
|
||||||
Controls_Right_JoyConKeyboard_Button_R = 103
|
Controls_Right_JoyConKeyboard_Button_R = 103
|
||||||
Controls_Right_JoyConKeyboard_Button_ZR = 97
|
Controls_Right_JoyConKeyboard_Button_ZR = 97
|
||||||
|
|
||||||
#Controller Controls
|
#Controller Controls (The default configuration is what works for a PS4 Controller using DS4 Windows)
|
||||||
|
|
||||||
Controls_Left_JoyConController_Stick_Button = LStick
|
Controls_Left_JoyConController_Stick_Button = LStick
|
||||||
Controls_Left_JoyConController_DPad_Up = DPadUp
|
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_R = RShoulder
|
||||||
Controls_Right_JoyConController_Button_ZR = RTrigger
|
Controls_Right_JoyConController_Button_ZR = RTrigger
|
||||||
|
|
||||||
Controls_Left_JoyConController_Stick = LJoystick
|
Controls_Left_JoyConController_Stick_AxisX = JoystickAxis0
|
||||||
Controls_Right_JoyConController_Stick = RJoystick
|
Controls_Left_JoyConController_Stick_AxisY = JoystickAxis1
|
||||||
|
Controls_Right_JoyConController_Stick_AxisX = -JoystickAxis3
|
||||||
|
Controls_Right_JoyConController_Stick_AxisY = -JoystickAxis2
|
||||||
|
|
|
@ -174,13 +174,41 @@ namespace Ryujinx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector2 GetJoystickAxisFromString(GamePadState GamePad, string Joystick)
|
private float GetJoystickAxisFromString(GamePadState GamePad, string Joystick)
|
||||||
{
|
{
|
||||||
switch (Joystick.ToUpper())
|
switch (Joystick.ToUpper())
|
||||||
{
|
{
|
||||||
case "LJOYSTICK": return GamePad.ThumbSticks.Left;
|
case "JOYSTICKAXIS0": return GamePad.ThumbSticks.Left.X;
|
||||||
case "RJOYSTICK": return new Vector2(-GamePad.ThumbSticks.Right.Y, -GamePad.ThumbSticks.Right.X);
|
case "JOYSTICKAXIS1": return GamePad.ThumbSticks.Left.Y;
|
||||||
default: throw new ArgumentException();
|
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 LeftJoystickDY = 0;
|
||||||
int RightJoystickDX = 0;
|
int RightJoystickDX = 0;
|
||||||
int RightJoystickDY = 0;
|
int RightJoystickDY = 0;
|
||||||
float AnalogStickDeadzone = Config.GamePadDeadzone;
|
|
||||||
|
|
||||||
//Keyboard Input
|
//Keyboard Input
|
||||||
if (Keyboard.HasValue)
|
if (Keyboard.HasValue && !IsGamePadActive(Config.GamePadIndex))
|
||||||
{
|
{
|
||||||
KeyboardState Keyboard = this.Keyboard.Value;
|
KeyboardState Keyboard = this.Keyboard.Value;
|
||||||
|
|
||||||
|
@ -237,9 +264,11 @@ namespace Ryujinx
|
||||||
}
|
}
|
||||||
|
|
||||||
//Controller Input
|
//Controller Input
|
||||||
if (Config.GamePadEnable)
|
if (Config.GamePadEnable && !Keyboard.HasValue && IsGamePadActive(Config.GamePadIndex))
|
||||||
{
|
{
|
||||||
GamePadState GamePad = OpenTK.Input.GamePad.GetState(Config.GamePadIndex);
|
GamePadState GamePad = OpenTK.Input.GamePad.GetState(Config.GamePadIndex);
|
||||||
|
float AnalogStickDeadzone = Config.GamePadDeadzone;
|
||||||
|
|
||||||
//LeftButtons
|
//LeftButtons
|
||||||
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.DPadUp)) CurrentButton |= HidControllerButtons.KEY_DUP;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.DPadUp)) CurrentButton |= HidControllerButtons.KEY_DUP;
|
||||||
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.DPadDown)) CurrentButton |= HidControllerButtons.KEY_DDOWN;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Left.DPadDown)) CurrentButton |= HidControllerButtons.KEY_DDOWN;
|
||||||
|
@ -261,22 +290,22 @@ namespace Ryujinx
|
||||||
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Right.ButtonZR)) CurrentButton |= HidControllerButtons.KEY_ZR;
|
if (IsGamePadButtonPressedFromString(GamePad, Config.JoyConController.Right.ButtonZR)) CurrentButton |= HidControllerButtons.KEY_ZR;
|
||||||
|
|
||||||
//LeftJoystick
|
//LeftJoystick
|
||||||
if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).X >= AnalogStickDeadzone
|
if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick_AxisX) >= AnalogStickDeadzone
|
||||||
|| GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).X <= -AnalogStickDeadzone)
|
|| GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick_AxisX) <= -AnalogStickDeadzone)
|
||||||
LeftJoystickDX = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).X * short.MaxValue);
|
LeftJoystickDX = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick_AxisX) * short.MaxValue);
|
||||||
|
|
||||||
if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).Y >= AnalogStickDeadzone
|
if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick_AxisY) >= AnalogStickDeadzone
|
||||||
|| GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).Y <= -AnalogStickDeadzone)
|
|| GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick_AxisY) <= -AnalogStickDeadzone)
|
||||||
LeftJoystickDY = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick).Y * short.MaxValue);
|
LeftJoystickDY = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Left.Stick_AxisY) * short.MaxValue);
|
||||||
|
|
||||||
//RightJoystick
|
//RightJoystick
|
||||||
if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).X >= AnalogStickDeadzone
|
if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisX) >= AnalogStickDeadzone
|
||||||
|| GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).X <= -AnalogStickDeadzone)
|
|| GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisX) <= -AnalogStickDeadzone)
|
||||||
RightJoystickDX = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).X * short.MaxValue);
|
RightJoystickDX = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisX) * short.MaxValue);
|
||||||
|
|
||||||
if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).Y >= AnalogStickDeadzone
|
if (GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisY) >= AnalogStickDeadzone
|
||||||
|| GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).Y <= -AnalogStickDeadzone)
|
|| GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisY) <= -AnalogStickDeadzone)
|
||||||
RightJoystickDY = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick).Y * short.MaxValue);
|
RightJoystickDY = (int)(GetJoystickAxisFromString(GamePad, Config.JoyConController.Right.Stick_AxisY) * short.MaxValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
LeftJoystick = new HidJoystickPosition
|
LeftJoystick = new HidJoystickPosition
|
||||||
|
|
|
@ -6,7 +6,8 @@ namespace Ryujinx.UI.Input
|
||||||
{
|
{
|
||||||
public struct JoyConControllerLeft
|
public struct JoyConControllerLeft
|
||||||
{
|
{
|
||||||
public string Stick;
|
public string Stick_AxisX;
|
||||||
|
public string Stick_AxisY;
|
||||||
public string StickButton;
|
public string StickButton;
|
||||||
public string DPadUp;
|
public string DPadUp;
|
||||||
public string DPadDown;
|
public string DPadDown;
|
||||||
|
@ -19,7 +20,8 @@ namespace Ryujinx.UI.Input
|
||||||
|
|
||||||
public struct JoyConControllerRight
|
public struct JoyConControllerRight
|
||||||
{
|
{
|
||||||
public string Stick;
|
public string Stick_AxisX;
|
||||||
|
public string Stick_AxisY;
|
||||||
public string StickButton;
|
public string StickButton;
|
||||||
public string ButtonA;
|
public string ButtonA;
|
||||||
public string ButtonB;
|
public string ButtonB;
|
||||||
|
|
Loading…
Reference in a new issue