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
68
Ryujinx.HLE/Input/Controller/NpadController.cs
Normal file
68
Ryujinx.HLE/Input/Controller/NpadController.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
namespace Ryujinx.HLE.Input
|
||||
{
|
||||
public class NpadController : BaseController
|
||||
{
|
||||
private (NpadColor Left, NpadColor Right) _npadBodyColors;
|
||||
private (NpadColor Left, NpadColor Right) _npadButtonColors;
|
||||
|
||||
private bool _isHalf;
|
||||
|
||||
public NpadController(
|
||||
ControllerStatus controllerStatus,
|
||||
Switch device,
|
||||
(NpadColor, NpadColor) npadBodyColors,
|
||||
(NpadColor, NpadColor) npadButtonColors) : base(device, controllerStatus)
|
||||
{
|
||||
_npadBodyColors = npadBodyColors;
|
||||
_npadButtonColors = npadButtonColors;
|
||||
}
|
||||
|
||||
public override void Connect(ControllerId controllerId)
|
||||
{
|
||||
if (HidControllerType != ControllerStatus.NpadLeft && HidControllerType != ControllerStatus.NpadRight)
|
||||
{
|
||||
_isHalf = false;
|
||||
}
|
||||
|
||||
ConnectionState = ControllerConnectionState.ControllerStateConnected;
|
||||
|
||||
if (controllerId == ControllerId.ControllerHandheld)
|
||||
ConnectionState |= ControllerConnectionState.ControllerStateWired;
|
||||
|
||||
ControllerColorDescription singleColorDesc =
|
||||
ControllerColorDescription.ColorDescriptionColorsNonexistent;
|
||||
|
||||
ControllerColorDescription splitColorDesc = 0;
|
||||
|
||||
NpadColor singleBodyColor = NpadColor.Black;
|
||||
NpadColor singleButtonColor = NpadColor.Black;
|
||||
|
||||
Initialize(_isHalf,
|
||||
(_npadBodyColors.Left, _npadBodyColors.Right),
|
||||
(_npadButtonColors.Left, _npadButtonColors.Right),
|
||||
singleColorDesc,
|
||||
splitColorDesc,
|
||||
singleBodyColor,
|
||||
singleButtonColor );
|
||||
|
||||
base.Connect(controllerId);
|
||||
|
||||
var _currentLayout = ControllerLayouts.HandheldJoined;
|
||||
|
||||
switch (HidControllerType)
|
||||
{
|
||||
case ControllerStatus.NpadLeft:
|
||||
_currentLayout = ControllerLayouts.Left;
|
||||
break;
|
||||
case ControllerStatus.NpadRight:
|
||||
_currentLayout = ControllerLayouts.Right;
|
||||
break;
|
||||
case ControllerStatus.NpadPair:
|
||||
_currentLayout = ControllerLayouts.Joined;
|
||||
break;
|
||||
}
|
||||
|
||||
SetLayout(_currentLayout);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue