HID SharedMem Rework (#1003)

* Delete old HLE.Input

* Add new HLE Input.

git shows Hid.cs as modified because of the same name. It is new.

* Change HID Service

* Change Ryujinx UI to reflect new Input

* Add basic ControllerApplet

* Add DebugPad

Should fix Kirby Star Allies

* Address Ac_K's comments

* Moved all of HLE.Input to Services.Hid
* Separated all structs and enums each to a file
* Removed vars
* Made some naming changes to align with switchbrew
* Added official joycon colors

As an aside, fixed a mistake in touchscreen headers and added checks to
important SharedMem structs at init time.

* Further address Ac_K's comments

* Addressed gdkchan's and some more Ac_K's comments

* Address AcK's review comments

* Address AcK's second review comments

* Replace missed Marshal.SizeOf and address gdkchan's comments
This commit is contained in:
mageven 2020-04-03 05:40:02 +05:30 committed by GitHub
parent 5b5239ab5b
commit 2365ddfc36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
105 changed files with 1500 additions and 1044 deletions

View file

@ -7,7 +7,7 @@ using OpenTK.Platform;
using Ryujinx.Configuration;
using Ryujinx.Graphics.OpenGL;
using Ryujinx.HLE;
using Ryujinx.HLE.Input;
using Ryujinx.HLE.HOS.Services.Hid;
using Ryujinx.Ui;
using System;
using System.Collections.Generic;
@ -382,10 +382,10 @@ namespace Ryujinx.Ui
}
HotkeyButtons currentHotkeyButtons = 0;
ControllerButtons currentButton = 0;
ControllerKeys currentButton = 0;
JoystickPosition leftJoystick;
JoystickPosition rightJoystick;
HLE.Input.Keyboard? hidKeyboard = null;
KeyboardInput? hidKeyboard = null;
int leftJoystickDx = 0;
int leftJoystickDy = 0;
@ -417,7 +417,7 @@ namespace Ryujinx.Ui
if (!hidKeyboard.HasValue)
{
hidKeyboard = new HLE.Input.Keyboard
hidKeyboard = new KeyboardInput
{
Modifier = 0,
Keys = new int[0x8]
@ -489,8 +489,8 @@ namespace Ryujinx.Ui
TouchPoint currentPoint = new TouchPoint
{
X = mX,
Y = mY,
X = (uint)mX,
Y = (uint)mY,
// Placeholder values till more data is acquired
DiameterX = 10,
@ -500,23 +500,29 @@ namespace Ryujinx.Ui
hasTouch = true;
_device.Hid.SetTouchPoints(currentPoint);
_device.Hid.Touchscreen.Update(currentPoint);
}
}
if (!hasTouch)
{
_device.Hid.SetTouchPoints();
_device.Hid.Touchscreen.Update();
}
if (ConfigurationState.Instance.Hid.EnableKeyboard && hidKeyboard.HasValue)
{
_device.Hid.WriteKeyboard(hidKeyboard.Value);
_device.Hid.Keyboard.Update(hidKeyboard.Value);
}
BaseController controller = _device.Hid.PrimaryController;
_device.Hid.DebugPad.Update();
controller.SendInput(currentButton, leftJoystick, rightJoystick);
_device.Hid.Npads.SetGamepadsInput(new GamepadInput
{
PlayerId = PlayerIndex.Auto,
Buttons = currentButton,
LStick = leftJoystick,
RStick = rightJoystick
});
// Toggle vsync
if (currentHotkeyButtons.HasFlag(HotkeyButtons.ToggleVSync) &&