Basic gamepad with force feedback impl

This commit is contained in:
2021-04-24 02:47:17 +02:00
parent db9c3cceea
commit 9f66f9d8fb
109 changed files with 205 additions and 196 deletions
+27
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
@@ -12,16 +13,22 @@ namespace EvilSatellites
{
private KeyboardState OldKeyState;
private KeyboardState NewKeyState;
private GamePadState OldPadState;
private GamePadState NewPadState;
public InputManager()
{
OldKeyState = Keyboard.GetState();
NewKeyState = Keyboard.GetState();
OldPadState = GamePad.GetState(PlayerIndex.One);
NewPadState = GamePad.GetState(PlayerIndex.One);
}
public void Update()
{
OldKeyState = NewKeyState;
NewKeyState = Keyboard.GetState();
OldPadState = NewPadState;
NewPadState = GamePad.GetState(PlayerIndex.One);
}
public bool IsJustPressed(Keys key)
@@ -43,5 +50,25 @@ namespace EvilSatellites
{
return NewKeyState.IsKeyUp(key);
}
public bool IsJustPressed(Buttons key)
{
return (NewPadState.IsButtonDown(key) && !OldPadState.IsButtonDown(key));
}
public bool IsJustReleased(Buttons key)
{
return !NewPadState.IsButtonDown(key) && OldPadState.IsButtonDown(key);
}
public bool IsPressed(Buttons key)
{
return NewPadState.IsButtonDown(key);
}
public bool IsReleased(Buttons key)
{
return !NewPadState.IsButtonDown(key);
}
}
}