Little rewrite of HID input (#723)
* change hid sharedmem writing to use structures
This commit is contained in:
parent
1f3a34dd7a
commit
d254548548
42 changed files with 682 additions and 409 deletions
|
@ -64,7 +64,7 @@
|
|||
"controller_type": "Handheld",
|
||||
|
||||
// Enable or disable "direct keyboard access (HID) support" (Provides games access to your keyboard as a text entry device).
|
||||
"enable_keyboard": true,
|
||||
"enable_keyboard": false,
|
||||
|
||||
// Keyboard Controls
|
||||
// https://github.com/opentk/opentk/blob/master/src/OpenTK/Input/Key.cs
|
||||
|
|
|
@ -120,7 +120,7 @@ namespace Ryujinx
|
|||
/// <summary>
|
||||
/// The primary controller's type
|
||||
/// </summary>
|
||||
public HidControllerType ControllerType { get; private set; }
|
||||
public ControllerStatus ControllerType { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Enable or disable keyboard support (Independent from controllers binding)
|
||||
|
@ -135,7 +135,7 @@ namespace Ryujinx
|
|||
/// <summary>
|
||||
/// Controller control bindings
|
||||
/// </summary>
|
||||
public NpadController GamepadControls { get; private set; }
|
||||
public UI.Input.NpadController GamepadControls { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Loads a configuration file from disk
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace Ryujinx
|
|||
|
||||
private IGalRenderer _renderer;
|
||||
|
||||
private HidHotkeyButtons _prevHotkeyButtons = 0;
|
||||
private HotkeyButtons _prevHotkeyButtons = 0;
|
||||
|
||||
private KeyboardState? _keyboard = null;
|
||||
|
||||
|
@ -140,11 +140,11 @@ namespace Ryujinx
|
|||
|
||||
private new void UpdateFrame()
|
||||
{
|
||||
HidHotkeyButtons currentHotkeyButtons = 0;
|
||||
HidControllerButtons currentButton = 0;
|
||||
HidJoystickPosition leftJoystick;
|
||||
HidJoystickPosition rightJoystick;
|
||||
HidKeyboard? hidKeyboard = null;
|
||||
HotkeyButtons currentHotkeyButtons = 0;
|
||||
ControllerButtons currentButton = 0;
|
||||
JoystickPosition leftJoystick;
|
||||
JoystickPosition rightJoystick;
|
||||
HLE.Input.Keyboard? hidKeyboard = null;
|
||||
|
||||
int leftJoystickDx = 0;
|
||||
int leftJoystickDy = 0;
|
||||
|
@ -176,7 +176,7 @@ namespace Ryujinx
|
|||
|
||||
if (!hidKeyboard.HasValue)
|
||||
{
|
||||
hidKeyboard = new HidKeyboard
|
||||
hidKeyboard = new HLE.Input.Keyboard
|
||||
{
|
||||
Modifier = 0,
|
||||
Keys = new int[0x8]
|
||||
|
@ -196,13 +196,13 @@ namespace Ryujinx
|
|||
(rightJoystickDx, rightJoystickDy) = Configuration.Instance.GamepadControls.GetRightStick();
|
||||
}
|
||||
|
||||
leftJoystick = new HidJoystickPosition
|
||||
leftJoystick = new JoystickPosition
|
||||
{
|
||||
Dx = leftJoystickDx,
|
||||
Dy = leftJoystickDy
|
||||
};
|
||||
|
||||
rightJoystick = new HidJoystickPosition
|
||||
rightJoystick = new JoystickPosition
|
||||
{
|
||||
Dx = rightJoystickDx,
|
||||
Dy = rightJoystickDy
|
||||
|
@ -247,7 +247,7 @@ namespace Ryujinx
|
|||
int mX = (scrnMouseX * TouchScreenWidth) / scrnWidth;
|
||||
int mY = (scrnMouseY * TouchScreenHeight) / scrnHeight;
|
||||
|
||||
HidTouchPoint currentPoint = new HidTouchPoint
|
||||
TouchPoint currentPoint = new TouchPoint
|
||||
{
|
||||
X = mX,
|
||||
Y = mY,
|
||||
|
@ -274,13 +274,13 @@ namespace Ryujinx
|
|||
_device.Hid.WriteKeyboard(hidKeyboard.Value);
|
||||
}
|
||||
|
||||
HidControllerBase controller = _device.Hid.PrimaryController;
|
||||
BaseController controller = _device.Hid.PrimaryController;
|
||||
|
||||
controller.SendInput(currentButton, leftJoystick, rightJoystick);
|
||||
|
||||
// Toggle vsync
|
||||
if (currentHotkeyButtons.HasFlag(HidHotkeyButtons.ToggleVSync) &&
|
||||
!_prevHotkeyButtons.HasFlag(HidHotkeyButtons.ToggleVSync))
|
||||
if (currentHotkeyButtons.HasFlag(HotkeyButtons.ToggleVSync) &&
|
||||
!_prevHotkeyButtons.HasFlag(HotkeyButtons.ToggleVSync))
|
||||
{
|
||||
_device.EnableDeviceVsync = !_device.EnableDeviceVsync;
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace Ryujinx.UI.Input
|
|||
Enabled = enabled;
|
||||
}
|
||||
|
||||
public HidControllerButtons GetButtons()
|
||||
public ControllerButtons GetButtons()
|
||||
{
|
||||
if (!Enabled)
|
||||
{
|
||||
|
@ -116,25 +116,25 @@ namespace Ryujinx.UI.Input
|
|||
|
||||
GamePadState gpState = GamePad.GetState(Index);
|
||||
|
||||
HidControllerButtons buttons = 0;
|
||||
ControllerButtons buttons = 0;
|
||||
|
||||
if (IsPressed(gpState, LeftJoycon.DPadUp)) buttons |= HidControllerButtons.DpadUp;
|
||||
if (IsPressed(gpState, LeftJoycon.DPadDown)) buttons |= HidControllerButtons.DpadDown;
|
||||
if (IsPressed(gpState, LeftJoycon.DPadLeft)) buttons |= HidControllerButtons.DpadLeft;
|
||||
if (IsPressed(gpState, LeftJoycon.DPadRight)) buttons |= HidControllerButtons.DPadRight;
|
||||
if (IsPressed(gpState, LeftJoycon.StickButton)) buttons |= HidControllerButtons.StickLeft;
|
||||
if (IsPressed(gpState, LeftJoycon.ButtonMinus)) buttons |= HidControllerButtons.Minus;
|
||||
if (IsPressed(gpState, LeftJoycon.ButtonL)) buttons |= HidControllerButtons.L;
|
||||
if (IsPressed(gpState, LeftJoycon.ButtonZl)) buttons |= HidControllerButtons.Zl;
|
||||
if (IsPressed(gpState, LeftJoycon.DPadUp)) buttons |= ControllerButtons.DpadUp;
|
||||
if (IsPressed(gpState, LeftJoycon.DPadDown)) buttons |= ControllerButtons.DpadDown;
|
||||
if (IsPressed(gpState, LeftJoycon.DPadLeft)) buttons |= ControllerButtons.DpadLeft;
|
||||
if (IsPressed(gpState, LeftJoycon.DPadRight)) buttons |= ControllerButtons.DPadRight;
|
||||
if (IsPressed(gpState, LeftJoycon.StickButton)) buttons |= ControllerButtons.StickLeft;
|
||||
if (IsPressed(gpState, LeftJoycon.ButtonMinus)) buttons |= ControllerButtons.Minus;
|
||||
if (IsPressed(gpState, LeftJoycon.ButtonL)) buttons |= ControllerButtons.L;
|
||||
if (IsPressed(gpState, LeftJoycon.ButtonZl)) buttons |= ControllerButtons.Zl;
|
||||
|
||||
if (IsPressed(gpState, RightJoycon.ButtonA)) buttons |= HidControllerButtons.A;
|
||||
if (IsPressed(gpState, RightJoycon.ButtonB)) buttons |= HidControllerButtons.B;
|
||||
if (IsPressed(gpState, RightJoycon.ButtonX)) buttons |= HidControllerButtons.X;
|
||||
if (IsPressed(gpState, RightJoycon.ButtonY)) buttons |= HidControllerButtons.Y;
|
||||
if (IsPressed(gpState, RightJoycon.StickButton)) buttons |= HidControllerButtons.StickRight;
|
||||
if (IsPressed(gpState, RightJoycon.ButtonPlus)) buttons |= HidControllerButtons.Plus;
|
||||
if (IsPressed(gpState, RightJoycon.ButtonR)) buttons |= HidControllerButtons.R;
|
||||
if (IsPressed(gpState, RightJoycon.ButtonZr)) buttons |= HidControllerButtons.Zr;
|
||||
if (IsPressed(gpState, RightJoycon.ButtonA)) buttons |= ControllerButtons.A;
|
||||
if (IsPressed(gpState, RightJoycon.ButtonB)) buttons |= ControllerButtons.B;
|
||||
if (IsPressed(gpState, RightJoycon.ButtonX)) buttons |= ControllerButtons.X;
|
||||
if (IsPressed(gpState, RightJoycon.ButtonY)) buttons |= ControllerButtons.Y;
|
||||
if (IsPressed(gpState, RightJoycon.StickButton)) buttons |= ControllerButtons.StickRight;
|
||||
if (IsPressed(gpState, RightJoycon.ButtonPlus)) buttons |= ControllerButtons.Plus;
|
||||
if (IsPressed(gpState, RightJoycon.ButtonR)) buttons |= ControllerButtons.R;
|
||||
if (IsPressed(gpState, RightJoycon.ButtonZr)) buttons |= ControllerButtons.Zr;
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
|
|
@ -57,27 +57,27 @@ namespace Ryujinx.UI.Input
|
|||
/// </summary>
|
||||
public KeyboardHotkeys Hotkeys { get; private set; }
|
||||
|
||||
public HidControllerButtons GetButtons(KeyboardState keyboard)
|
||||
public ControllerButtons GetButtons(KeyboardState keyboard)
|
||||
{
|
||||
HidControllerButtons buttons = 0;
|
||||
ControllerButtons buttons = 0;
|
||||
|
||||
if (keyboard[(Key)LeftJoycon.StickButton]) buttons |= HidControllerButtons.StickLeft;
|
||||
if (keyboard[(Key)LeftJoycon.DPadUp]) buttons |= HidControllerButtons.DpadUp;
|
||||
if (keyboard[(Key)LeftJoycon.DPadDown]) buttons |= HidControllerButtons.DpadDown;
|
||||
if (keyboard[(Key)LeftJoycon.DPadLeft]) buttons |= HidControllerButtons.DpadLeft;
|
||||
if (keyboard[(Key)LeftJoycon.DPadRight]) buttons |= HidControllerButtons.DPadRight;
|
||||
if (keyboard[(Key)LeftJoycon.ButtonMinus]) buttons |= HidControllerButtons.Minus;
|
||||
if (keyboard[(Key)LeftJoycon.ButtonL]) buttons |= HidControllerButtons.L;
|
||||
if (keyboard[(Key)LeftJoycon.ButtonZl]) buttons |= HidControllerButtons.Zl;
|
||||
if (keyboard[(Key)LeftJoycon.StickButton]) buttons |= ControllerButtons.StickLeft;
|
||||
if (keyboard[(Key)LeftJoycon.DPadUp]) buttons |= ControllerButtons.DpadUp;
|
||||
if (keyboard[(Key)LeftJoycon.DPadDown]) buttons |= ControllerButtons.DpadDown;
|
||||
if (keyboard[(Key)LeftJoycon.DPadLeft]) buttons |= ControllerButtons.DpadLeft;
|
||||
if (keyboard[(Key)LeftJoycon.DPadRight]) buttons |= ControllerButtons.DPadRight;
|
||||
if (keyboard[(Key)LeftJoycon.ButtonMinus]) buttons |= ControllerButtons.Minus;
|
||||
if (keyboard[(Key)LeftJoycon.ButtonL]) buttons |= ControllerButtons.L;
|
||||
if (keyboard[(Key)LeftJoycon.ButtonZl]) buttons |= ControllerButtons.Zl;
|
||||
|
||||
if (keyboard[(Key)RightJoycon.StickButton]) buttons |= HidControllerButtons.StickRight;
|
||||
if (keyboard[(Key)RightJoycon.ButtonA]) buttons |= HidControllerButtons.A;
|
||||
if (keyboard[(Key)RightJoycon.ButtonB]) buttons |= HidControllerButtons.B;
|
||||
if (keyboard[(Key)RightJoycon.ButtonX]) buttons |= HidControllerButtons.X;
|
||||
if (keyboard[(Key)RightJoycon.ButtonY]) buttons |= HidControllerButtons.Y;
|
||||
if (keyboard[(Key)RightJoycon.ButtonPlus]) buttons |= HidControllerButtons.Plus;
|
||||
if (keyboard[(Key)RightJoycon.ButtonR]) buttons |= HidControllerButtons.R;
|
||||
if (keyboard[(Key)RightJoycon.ButtonZr]) buttons |= HidControllerButtons.Zr;
|
||||
if (keyboard[(Key)RightJoycon.StickButton]) buttons |= ControllerButtons.StickRight;
|
||||
if (keyboard[(Key)RightJoycon.ButtonA]) buttons |= ControllerButtons.A;
|
||||
if (keyboard[(Key)RightJoycon.ButtonB]) buttons |= ControllerButtons.B;
|
||||
if (keyboard[(Key)RightJoycon.ButtonX]) buttons |= ControllerButtons.X;
|
||||
if (keyboard[(Key)RightJoycon.ButtonY]) buttons |= ControllerButtons.Y;
|
||||
if (keyboard[(Key)RightJoycon.ButtonPlus]) buttons |= ControllerButtons.Plus;
|
||||
if (keyboard[(Key)RightJoycon.ButtonR]) buttons |= ControllerButtons.R;
|
||||
if (keyboard[(Key)RightJoycon.ButtonZr]) buttons |= ControllerButtons.Zr;
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
@ -108,11 +108,11 @@ namespace Ryujinx.UI.Input
|
|||
return (dx, dy);
|
||||
}
|
||||
|
||||
public HidHotkeyButtons GetHotkeyButtons(KeyboardState keyboard)
|
||||
public HotkeyButtons GetHotkeyButtons(KeyboardState keyboard)
|
||||
{
|
||||
HidHotkeyButtons buttons = 0;
|
||||
HotkeyButtons buttons = 0;
|
||||
|
||||
if (keyboard[(Key)Hotkeys.ToggleVsync]) buttons |= HidHotkeyButtons.ToggleVSync;
|
||||
if (keyboard[(Key)Hotkeys.ToggleVsync]) buttons |= HotkeyButtons.ToggleVSync;
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
@ -267,9 +267,9 @@ namespace Ryujinx.UI.Input
|
|||
new KeyMappingEntry { TargetKey = Key.NumLock, Target = 10 },
|
||||
};
|
||||
|
||||
public HidKeyboard GetKeysDown(KeyboardState keyboard)
|
||||
public HLE.Input.Keyboard GetKeysDown(KeyboardState keyboard)
|
||||
{
|
||||
HidKeyboard hidKeyboard = new HidKeyboard
|
||||
HLE.Input.Keyboard hidKeyboard = new HLE.Input.Keyboard
|
||||
{
|
||||
Modifier = 0,
|
||||
Keys = new int[0x8]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue