Add more buttons, fix multiple inputs and fix a small typo

This commit is contained in:
Starlet 2018-06-10 19:52:09 -04:00
parent a5e90ec2d1
commit b513c00627

View file

@ -21,7 +21,7 @@ namespace Ryujinx
private IGalRenderer Renderer; private IGalRenderer Renderer;
// Initialize XInput //Initialize XInput
private Controller[] InputControllers = new[] private Controller[] InputControllers = new[]
{ {
new Controller(UserIndex.One), new Controller(UserIndex.One),
@ -43,7 +43,7 @@ namespace Ryujinx
this.Ns = Ns; this.Ns = Ns;
this.Renderer = Renderer; this.Renderer = Renderer;
// Get 1st controller detected/available //Get 1st controller detected
foreach (Controller SelectController in InputControllers) foreach (Controller SelectController in InputControllers)
{ {
if (SelectController.IsConnected) if (SelectController.IsConnected)
@ -92,36 +92,31 @@ namespace Ryujinx
if (XInputEnabled) if (XInputEnabled)
{ {
State CurrentState = InputController.GetState(); State CurrentState = InputController.GetState();
switch (CurrentState.Gamepad.Buttons)
{ //Buttons
case GamepadButtonFlags.A: if (CurrentState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.A)) CurrentButton |= HidControllerButtons.KEY_A;
CurrentButton |= HidControllerButtons.KEY_A; if (CurrentState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.B)) CurrentButton |= HidControllerButtons.KEY_B;
break; if (CurrentState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.X)) CurrentButton |= HidControllerButtons.KEY_X;
case GamepadButtonFlags.B: if (CurrentState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.Y)) CurrentButton |= HidControllerButtons.KEY_Y;
CurrentButton |= HidControllerButtons.KEY_B;
break; //Plus/Minus
case GamepadButtonFlags.X: if (CurrentState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.Back)) CurrentButton |= HidControllerButtons.KEY_MINUS;
CurrentButton |= HidControllerButtons.KEY_X; if (CurrentState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.Start)) CurrentButton |= HidControllerButtons.KEY_PLUS;
break;
case GamepadButtonFlags.Y: //DPad
CurrentButton |= HidControllerButtons.KEY_Y; if (CurrentState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.DPadUp)) CurrentButton |= HidControllerButtons.KEY_DUP;
break; if (CurrentState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.DPadDown)) CurrentButton |= HidControllerButtons.KEY_DDOWN;
case GamepadButtonFlags.DPadUp: if (CurrentState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.DPadLeft)) CurrentButton |= HidControllerButtons.KEY_DLEFT;
CurrentButton |= HidControllerButtons.KEY_DUP; if (CurrentState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.DPadRight)) CurrentButton |= HidControllerButtons.KEY_DRIGHT;
break;
case GamepadButtonFlags.DPadDown: //L/ZL/R/ZR
CurrentButton |= HidControllerButtons.KEY_DDOWN; if (CurrentState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.LeftThumb)) CurrentButton |= HidControllerButtons.KEY_L;
break; if (CurrentState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.LeftShoulder)) CurrentButton |= HidControllerButtons.KEY_ZL;
case GamepadButtonFlags.DPadLeft: if (CurrentState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.RightThumb)) CurrentButton |= HidControllerButtons.KEY_R;
CurrentButton |= HidControllerButtons.KEY_DLEFT; if (CurrentState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.RightShoulder)) CurrentButton |= HidControllerButtons.KEY_ZR;
break;
case GamepadButtonFlags.DPadRight:
CurrentButton |= HidControllerButtons.KEY_DRIGHT;
break;
}
} }
//RightJoystick //LeftJoystick
if (Keyboard[(Key)Config.FakeJoyCon.Left.StickUp]) LeftJoystickDY = short.MaxValue; 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.StickDown]) LeftJoystickDY = -short.MaxValue;
if (Keyboard[(Key)Config.FakeJoyCon.Left.StickLeft]) LeftJoystickDX = -short.MaxValue; if (Keyboard[(Key)Config.FakeJoyCon.Left.StickLeft]) LeftJoystickDX = -short.MaxValue;