using System.Runtime.CompilerServices;
namespace Ryujinx.Input
{
///
/// Represent an emulated keyboard.
///
public interface IKeyboard : IGamepad
{
///
/// Check if a given key is pressed on the keyboard.
///
/// The key
/// True if the given key is pressed on the keyboard
bool IsPressed(Key key);
///
/// Get a snaphost of the state of the keyboard.
///
/// A snaphost of the state of the keyboard.
KeyboardStateSnapshot GetKeyboardStateSnapshot();
///
/// Get a snaphost of the state of a keyboard.
///
/// The keyboard to do a snapshot of
/// A snaphost of the state of the keyboard.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static KeyboardStateSnapshot GetStateSnapshot(IKeyboard keyboard)
{
bool[] keysState = new bool[(int)Key.Count];
for (Key key = 0; key < Key.Count; key++)
{
keysState[(int)key] = keyboard.IsPressed(key);
}
return new KeyboardStateSnapshot(keysState);
}
}
}