From 7004eeb193b1377ea97f7039620d3c039f86ad77 Mon Sep 17 00:00:00 2001 From: Nickolas McDonald <43690021+n77y@users.noreply.github.com> Date: Sat, 19 Aug 2023 22:16:52 -0400 Subject: [PATCH] Update rcore.c --- src/rcore.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/rcore.c b/src/rcore.c index bc3829cdb8fa..53ba78a3f553 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -3746,12 +3746,10 @@ void OpenURL(const char *url) //---------------------------------------------------------------------------------- // Module Functions Definition - Input (Keyboard, Mouse, Gamepad) Functions //---------------------------------------------------------------------------------- -#define KEY_SAFE(key) (((key) >= 0) && ((key) < sizeof(CORE.Input.Keyboard.currentKeyState))) - // Check if a key has been pressed once bool IsKeyPressed(int key) { - if (!KEY_SAFE(key)) return false; + if ((key < 0) || (key >= sizeof(CORE.Input.Keyboard.currentKeyState))) return false; bool pressed = false; if ((CORE.Input.Keyboard.previousKeyState[key] == 0) && (CORE.Input.Keyboard.currentKeyState[key] == 1)) pressed = true; @@ -3762,7 +3760,7 @@ bool IsKeyPressed(int key) // Check if a key is being pressed (key held down) bool IsKeyDown(int key) { - if (!KEY_SAFE(key)) return false; + if ((key < 0) || (key >= sizeof(CORE.Input.Keyboard.currentKeyState))) return false; if (CORE.Input.Keyboard.currentKeyState[key] == 1) return true; else return false; } @@ -3770,7 +3768,7 @@ bool IsKeyDown(int key) // Check if a key has been released once bool IsKeyReleased(int key) { - if (!KEY_SAFE(key)) return false; + if ((key < 0) || (key >= sizeof(CORE.Input.Keyboard.currentKeyState))) return false; bool released = false; if ((CORE.Input.Keyboard.previousKeyState[key] == 1) && (CORE.Input.Keyboard.currentKeyState[key] == 0)) released = true; @@ -3781,7 +3779,7 @@ bool IsKeyReleased(int key) // Check if a key is NOT being pressed (key not held down) bool IsKeyUp(int key) { - if (!KEY_SAFE(key)) return false; + if ((key < 0) || (key >= sizeof(CORE.Input.Keyboard.currentKeyState))) return false; if (CORE.Input.Keyboard.currentKeyState[key] == 0) return true; else return false; } @@ -3789,7 +3787,7 @@ bool IsKeyUp(int key) // Check if a key has been repeated bool IsKeyRepeated(int key) { - if (!KEY_SAFE(key)) return false; + if ((key < 0) || (key >= sizeof(CORE.Input.Keyboard.currentKeyState))) return false; if (CORE.Input.Keyboard.repeatKeyState[key] == 1) return true; else return false; }