hid: Initial Keyboard Support (#684)
* hid: Initial Keyboard Support This adds basic hid keyboard support. Because of OpenTK.Input limitations, some specials keys aren't mapped. * Fix code style * Fix for loops code style * Make hid keyboard feature toggleable * Address comments * Fix 2 other nits * Apply jd's suggestion
This commit is contained in:
parent
3079c6a659
commit
12badfffb9
8 changed files with 261 additions and 1 deletions
|
@ -145,6 +145,7 @@ namespace Ryujinx
|
|||
HidControllerButtons currentButton = 0;
|
||||
HidJoystickPosition leftJoystick;
|
||||
HidJoystickPosition rightJoystick;
|
||||
HidKeyboard? hidKeyboard = null;
|
||||
|
||||
int leftJoystickDx = 0;
|
||||
int leftJoystickDy = 0;
|
||||
|
@ -165,9 +166,23 @@ namespace Ryujinx
|
|||
currentHotkeyButtons = Configuration.Instance.KeyboardControls.GetHotkeyButtons(keyboard);
|
||||
currentButton = Configuration.Instance.KeyboardControls.GetButtons(keyboard);
|
||||
|
||||
if (Configuration.Instance.EnableKeyboard)
|
||||
{
|
||||
hidKeyboard = Configuration.Instance.KeyboardControls.GetKeysDown(keyboard);
|
||||
}
|
||||
|
||||
(leftJoystickDx, leftJoystickDy) = Configuration.Instance.KeyboardControls.GetLeftStick(keyboard);
|
||||
(rightJoystickDx, rightJoystickDy) = Configuration.Instance.KeyboardControls.GetRightStick(keyboard);
|
||||
}
|
||||
|
||||
if (!hidKeyboard.HasValue)
|
||||
{
|
||||
hidKeyboard = new HidKeyboard
|
||||
{
|
||||
Modifier = 0,
|
||||
Keys = new int[0x8]
|
||||
};
|
||||
}
|
||||
|
||||
currentButton |= Configuration.Instance.GamepadControls.GetButtons();
|
||||
|
||||
|
@ -255,6 +270,11 @@ namespace Ryujinx
|
|||
_device.Hid.SetTouchPoints();
|
||||
}
|
||||
|
||||
if (Configuration.Instance.EnableKeyboard && hidKeyboard.HasValue)
|
||||
{
|
||||
_device.Hid.WriteKeyboard(hidKeyboard.Value);
|
||||
}
|
||||
|
||||
HidControllerBase controller = _device.Hid.PrimaryController;
|
||||
|
||||
controller.SendInput(currentButton, leftJoystick, rightJoystick);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue