From e90739ca578a6e858fcdad2f4737788fae0fde03 Mon Sep 17 00:00:00 2001 From: Locria Cyber <74560659+iacore@users.noreply.github.com> Date: Tue, 13 Jun 2023 20:18:16 +0000 Subject: [PATCH] examples/core_input_gamepad: arrows left/right to choose gamepad --- examples/core/core_input_gamepad.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/core/core_input_gamepad.c b/examples/core/core_input_gamepad.c index e80a3d845..410076754 100644 --- a/examples/core/core_input_gamepad.c +++ b/examples/core/core_input_gamepad.c @@ -49,6 +49,8 @@ int main(void) SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- + int gamepad = 0; // which gamepad to display + // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { @@ -62,7 +64,9 @@ int main(void) BeginDrawing(); ClearBackground(RAYWHITE); - int gamepad = 1; + + if (IsKeyPressed(KEY_LEFT) && gamepad > 0) gamepad--; + if (IsKeyPressed(KEY_RIGHT)) gamepad++; if (IsGamepadAvailable(gamepad)) { @@ -189,7 +193,7 @@ int main(void) } else { - DrawText("GP1: NOT DETECTED", 10, 10, 10, GRAY); + DrawText(TextFormat("GP%d: NOT DETECTED", gamepad), 10, 10, 10, GRAY); DrawTexture(texXboxPad, 0, 0, LIGHTGRAY); }