mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Add vibration test button to core_input_gamepad (#5362)
This commit is contained in:
@ -72,6 +72,8 @@ int main(void)
|
||||
|
||||
if (IsKeyPressed(KEY_LEFT) && gamepad > 0) gamepad--;
|
||||
if (IsKeyPressed(KEY_RIGHT)) gamepad++;
|
||||
Vector2 mousePosition = GetMousePosition();
|
||||
bool mousePressed = IsMouseButtonPressed(MOUSE_BUTTON_LEFT);
|
||||
|
||||
if (IsGamepadAvailable(gamepad))
|
||||
{
|
||||
@ -262,6 +264,14 @@ int main(void)
|
||||
DrawText(TextFormat("AXIS %i: %.02f", i, GetGamepadAxisMovement(gamepad, i)), 20, 70 + 20*i, 10, DARKGRAY);
|
||||
}
|
||||
|
||||
Rectangle vibrateButton = (Rectangle){10, 70 + 20*GetGamepadAxisCount(gamepad) + 20, 75, 10};
|
||||
if (mousePressed && CheckCollisionPointRec(mousePosition, vibrateButton)){
|
||||
SetGamepadVibration(gamepad, 1.0, 1.0, 1.0);
|
||||
}
|
||||
DrawRectangleRec(vibrateButton, SKYBLUE);
|
||||
|
||||
DrawText("VIBRATE", vibrateButton.x + 14, vibrateButton.y + 1, 10, DARKGRAY);
|
||||
|
||||
if (GetGamepadButtonPressed() != GAMEPAD_BUTTON_UNKNOWN) DrawText(TextFormat("DETECTED BUTTON: %i", GetGamepadButtonPressed()), 10, 430, 10, RED);
|
||||
else DrawText("DETECTED BUTTON: NONE", 10, 430, 10, GRAY);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user