diff --git a/examples/core/core_input_gamepad.c b/examples/core/core_input_gamepad.c index abfdb11c1..9e1bbc386 100644 --- a/examples/core/core_input_gamepad.c +++ b/examples/core/core_input_gamepad.c @@ -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); }