From 18bedbd0952c27b0eb8bc5df0df4acf589cef181 Mon Sep 17 00:00:00 2001 From: MichaelFiber <42419558+michaelfiber@users.noreply.github.com> Date: Sat, 14 Oct 2023 16:51:35 -0400 Subject: [core] Change axisCount to be an array (#3421) * Update `PLATFORM_DRM` implementation of `GetGamepadAxisCount` * Update * Update `PLATFORM_DRM` implementation of `GetGamepadName` * Add example to test gamepad info functions Fix typo * Update new gamepad info example * Move axis count update out of GamepadThread - race condition * Remove pointless if statement * Start integrating stuff from the mikesinput lib * Add more logging * Add semicolon * Add forgotten static * More fixes * Update axisCount to be array * More debugging * Add forgotten index to ready check * Add path logging * Missing parenthesis * Add missing slash * Fix axis count being reset to 0 * Fix missing paren * Test polling joystick button events * Major updates * Fix missing array index * Fix another missing array index * Update example * dumb logging * Wrong constant for ev.code handling * More dumb logging * Remove some logging * Add FPS to gamepad info example and try for max FPS * tweak * Revert example * Add fps back * Clean up after merge * Switch axisCount to be an array --- examples/core/core_input_gamepad_info.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/core/core_input_gamepad_info.c b/examples/core/core_input_gamepad_info.c index 84a687cd..55f0354b 100644 --- a/examples/core/core_input_gamepad_info.c +++ b/examples/core/core_input_gamepad_info.c @@ -41,15 +41,29 @@ int main(void) ClearBackground(RAYWHITE); - for (int i = 0; i < 4; i++) // by default rcore.h has a MAX_GAMEPADS of 4 so mimmic that here. + for (int i = 0; i < 4; i++) // by default rcore.h has a MAX_GAMEPADS of 4 so mimmic that here. { if (IsGamepadAvailable(i)) { - DrawText(TextFormat("Gamepad:\n\tName: %s\n\tAxes: %d", GetGamepadName(i), GetGamepadAxisCount(i)), 10, y, 20, BLACK); - y += 40; + DrawText(TextFormat("Gamepad name: %s", GetGamepadName(i)), 10, y, 20, BLACK); + y += 30; + DrawText(TextFormat("\tAxis count: %d", GetGamepadAxisCount(i)), 10, y, 20, BLACK); + y += 30; + for (int axis = 0; axis < GetGamepadAxisCount(i); axis++) + { + DrawText(TextFormat("\tAxis %d = %f", axis, GetGamepadAxisMovement(i, axis)), 10, y, 20, BLACK); + y += 30; + } + for (int button = 0; button < 32; button++) + { + DrawText(TextFormat("\tButton %d = %d", button, IsGamepadButtonDown(i, button)), 10, y, 20, BLACK); + y += 30; + } } } + DrawFPS(GetScreenWidth() - 100, 100); + EndDrawing(); } -- cgit v1.2.3