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