mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 03:56:31 +00:00
4ecb74f6b6
* FNA projects * update actions fixes MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file. * build tests * remove test for issue #633 * FNA/XNA compatible * GraphicsDevice Extensions * remove MockGameWindow --------- Co-authored-by: Christopher Whitley <103014489+AristurtleDev@users.noreply.github.com>
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
using System;
|
|
using Microsoft.Xna.Framework.Input;
|
|
|
|
namespace MonoGame.Extended.Input
|
|
{
|
|
public static class KeyboardStateExtensions
|
|
{
|
|
|
|
#if FNA
|
|
// MomoGame compatibility layer
|
|
|
|
/// <summary>
|
|
/// Fills an array of values holding keys that are currently being pressed.
|
|
/// Note: This extension method is not allocation free when targeting FNA.
|
|
/// </summary>
|
|
/// <param name="keys">The keys array to fill.
|
|
internal static void GetPressedKeys(this KeyboardState value, Keys[] keys)
|
|
{
|
|
Keys[] pressedKeys = value.GetPressedKeys();
|
|
Array.Copy(pressedKeys, keys, pressedKeys.Length);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the number of pressed keys in this KeyboardState.
|
|
/// </summary>
|
|
/// Note: This extension method is not allocation free when targeting FNA.
|
|
/// <returns>An integer representing the number of keys currently pressed in this KeyboardState.</returns>
|
|
|
|
internal static int GetPressedKeyCount(this KeyboardState value)
|
|
{
|
|
Keys[] pressedKeys = value.GetPressedKeys();
|
|
return pressedKeys.Length;
|
|
}
|
|
#endif
|
|
}
|
|
} |