1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-27 08:32:01 +00:00
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 20:01:59 +00:00
bool _wired = false;
2018-12-01 20:01:59 +00:00
public HidProController(Switch device) : base(HidControllerType.ProController, device)
{
2018-12-01 20:01:59 +00:00
_wired = true;
}
2018-12-01 20:01:59 +00:00
public override void Connect(HidControllerId controllerId)
{
2018-12-01 20:01:59 +00:00
base.Connect(controllerId);
2018-12-01 20:01:59 +00:00
HidControllerColorDesc singleColorDesc =
HidControllerColorDesc.ColorDescColorsNonexistent;
2018-12-01 20:01:59 +00:00
HidControllerColorDesc splitColorDesc = 0;
2018-12-01 20:01:59 +00:00
NpadColor singleColorBody = NpadColor.Black;
NpadColor singleColorButtons = NpadColor.Black;
2018-12-01 20:01:59 +00: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 20:01:59 +00:00
HidControllerButtons buttons,
HidJoystickPosition leftStick,
HidJoystickPosition rightStick)
{
2018-12-01 20:01:59 +00:00
long controllerOffset = WriteInput(buttons, leftStick, rightStick, HidControllerLayouts.ProController);
2018-12-01 20:01:59 +00:00
Device.Memory.WriteInt64(controllerOffset + 0x28,
(Connected ? (uint)HidControllerConnState.ControllerStateConnected : 0) |
(_wired ? (uint)HidControllerConnState.ControllerStateWired : 0));
}
}
}