From ea1339a8e82b6639a2efc0dcf337233d32df1c35 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Sat, 16 Mar 2024 12:15:40 -0400 Subject: [PATCH] Added isKeyPressed C# api --- Nuake/src/Scripting/NetModules/InputNetAPI.cpp | 7 +++++++ NuakeNet/src/Input.cs | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/Nuake/src/Scripting/NetModules/InputNetAPI.cpp b/Nuake/src/Scripting/NetModules/InputNetAPI.cpp index 44e0d214..71e34b3a 100644 --- a/Nuake/src/Scripting/NetModules/InputNetAPI.cpp +++ b/Nuake/src/Scripting/NetModules/InputNetAPI.cpp @@ -11,6 +11,11 @@ namespace Nuake { return Input::IsKeyDown(keyCode); } + bool IsKeyPressed(int keyCode) + { + return Input::IsKeyPressed(keyCode); + } + Coral::NativeArray GetMousePosition() { Vector2 mousePosition = Input::GetMousePosition(); @@ -21,6 +26,8 @@ namespace Nuake { void InputNetAPI::RegisterMethods() { RegisterMethod("Input.IsKeyDownIcall", &IsKeyDown); + RegisterMethod("Input.IsKeyPressedIcall", &IsKeyPressed); + RegisterMethod("Input.GetMousePositionIcall", &GetMousePosition); } diff --git a/NuakeNet/src/Input.cs b/NuakeNet/src/Input.cs index 4b672af1..b986cdcc 100644 --- a/NuakeNet/src/Input.cs +++ b/NuakeNet/src/Input.cs @@ -135,6 +135,7 @@ namespace Nuake.Net public class Input { internal static unsafe delegate* IsKeyDownIcall; + internal static unsafe delegate* IsKeyPressedIcall; internal static unsafe delegate*> GetMousePositionIcall; public static bool IsKeyDown(Key keys) @@ -142,6 +143,11 @@ namespace Nuake.Net unsafe { return IsKeyDownIcall((int)keys); } } + public static bool IsKeyPressed(Key key) + { + unsafe { return IsKeyPressedIcall((int)key); } + } + public static Vector2 GetMousePosition() { NativeArray result;