Add vibration test button to core_input_gamepad (#5362)

This commit is contained in:
Serhii Zasenko
2025-11-18 22:27:50 +02:00
committed by GitHub
parent a24e65d8e1
commit f51204821a

View File

@ -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);
}