using CC_Functions.W32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Input;
namespace Base
{
public static class Input
{
///
/// Check whether the Key is pressed
///
/// Key to check
/// Whether the key is pressed
public static bool IsKeyDown(Keys key)
{
try
{
return KeyboardReader.IsKeyDown(key);
}
catch (Exception e)
{
Console.WriteLine("Invader: IsKeyDown failed:\r\n" + e.ToString());
return false;
}
}
///
/// Unified input for going up
///
public static bool Up => IsKeyDown(Keys.Up) || IsKeyDown(Keys.W);
///
/// Unified input for going left
///
public static bool Left => IsKeyDown(Keys.Left) || IsKeyDown(Keys.A);
///
/// Unified input for going down
///
public static bool Down => IsKeyDown(Keys.Down) || IsKeyDown(Keys.S);
///
/// Unified input for going right
///
public static bool Right => IsKeyDown(Keys.Right) || IsKeyDown(Keys.D);
///
/// Unified input for doing something
///
public static bool Action => IsKeyDown(Keys.Space) || IsKeyDown(Keys.Q) || IsKeyDown(Keys.E);
}
}