mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-21 04:59:17 -05:00
Compare commits
4 Commits
63e4fd838d
...
de7fc12be0
| Author | SHA1 | Date | |
|---|---|---|---|
| de7fc12be0 | |||
| 8a2da96eed | |||
| af37fa2a96 | |||
| d0a6892989 |
39
src/rcore.c
39
src/rcore.c
@ -3831,7 +3831,6 @@ void PlayAutomationEvent(AutomationEvent event)
|
||||
// Check if a key has been pressed once
|
||||
bool IsKeyPressed(int key)
|
||||
{
|
||||
|
||||
bool pressed = false;
|
||||
|
||||
if ((key > 0) && (key < MAX_KEYBOARD_KEYS))
|
||||
@ -3973,8 +3972,10 @@ bool IsGamepadButtonPressed(int gamepad, int button)
|
||||
{
|
||||
bool pressed = false;
|
||||
|
||||
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS) &&
|
||||
(CORE.Input.Gamepad.previousButtonState[gamepad][button] == 0) && (CORE.Input.Gamepad.currentButtonState[gamepad][button] == 1)) pressed = true;
|
||||
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS))
|
||||
{
|
||||
if ((CORE.Input.Gamepad.previousButtonState[gamepad][button] == 0) && (CORE.Input.Gamepad.currentButtonState[gamepad][button] == 1)) pressed = true;
|
||||
}
|
||||
|
||||
return pressed;
|
||||
}
|
||||
@ -3984,8 +3985,10 @@ bool IsGamepadButtonDown(int gamepad, int button)
|
||||
{
|
||||
bool down = false;
|
||||
|
||||
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS) &&
|
||||
(CORE.Input.Gamepad.currentButtonState[gamepad][button] == 1)) down = true;
|
||||
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS))
|
||||
{
|
||||
if (CORE.Input.Gamepad.currentButtonState[gamepad][button] == 1) down = true;
|
||||
}
|
||||
|
||||
return down;
|
||||
}
|
||||
@ -3995,8 +3998,10 @@ bool IsGamepadButtonReleased(int gamepad, int button)
|
||||
{
|
||||
bool released = false;
|
||||
|
||||
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS) &&
|
||||
(CORE.Input.Gamepad.previousButtonState[gamepad][button] == 1) && (CORE.Input.Gamepad.currentButtonState[gamepad][button] == 0)) released = true;
|
||||
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS))
|
||||
{
|
||||
if ((CORE.Input.Gamepad.previousButtonState[gamepad][button] == 1) && (CORE.Input.Gamepad.currentButtonState[gamepad][button] == 0)) released = true;
|
||||
}
|
||||
|
||||
return released;
|
||||
}
|
||||
@ -4006,8 +4011,10 @@ bool IsGamepadButtonUp(int gamepad, int button)
|
||||
{
|
||||
bool up = false;
|
||||
|
||||
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS) &&
|
||||
(CORE.Input.Gamepad.currentButtonState[gamepad][button] == 0)) up = true;
|
||||
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS))
|
||||
{
|
||||
if (CORE.Input.Gamepad.currentButtonState[gamepad][button] == 0) up = true;
|
||||
}
|
||||
|
||||
return up;
|
||||
}
|
||||
@ -4053,10 +4060,13 @@ 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;
|
||||
|
||||
// Map touches to mouse buttons checking
|
||||
if ((CORE.Input.Touch.currentTouchState[button] == 1) && (CORE.Input.Touch.previousTouchState[button] == 0)) pressed = true;
|
||||
}
|
||||
|
||||
return pressed;
|
||||
}
|
||||
@ -4066,10 +4076,13 @@ bool IsMouseButtonDown(int button)
|
||||
{
|
||||
bool down = false;
|
||||
|
||||
if ((button >= 0) && (button <= MOUSE_BUTTON_BACK))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
return down;
|
||||
}
|
||||
@ -4079,10 +4092,13 @@ 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;
|
||||
|
||||
// Map touches to mouse buttons checking
|
||||
if ((CORE.Input.Touch.currentTouchState[button] == 0) && (CORE.Input.Touch.previousTouchState[button] == 1)) released = true;
|
||||
}
|
||||
|
||||
return released;
|
||||
}
|
||||
@ -4092,10 +4108,13 @@ bool IsMouseButtonUp(int button)
|
||||
{
|
||||
bool up = false;
|
||||
|
||||
if ((button >= 0) && (button <= MOUSE_BUTTON_BACK))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
return up;
|
||||
}
|
||||
@ -4104,6 +4123,7 @@ bool IsMouseButtonUp(int button)
|
||||
int GetMouseX(void)
|
||||
{
|
||||
int mouseX = (int)((CORE.Input.Mouse.currentPosition.x + CORE.Input.Mouse.offset.x)*CORE.Input.Mouse.scale.x);
|
||||
|
||||
return mouseX;
|
||||
}
|
||||
|
||||
@ -4111,6 +4131,7 @@ int GetMouseX(void)
|
||||
int GetMouseY(void)
|
||||
{
|
||||
int mouseY = (int)((CORE.Input.Mouse.currentPosition.y + CORE.Input.Mouse.offset.y)*CORE.Input.Mouse.scale.y);
|
||||
|
||||
return mouseY;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user