mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-08 00:43:04 +00:00
Added Configuration for the A B X Y Buttons
This commit is contained in:
parent
bb53859cba
commit
29d2d32372
3 changed files with 101 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
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
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue