Files
MonoGame.Extended/source/MonoGame.Extended.Input/KeyboardState.Extensions.cs
T
4ecb74f6b6 Fna.Extended (#893)
* 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>
2024-06-23 22:49:58 -04:00

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
}
}