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
+10 -18
View File
@@ -1,4 +1,5 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace GlitchyEngine; namespace GlitchyEngine;
@@ -11,66 +12,57 @@ public static class Input
/// Returns <see langword="true"/> if the specified key is in the pressed down state. /// Returns <see langword="true"/> if the specified key is in the pressed down state.
/// </summary> /// </summary>
/// <param name="key">The key to query.</param> /// <param name="key">The key to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)] public static bool IsKeyPressed(Key key) => ScriptGlue.Input_IsKeyPressed(key);
public static extern bool IsKeyPressed(Key key);
/// <summary> /// <summary>
/// Returns <see langword="true"/> if the specified <see cref="key"/> is in the released state. /// Returns <see langword="true"/> if the specified <see cref="key"/> is in the released state.
/// </summary> /// </summary>
/// <param name="key">The key to query.</param> /// <param name="key">The key to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)] public static bool IsKeyReleased(Key key) => ScriptGlue.Input_IsKeyReleased(key);
public static extern bool IsKeyReleased(Key key);
/// <summary> /// <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). /// 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> /// </summary>
/// <param name="key">The key to query.</param> /// <param name="key">The key to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)] public static bool IsKeyToggled(Key key) => ScriptGlue.Input_IsKeyToggled(key);
public static extern bool IsKeyToggled(Key key);
/// <summary> /// <summary>
/// Returns <see langword="true"/> if <see cref="key"/> is being pressed down this frame /// 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). /// (<see cref="IsKeyPressed"/> was <see langword="false"/> last frame and is <see langword="true"/> this frame).
/// </summary> /// </summary>
/// <param name="key">The key to query.</param> /// <param name="key">The key to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)] public static bool IsKeyPressing(Key key) => ScriptGlue.Input_IsKeyPressing(key);
public static extern bool IsKeyPressing(Key key);
/// <summary> /// <summary>
/// Returns <see langword="true"/> if <see cref="key"/> is being released this frame /// 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). /// (<see cref="IsKeyPressed"/> was <see langword="true"/> last frame and is <see langword="false"/> this frame).
/// </summary> /// </summary>
/// <param name="key">The key to query.</param> /// <param name="key">The key to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)] public static bool IsKeyReleasing(Key key) => ScriptGlue.Input_IsKeyReleasing(key);
public static extern bool IsKeyReleasing(Key key);
/// <summary> /// <summary>
/// Returns <see langword="true"/> if the specified mouse button is in the pressed down state. /// Returns <see langword="true"/> if the specified mouse button is in the pressed down state.
/// </summary> /// </summary>
/// <param name="mouseButton">The button to query.</param> /// <param name="mouseButton">The button to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)] public static bool IsMouseButtonPressed(MouseButton mouseButton) => ScriptGlue.Input_IsMouseButtonPressed(mouseButton);
public static extern bool IsMouseButtonPressed(MouseButton mouseButton);
/// <summary> /// <summary>
/// Returns <see langword="true"/> if the specified mouse button is in the released state. /// Returns <see langword="true"/> if the specified mouse button is in the released state.
/// </summary> /// </summary>
/// <param name="mouseButton">The button to query.</param> /// <param name="mouseButton">The button to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)] public static bool IsMouseButtonReleased(MouseButton mouseButton) => ScriptGlue.Input_IsMouseButtonReleased(mouseButton);
public static extern bool IsMouseButtonReleased(MouseButton mouseButton);
/// <summary> /// <summary>
/// Returns <see langword="true"/> if the mouse button is being pressed down this frame /// 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). /// (<see cref="IsMouseButtonPressed"/> was <see langword="false"/> last frame and is <see langword="true"/> this frame).
/// </summary> /// </summary>
/// <param name="mouseButton">The button to query.</param> /// <param name="mouseButton">The button to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)] public static bool IsMouseButtonPressing(MouseButton mouseButton) => ScriptGlue.Input_IsMouseButtonPressing(mouseButton);
public static extern bool IsMouseButtonPressing(MouseButton mouseButton);
/// <summary> /// <summary>
/// Returns <see langword="true"/> if the mouse button is being released this frame /// 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). /// (<see cref="IsMouseButtonPressed"/> was <see langword="true"/> last frame and is <see langword="false"/> this frame).
/// </summary> /// </summary>
/// <param name="mouseButton">The button to query.</param> /// <param name="mouseButton">The button to query.</param>
[MethodImpl(MethodImplOptions.InternalCall)] public static bool IsMouseButtonReleasing(MouseButton mouseButton) => ScriptGlue.Input_IsMouseButtonReleasing(mouseButton);
public static extern bool IsMouseButtonReleasing(MouseButton mouseButton);
} }