我试图从Xbox One控制器中获取输入,但我无法让它工作。我尝试了SharpDX,但在从NuGet安装SharpDX之后,我无法添加“SharpDX.XInput”。我还尝试了XInputDotNet,并添加了对XInputDotNetPure的引用,但当我运行程序时,它会崩溃,并显示错误消息:“尝试加载具有不正确格式的程序”。如果您知道如何解决此问题,或者以另一种方式从Xbox One控制器中获取输入,请与我分享。谢谢!
private Controller m_playerControl;
标签。
m_playerControl = new Controller(UserIndex.One);
或2等3、4。
您可以通过以下方式测试Xbox控制器是否连接:
m_playerControl.IsConnected
m_state = m_playerControl.GetState();
m_lx = m_state.Gamepad.LeftThumbX;
m_ly = m_state.Gamepad.LeftThumbY;
m_lt = m_state.Gamepad.LeftTrigger;
m_lb = m_state.Gamepad.Buttons;
m_rx = m_state.Gamepad.RightThumbX;
m_ry = m_state.Gamepad.RightThumbY;
m_rt = m_state.Gamepad.RightTrigger;