Ryujinx/Ryujinx.HLE/Input/HidProController.cs

45 lines
1.5 KiB
C#
Raw Normal View History

namespace Ryujinx.HLE.Input
{
public class HidProController : HidControllerBase
{
2018-12-01 21:01:59 +01:00
bool _wired = false;
2018-12-01 21:01:59 +01:00
public HidProController(Switch device) : base(HidControllerType.ProController, device)
{
2018-12-01 21:01:59 +01:00
_wired = true;
}
2018-12-01 21:01:59 +01:00
public override void Connect(HidControllerId controllerId)
{
2018-12-01 21:01:59 +01:00
base.Connect(controllerId);
2018-12-01 21:01:59 +01:00
HidControllerColorDesc singleColorDesc =
HidControllerColorDesc.ColorDescColorsNonexistent;
2018-12-01 21:01:59 +01:00
HidControllerColorDesc splitColorDesc = 0;
2018-12-01 21:01:59 +01:00
NpadColor singleColorBody = NpadColor.Black;
NpadColor singleColorButtons = NpadColor.Black;
2018-12-01 21:01:59 +01:00
Device.Memory.WriteInt32(Offset + 0x08, (int)singleColorDesc);
Device.Memory.WriteInt32(Offset + 0x0c, (int)singleColorBody);
Device.Memory.WriteInt32(Offset + 0x10, (int)singleColorButtons);
Device.Memory.WriteInt32(Offset + 0x14, (int)splitColorDesc);
Connected = true;
}
public override void SendInput(
2018-12-01 21:01:59 +01:00
HidControllerButtons buttons,
HidJoystickPosition leftStick,
HidJoystickPosition rightStick)
{
2018-12-01 21:01:59 +01:00
long controllerOffset = WriteInput(buttons, leftStick, rightStick, HidControllerLayouts.ProController);
2018-12-01 21:01:59 +01:00
Device.Memory.WriteInt64(controllerOffset + 0x28,
(Connected ? (uint)HidControllerConnState.ControllerStateConnected : 0) |
(_wired ? (uint)HidControllerConnState.ControllerStateWired : 0));
}
}
}