From f2af14d6935a0c39cfc498306dcfd9f430816422 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Wed, 7 Feb 2024 11:38:54 -0500 Subject: [PATCH 1/3] Add keyboard test --- clib.json | 1 + include/raylib-cpp.hpp | 1 + tests/raylib_cpp_test.cpp | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/clib.json b/clib.json index 5a5fafba..bbdd1cc9 100644 --- a/clib.json +++ b/clib.json @@ -32,6 +32,7 @@ "include/Functions.hpp", "include/Gamepad.hpp", "include/Image.hpp", + "include/Keyboard.hpp", "include/Material.hpp", "include/Matrix.hpp", "include/Mesh.hpp", diff --git a/include/raylib-cpp.hpp b/include/raylib-cpp.hpp index 88cd6ef9..b2feba0c 100644 --- a/include/raylib-cpp.hpp +++ b/include/raylib-cpp.hpp @@ -42,6 +42,7 @@ #include "./Functions.hpp" #include "./Gamepad.hpp" #include "./Image.hpp" +#include "./Keyboard.hpp" #include "./Material.hpp" #include "./Matrix.hpp" #include "./Mesh.hpp" diff --git a/tests/raylib_cpp_test.cpp b/tests/raylib_cpp_test.cpp index 6d188c61..0c6331b0 100644 --- a/tests/raylib_cpp_test.cpp +++ b/tests/raylib_cpp_test.cpp @@ -69,6 +69,11 @@ int main(int argc, char *argv[]) { AssertEqual(image.GetHeight(), 50); } + // Keyboard + { + AssertNot(raylib::Keyboard::GetKeyPressed(KEY_MINUS)); + } + // raylib::LoadDirectoryFiles() { std::vector files = raylib::LoadDirectoryFiles(::GetWorkingDirectory()); From eb2cca24893953a17eb66df9faaba4895e63f99b Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Wed, 7 Feb 2024 12:45:17 -0500 Subject: [PATCH 2/3] It's IsKeyPressed() --- tests/raylib_cpp_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/raylib_cpp_test.cpp b/tests/raylib_cpp_test.cpp index 0c6331b0..375eff46 100644 --- a/tests/raylib_cpp_test.cpp +++ b/tests/raylib_cpp_test.cpp @@ -71,7 +71,7 @@ int main(int argc, char *argv[]) { // Keyboard { - AssertNot(raylib::Keyboard::GetKeyPressed(KEY_MINUS)); + AssertNot(raylib::Keyboard::IsKeyPressed(KEY_MINUS)); } // raylib::LoadDirectoryFiles() From 4fbbd70ed75712550c38a166f1b8e37196aa8ee4 Mon Sep 17 00:00:00 2001 From: swiderskis <66870324+swiderskis@users.noreply.github.com> Date: Wed, 7 Feb 2024 20:51:23 +0000 Subject: [PATCH 3/3] Fixed Rkeyboard::GetKeyPressed() and RKeyboard::GetCharPressed() methods implicitly converting to bool --- include/Keyboard.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Keyboard.hpp b/include/Keyboard.hpp index b111d2c5..635fb4b0 100644 --- a/include/Keyboard.hpp +++ b/include/Keyboard.hpp @@ -47,14 +47,14 @@ class Keyboard { /** * Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty */ - static bool GetKeyPressed() { + static int GetKeyPressed() { return ::GetKeyPressed(); } /** * Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty */ - static bool GetCharPressed() { + static int GetCharPressed() { return ::GetCharPressed(); } };