mirror of
https://github.com/raysan5/raylib.git
synced 2026-01-29 18:55:44 +00:00
[rcore] IsMouseButton*(), random key codes return unexpected results (#5516)
* update * update * stuff * update * move headerfile to root * delete .h * update ignore * fix IsMouseButtonDown\Pressed\Released\Up will get randomly returned to true when the button code is outside the range of mouse button * remove unessary macro * refactor IsMouseButton*() early returns
This commit is contained in:
parent
63e4fd838d
commit
d0a6892989
60
src/rcore.c
60
src/rcore.c
@ -4052,12 +4052,17 @@ float GetGamepadAxisMovement(int gamepad, int axis)
|
||||
bool IsMouseButtonPressed(int button)
|
||||
{
|
||||
bool pressed = false;
|
||||
|
||||
if ((button >= 0) && (button <= MOUSE_BUTTON_BACK))
|
||||
{
|
||||
|
||||
if ((CORE.Input.Mouse.currentButtonState[button] == 1) && (CORE.Input.Mouse.previousButtonState[button] == 0)) pressed = true;
|
||||
|
||||
if ((CORE.Input.Mouse.currentButtonState[button] == 1) && (CORE.Input.Mouse.previousButtonState[button] == 0)) pressed = true;
|
||||
|
||||
// Map touches to mouse buttons checking
|
||||
if ((CORE.Input.Touch.currentTouchState[button] == 1) && (CORE.Input.Touch.previousTouchState[button] == 0)) pressed = true;
|
||||
|
||||
// Map touches to mouse buttons checking
|
||||
if ((CORE.Input.Touch.currentTouchState[button] == 1) && (CORE.Input.Touch.previousTouchState[button] == 0)) pressed = true;
|
||||
|
||||
}
|
||||
|
||||
return pressed;
|
||||
}
|
||||
|
||||
@ -4065,12 +4070,17 @@ bool IsMouseButtonPressed(int button)
|
||||
bool IsMouseButtonDown(int button)
|
||||
{
|
||||
bool down = false;
|
||||
|
||||
if ((button >= 0) && (button <= MOUSE_BUTTON_BACK))
|
||||
{
|
||||
|
||||
if (CORE.Input.Mouse.currentButtonState[button] == 1) down = true;
|
||||
|
||||
if (CORE.Input.Mouse.currentButtonState[button] == 1) down = true;
|
||||
|
||||
// NOTE: Touches are considered like mouse buttons
|
||||
if (CORE.Input.Touch.currentTouchState[button] == 1) down = true;
|
||||
|
||||
// NOTE: Touches are considered like mouse buttons
|
||||
if (CORE.Input.Touch.currentTouchState[button] == 1) down = true;
|
||||
|
||||
}
|
||||
|
||||
return down;
|
||||
}
|
||||
|
||||
@ -4078,12 +4088,17 @@ bool IsMouseButtonDown(int button)
|
||||
bool IsMouseButtonReleased(int button)
|
||||
{
|
||||
bool released = false;
|
||||
|
||||
if ((button >= 0) && (button <= MOUSE_BUTTON_BACK))
|
||||
{
|
||||
|
||||
if ((CORE.Input.Mouse.currentButtonState[button] == 0) && (CORE.Input.Mouse.previousButtonState[button] == 1)) released = true;
|
||||
|
||||
if ((CORE.Input.Mouse.currentButtonState[button] == 0) && (CORE.Input.Mouse.previousButtonState[button] == 1)) released = true;
|
||||
|
||||
// Map touches to mouse buttons checking
|
||||
if ((CORE.Input.Touch.currentTouchState[button] == 0) && (CORE.Input.Touch.previousTouchState[button] == 1)) released = true;
|
||||
|
||||
// Map touches to mouse buttons checking
|
||||
if ((CORE.Input.Touch.currentTouchState[button] == 0) && (CORE.Input.Touch.previousTouchState[button] == 1)) released = true;
|
||||
|
||||
}
|
||||
|
||||
return released;
|
||||
}
|
||||
|
||||
@ -4091,12 +4106,17 @@ bool IsMouseButtonReleased(int button)
|
||||
bool IsMouseButtonUp(int button)
|
||||
{
|
||||
bool up = false;
|
||||
|
||||
if ((button >= 0) && (button <= MOUSE_BUTTON_BACK))
|
||||
{
|
||||
|
||||
if (CORE.Input.Mouse.currentButtonState[button] == 0) up = true;
|
||||
|
||||
if (CORE.Input.Mouse.currentButtonState[button] == 0) up = true;
|
||||
|
||||
// NOTE: Touches are considered like mouse buttons
|
||||
if (CORE.Input.Touch.currentTouchState[button] == 0) up = true;
|
||||
|
||||
// NOTE: Touches are considered like mouse buttons
|
||||
if (CORE.Input.Touch.currentTouchState[button] == 0) up = true;
|
||||
|
||||
}
|
||||
|
||||
return up;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user