17.01.2021
+ WPF-Support + Game Controller System + GameKeybind System + SM_WPF_TEST
This commit is contained in:
parent
af90d617d3
commit
6f23a80f7f
60 changed files with 1536 additions and 143 deletions
39
SMOptionals/SM.Game/Controls/GameController.cs
Normal file
39
SMOptionals/SM.Game/Controls/GameController.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using SharpDX.XInput;
|
||||
|
||||
namespace SM.Game.Controls
|
||||
{
|
||||
public struct GameController
|
||||
{
|
||||
public static float GlobalDeadband = 2500;
|
||||
|
||||
private Controller _controller;
|
||||
|
||||
public float Deadband { get; set; }
|
||||
public bool IsConnected => _controller.IsConnected;
|
||||
|
||||
public UserIndex Index { get; private set; }
|
||||
|
||||
public GameController(int id) : this((UserIndex)id)
|
||||
{}
|
||||
|
||||
public GameController(UserIndex index = UserIndex.Any)
|
||||
{
|
||||
_controller = new Controller(index);
|
||||
Index = index;
|
||||
Deadband = GlobalDeadband;
|
||||
}
|
||||
|
||||
public GameControllerState GetState()
|
||||
{
|
||||
if (!IsConnected)
|
||||
{
|
||||
return new GameControllerState(true);
|
||||
}
|
||||
|
||||
Gamepad state = _controller.GetState().Gamepad;
|
||||
|
||||
return new GameControllerState(state, ref this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue