summaryrefslogtreecommitdiffhomepage
path: root/src/core.c
diff options
context:
space:
mode:
authorRay <[email protected]>2020-03-03 16:43:15 +0100
committerRay <[email protected]>2020-03-03 16:43:15 +0100
commit6b8f30964dc9490fb4725a7c4764d793202ee48f (patch)
tree5cd5a72ff4d5f1a1e5d7adbe72c77ddc7808adf1 /src/core.c
parentdc2e5c17511e520250cbf73e4dd8a4b08fb7b082 (diff)
downloadraylib-6b8f30964dc9490fb4725a7c4764d793202ee48f.tar.gz
raylib-6b8f30964dc9490fb4725a7c4764d793202ee48f.zip
WARNING: Corrected issue with IsKeyDown() #1119
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/core.c b/src/core.c
index 8981799a..42145158 100644
--- a/src/core.c
+++ b/src/core.c
@@ -477,8 +477,6 @@ static void SwapBuffers(void); // Copy back buffer to f
static void InitTimer(void); // Initialize timer
static void Wait(float ms); // Wait for some milliseconds (stop program execution)
-//static int GetKeyState(int key);
-//static int GetMouseButtonState(int button);
static int GetGamepadButton(int button); // Get gamepad button generic to all platforms
static int GetGamepadAxis(int axis); // Get gamepad axis generic to all platforms
static void PollInputEvents(void); // Register user events
@@ -3988,12 +3986,20 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
}
#endif // SUPPORT_SCREEN_CAPTURE
}
- else CORE.Input.Keyboard.currentKeyState[key] = action;
+ else
+ {
+ // WARNING: GLFW could return GLFW_REPEAT, we need to consider it as 1
+ // to work properly with our implementation (IsKeyDown/IsKeyUp checks)
+ if (action == GLFW_RELEASE) CORE.Input.Keyboard.currentKeyState[key] = 0;
+ else CORE.Input.Keyboard.currentKeyState[key] = 1;
+ }
}
// GLFW3 Mouse Button Callback, runs on mouse button pressed
static void MouseButtonCallback(GLFWwindow *window, int button, int action, int mods)
{
+ // WARNING: GLFW could only return GLFW_PRESS (1) or GLFW_RELEASE (0) for now,
+ // but future releases may add more actions (i.e. GLFW_REPEAT)
CORE.Input.Mouse.currentButtonState[button] = action;
#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES)