Correctly use ScriptGlue functions for Input queries

This commit is contained in:
Simon Lübeß
2026-09-03 22:36:15 +02:00
parent 5c18f61da4
commit 6c184aafe0
+15 -23
View File
@@ -1,4 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace GlitchyEngine;
@@ -11,66 +12,57 @@ public static class Input
/// Returns <see langword="true"/> if the specified key is in the pressed down state.
/// </summary>
/// <param name="key">The key to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool IsKeyPressed(Key key);
public static bool IsKeyPressed(Key key) => ScriptGlue.Input_IsKeyPressed(key);
/// <summary>
/// Returns <see langword="true"/> if the specified <see cref="key"/> is in the released state.
/// </summary>
/// <param name="key">The key to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool IsKeyReleased(Key key);
public static bool IsKeyReleased(Key key) => ScriptGlue.Input_IsKeyReleased(key);
/// <summary>
/// Returns <see langword="true"/> if the state of the specified <see cref="key"/> changed this frame (i.e. changed from pressed to released or from released to pressed).
/// </summary>
/// <param name="key">The key to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool IsKeyToggled(Key key);
public static bool IsKeyToggled(Key key) => ScriptGlue.Input_IsKeyToggled(key);
/// <summary>
/// Returns <see langword="true"/> if <see cref="key"/> is being pressed down this frame
/// (<see cref="IsKeyPressed"/> was <see langword="false"/> last frame and is <see langword="true"/> this frame).
/// </summary>
/// <param name="key">The key to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool IsKeyPressing(Key key);
public static bool IsKeyPressing(Key key) => ScriptGlue.Input_IsKeyPressing(key);
/// <summary>
/// Returns <see langword="true"/> if <see cref="key"/> is being released this frame
/// (<see cref="IsKeyPressed"/> was <see langword="true"/> last frame and is <see langword="false"/> this frame).
/// </summary>
/// <param name="key">The key to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool IsKeyReleasing(Key key);
public static bool IsKeyReleasing(Key key) => ScriptGlue.Input_IsKeyReleasing(key);
/// <summary>
/// Returns <see langword="true"/> if the specified mouse button is in the pressed down state.
/// </summary>
/// <param name="mouseButton">The button to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool IsMouseButtonPressed(MouseButton mouseButton);
public static bool IsMouseButtonPressed(MouseButton mouseButton) => ScriptGlue.Input_IsMouseButtonPressed(mouseButton);
/// <summary>
/// Returns <see langword="true"/> if the specified mouse button is in the released state.
/// </summary>
/// <param name="mouseButton">The button to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool IsMouseButtonReleased(MouseButton mouseButton);
public static bool IsMouseButtonReleased(MouseButton mouseButton) => ScriptGlue.Input_IsMouseButtonReleased(mouseButton);
/// <summary>
/// Returns <see langword="true"/> if the mouse button is being pressed down this frame
/// (<see cref="IsMouseButtonPressed"/> was <see langword="false"/> last frame and is <see langword="true"/> this frame).
/// </summary>
/// <param name="mouseButton">The button to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool IsMouseButtonPressing(MouseButton mouseButton);
public static bool IsMouseButtonPressing(MouseButton mouseButton) => ScriptGlue.Input_IsMouseButtonPressing(mouseButton);
/// <summary>
/// Returns <see langword="true"/> if the mouse button is being released this frame
/// (<see cref="IsMouseButtonPressed"/> was <see langword="true"/> last frame and is <see langword="false"/> this frame).
/// </summary>
/// <param name="mouseButton">The button to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool IsMouseButtonReleasing(MouseButton mouseButton);
public static bool IsMouseButtonReleasing(MouseButton mouseButton) => ScriptGlue.Input_IsMouseButtonReleasing(mouseButton);
}