mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-08 20:02:39 +00:00
Added Basic Joystick Configuration
This commit is contained in:
parent
50ee597735
commit
56dc5005c4
3 changed files with 47 additions and 13 deletions
|
@ -35,6 +35,9 @@ namespace Ryujinx
|
||||||
public static string Controls_Left_FakeJoycon_GamePadStick_Button;
|
public static string Controls_Left_FakeJoycon_GamePadStick_Button;
|
||||||
public static string Controls_Left_FakeJoycon_GamePadTrigger_ZL;
|
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)
|
public static void Read(Logger Log)
|
||||||
{
|
{
|
||||||
string IniFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
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_GamePadStick_Button = Parser.Value("Controls_Left_FakeJoycon_GamePadStick_Button");
|
||||||
Controls_Left_FakeJoycon_GamePadTrigger_ZL = Parser.Value("Controls_Left_FakeJoycon_GamePadTrigger_ZL");
|
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);
|
string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
//When the classes are specified on the list, we only
|
//When the classes are specified on the list, we only
|
||||||
|
|
|
@ -72,4 +72,7 @@ Controls_Left_FakeJoycon_GamePadDPad_Right = DPadRight
|
||||||
Controls_Left_FakeJoycon_GamePadButton_Minus = Back
|
Controls_Left_FakeJoycon_GamePadButton_Minus = Back
|
||||||
Controls_Left_FakeJoycon_GamePadButton_L = LShoulder
|
Controls_Left_FakeJoycon_GamePadButton_L = LShoulder
|
||||||
Controls_Left_FakeJoycon_GamePadStick_Button = LStick
|
Controls_Left_FakeJoycon_GamePadStick_Button = LStick
|
||||||
Controls_Left_FakeJoycon_GamePadTrigger_ZL = LTrigger
|
Controls_Left_FakeJoycon_GamePadTrigger_ZL = LTrigger
|
||||||
|
|
||||||
|
Controls_Right_FakeJoycon_GamePadJoystick_R = RJoystick
|
||||||
|
Controls_Left_FakeJoycon_GamePadJoystick_L = LJoystick
|
|
@ -121,6 +121,26 @@ namespace Ryujinx
|
||||||
return result;
|
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)
|
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||||
{
|
{
|
||||||
HidControllerButtons CurrentButton = 0;
|
HidControllerButtons CurrentButton = 0;
|
||||||
|
@ -187,12 +207,13 @@ namespace Ryujinx
|
||||||
== ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_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;
|
== 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;
|
== 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;
|
== ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_PLUS;
|
||||||
if (gamePad.Buttons.RightShoulder == ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_R;
|
if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_R)
|
||||||
if (getGamePadTriggerFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadTrigger_ZR)
|
== ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_R;
|
||||||
|
if (getGamePadTriggerFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadTrigger_ZR)
|
||||||
>= 0.5) CurrentButton |= HidControllerButtons.KEY_ZR;
|
>= 0.5) CurrentButton |= HidControllerButtons.KEY_ZR;
|
||||||
|
|
||||||
//LeftButtons
|
//LeftButtons
|
||||||
|
@ -214,18 +235,22 @@ namespace Ryujinx
|
||||||
>= 0.5) CurrentButton |= HidControllerButtons.KEY_ZL;
|
>= 0.5) CurrentButton |= HidControllerButtons.KEY_ZL;
|
||||||
|
|
||||||
//RightJoystick
|
//RightJoystick
|
||||||
if (gamePad.ThumbSticks.Right.X >= deadzone || gamePad.ThumbSticks.Right.X <= -deadzone)
|
if (getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).X >= deadzone
|
||||||
RightJoystickDY = (int)(-gamePad.ThumbSticks.Right.X * short.MaxValue);
|
|| 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)
|
if (getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).Y >= deadzone
|
||||||
RightJoystickDX = (int)(-gamePad.ThumbSticks.Right.Y * short.MaxValue);
|
|| getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).Y <= -deadzone)
|
||||||
|
RightJoystickDX = (int)(-getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).Y * short.MaxValue);
|
||||||
|
|
||||||
//LeftJoystick
|
//LeftJoystick
|
||||||
if (gamePad.ThumbSticks.Left.X >= deadzone || gamePad.ThumbSticks.Left.X <= -deadzone)
|
if (getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).X >= deadzone
|
||||||
LeftJoystickDX = (int)(gamePad.ThumbSticks.Left.X * short.MaxValue);
|
|| 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)
|
if (getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).Y >= deadzone
|
||||||
LeftJoystickDY = (int)(gamePad.ThumbSticks.Left.Y * short.MaxValue);
|
|| 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
|
LeftJoystick = new HidJoystickPosition
|
||||||
|
|
Loading…
Reference in a new issue