fix IsMouseButtonDown\Pressed\Released\Up will get randomly returned to true when the button code is outside the range of mouse button
This commit is contained in:
parent
0f15214e67
commit
6ff74563ef
|
|
@ -4047,12 +4047,15 @@ float GetGamepadAxisMovement(int gamepad, int axis)
|
|||
// NOTE: Functions with a platform-specific implementation on rcore_<platform>.c
|
||||
//void SetMousePosition(int x, int y)
|
||||
//void SetMouseCursor(int cursor)
|
||||
#define ArrayCount(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
|
||||
// Check if a mouse button has been pressed once
|
||||
bool IsMouseButtonPressed(int button)
|
||||
{
|
||||
bool pressed = false;
|
||||
|
||||
if ((button < 0) || (button > MOUSE_BUTTON_BACK)) return false;
|
||||
|
||||
if ((CORE.Input.Mouse.currentButtonState[button] == 1) && (CORE.Input.Mouse.previousButtonState[button] == 0)) pressed = true;
|
||||
|
||||
// Map touches to mouse buttons checking
|
||||
|
|
@ -4066,6 +4069,8 @@ bool IsMouseButtonDown(int button)
|
|||
{
|
||||
bool down = false;
|
||||
|
||||
if ((button < 0) || (button > MOUSE_BUTTON_BACK)) return false;
|
||||
|
||||
if (CORE.Input.Mouse.currentButtonState[button] == 1) down = true;
|
||||
|
||||
// NOTE: Touches are considered like mouse buttons
|
||||
|
|
@ -4079,6 +4084,8 @@ bool IsMouseButtonReleased(int button)
|
|||
{
|
||||
bool released = false;
|
||||
|
||||
if ((button < 0) || (button > MOUSE_BUTTON_BACK)) return false;
|
||||
|
||||
if ((CORE.Input.Mouse.currentButtonState[button] == 0) && (CORE.Input.Mouse.previousButtonState[button] == 1)) released = true;
|
||||
|
||||
// Map touches to mouse buttons checking
|
||||
|
|
@ -4092,6 +4099,8 @@ bool IsMouseButtonUp(int button)
|
|||
{
|
||||
bool up = false;
|
||||
|
||||
if ((button < 0) || (button > MOUSE_BUTTON_BACK)) return false;
|
||||
|
||||
if (CORE.Input.Mouse.currentButtonState[button] == 0) up = true;
|
||||
|
||||
// NOTE: Touches are considered like mouse buttons
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user