[rcore] IsMouseButton*(), random key codes return unexpected results#5516
Merged
Conversation
…to true when the button code is outside the range of mouse button
Owner
|
@jasoncnm oh, interesting issue... thanks for the review. In raylib I try to avoid/minimiz the early returns, can you refactor it to be code to be: if ((button < 0) || (button > MOUSE_BUTTON_BACK))
{
if ((CORE.Input.Mouse.currentButtonState[button] == 1) && (CORE.Input.Mouse.previousButtonState[button] == 0)) pressed = true;
}It will be consistent with |
IsMouseButton*(), random key codes return unexpected results
Contributor
Author
|
@raysan5 I think Is the correct change, and that's updated. Thanks for the feedback! |
Owner
|
@jasoncnm Thanks for the review! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, today I've encountered a weird behaviour when I accidentally wrote
In my raylib project, it will sometimes return true when I'm moving my cursor. So I've written a simple test code as such
And I got the same result, when I move around the cursor on the screen, it will increase
down_countandpress_count.Here is the video of it.
2026-01-27.21-27-34.mp4
What I did to fix this was return false when the keycodes are not valid. i.e
if ((button < 0) || (button > MOUSE_BUTTON_BACK)) return false;