2018-11-19 19:01:36 -05:00
|
|
|
|
namespace Ryujinx.HLE.Input
|
|
|
|
|
{
|
|
|
|
|
public class HidProController : HidControllerBase
|
|
|
|
|
{
|
2018-12-04 15:23:37 -05:00
|
|
|
|
bool _wired = false;
|
2018-11-19 19:01:36 -05:00
|
|
|
|
|
2018-12-04 15:23:37 -05:00
|
|
|
|
public HidProController(Switch device) : base(HidControllerType.ProController, device)
|
2018-11-19 19:01:36 -05:00
|
|
|
|
{
|
2018-12-04 15:23:37 -05:00
|
|
|
|
_wired = true;
|
2018-11-19 19:01:36 -05:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-04 15:23:37 -05:00
|
|
|
|
public override void Connect(HidControllerId controllerId)
|
2018-11-19 19:01:36 -05:00
|
|
|
|
{
|
2018-12-04 15:23:37 -05:00
|
|
|
|
base.Connect(controllerId);
|
2018-11-19 19:01:36 -05:00
|
|
|
|
|
2018-12-04 15:23:37 -05:00
|
|
|
|
HidControllerColorDesc singleColorDesc =
|
|
|
|
|
HidControllerColorDesc.ColorDescColorsNonexistent;
|
2018-11-19 19:01:36 -05:00
|
|
|
|
|
2018-12-04 15:23:37 -05:00
|
|
|
|
HidControllerColorDesc splitColorDesc = 0;
|
2018-11-19 19:01:36 -05:00
|
|
|
|
|
2018-12-04 15:23:37 -05:00
|
|
|
|
NpadColor singleColorBody = NpadColor.Black;
|
|
|
|
|
NpadColor singleColorButtons = NpadColor.Black;
|
2018-11-19 19:01:36 -05:00
|
|
|
|
|
2018-12-04 15:23:37 -05: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);
|
2018-11-19 19:01:36 -05:00
|
|
|
|
|
|
|
|
|
Connected = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void SendInput(
|
2018-12-04 15:23:37 -05:00
|
|
|
|
HidControllerButtons buttons,
|
|
|
|
|
HidJoystickPosition leftStick,
|
|
|
|
|
HidJoystickPosition rightStick)
|
2018-11-19 19:01:36 -05:00
|
|
|
|
{
|
2018-12-04 15:23:37 -05:00
|
|
|
|
long controllerOffset = WriteInput(buttons, leftStick, rightStick, HidControllerLayouts.ProController);
|
2018-11-19 19:01:36 -05:00
|
|
|
|
|
2018-12-04 15:23:37 -05:00
|
|
|
|
Device.Memory.WriteInt64(controllerOffset + 0x28,
|
|
|
|
|
(Connected ? (uint)HidControllerConnState.ControllerStateConnected : 0) |
|
|
|
|
|
(_wired ? (uint)HidControllerConnState.ControllerStateWired : 0));
|
2018-11-19 19:01:36 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|