Basic gamepad with force feedback impl
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user