From ebcfc7f49e925f0ff5ddfa744e44bdc1c50ed2a2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 22 Oct 2024 22:21:35 +0000 Subject: [PATCH 1/7] Update raylib_api.* by CI --- parser/output/raylib_api.json | 92 +++++++++++++++++------------------ parser/output/raylib_api.lua | 44 ++++++++--------- parser/output/raylib_api.txt | 42 ++++++++-------- parser/output/raylib_api.xml | 24 ++++----- 4 files changed, 101 insertions(+), 101 deletions(-) diff --git a/parser/output/raylib_api.json b/parser/output/raylib_api.json index cca7241f2..9db3d7ac0 100644 --- a/parser/output/raylib_api.json +++ b/parser/output/raylib_api.json @@ -6662,6 +6662,29 @@ } ] }, + { + "name": "CheckCollisionCircleLine", + "description": "Check if circle collides with a line created betweeen two points [p1] and [p2]", + "returnType": "bool", + "params": [ + { + "type": "Vector2", + "name": "center" + }, + { + "type": "float", + "name": "radius" + }, + { + "type": "Vector2", + "name": "p1" + }, + { + "type": "Vector2", + "name": "p2" + } + ] + }, { "name": "CheckCollisionPointRec", "description": "Check if point is inside rectangle", @@ -6719,6 +6742,29 @@ } ] }, + { + "name": "CheckCollisionPointLine", + "description": "Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]", + "returnType": "bool", + "params": [ + { + "type": "Vector2", + "name": "point" + }, + { + "type": "Vector2", + "name": "p1" + }, + { + "type": "Vector2", + "name": "p2" + }, + { + "type": "int", + "name": "threshold" + } + ] + }, { "name": "CheckCollisionPointPoly", "description": "Check if point is within a polygon described by array of vertices", @@ -6765,52 +6811,6 @@ } ] }, - { - "name": "CheckCollisionPointLine", - "description": "Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]", - "returnType": "bool", - "params": [ - { - "type": "Vector2", - "name": "point" - }, - { - "type": "Vector2", - "name": "p1" - }, - { - "type": "Vector2", - "name": "p2" - }, - { - "type": "int", - "name": "threshold" - } - ] - }, - { - "name": "CheckCollisionCircleLine", - "description": "Check if circle collides with a line created betweeen two points [p1] and [p2]", - "returnType": "bool", - "params": [ - { - "type": "Vector2", - "name": "center" - }, - { - "type": "float", - "name": "radius" - }, - { - "type": "Vector2", - "name": "p1" - }, - { - "type": "Vector2", - "name": "p2" - } - ] - }, { "name": "GetCollisionRec", "description": "Get collision rectangle for two rectangles collision", diff --git a/parser/output/raylib_api.lua b/parser/output/raylib_api.lua index f1ff0aa7b..d5492cb9b 100644 --- a/parser/output/raylib_api.lua +++ b/parser/output/raylib_api.lua @@ -5264,6 +5264,17 @@ return { {type = "Rectangle", name = "rec"} } }, + { + name = "CheckCollisionCircleLine", + description = "Check if circle collides with a line created betweeen two points [p1] and [p2]", + returnType = "bool", + params = { + {type = "Vector2", name = "center"}, + {type = "float", name = "radius"}, + {type = "Vector2", name = "p1"}, + {type = "Vector2", name = "p2"} + } + }, { name = "CheckCollisionPointRec", description = "Check if point is inside rectangle", @@ -5294,6 +5305,17 @@ return { {type = "Vector2", name = "p3"} } }, + { + name = "CheckCollisionPointLine", + description = "Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]", + returnType = "bool", + params = { + {type = "Vector2", name = "point"}, + {type = "Vector2", name = "p1"}, + {type = "Vector2", name = "p2"}, + {type = "int", name = "threshold"} + } + }, { name = "CheckCollisionPointPoly", description = "Check if point is within a polygon described by array of vertices", @@ -5316,28 +5338,6 @@ return { {type = "Vector2 *", name = "collisionPoint"} } }, - { - name = "CheckCollisionPointLine", - description = "Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]", - returnType = "bool", - params = { - {type = "Vector2", name = "point"}, - {type = "Vector2", name = "p1"}, - {type = "Vector2", name = "p2"}, - {type = "int", name = "threshold"} - } - }, - { - name = "CheckCollisionCircleLine", - description = "Check if circle collides with a line created betweeen two points [p1] and [p2]", - returnType = "bool", - params = { - {type = "Vector2", name = "center"}, - {type = "float", name = "radius"}, - {type = "Vector2", name = "p1"}, - {type = "Vector2", name = "p2"} - } - }, { name = "GetCollisionRec", description = "Get collision rectangle for two rectangles collision", diff --git a/parser/output/raylib_api.txt b/parser/output/raylib_api.txt index faddc6008..f6c79f85e 100644 --- a/parser/output/raylib_api.txt +++ b/parser/output/raylib_api.txt @@ -2577,20 +2577,28 @@ Function 265: CheckCollisionCircleRec() (3 input parameters) Param[1]: center (type: Vector2) Param[2]: radius (type: float) Param[3]: rec (type: Rectangle) -Function 266: CheckCollisionPointRec() (2 input parameters) +Function 266: CheckCollisionCircleLine() (4 input parameters) + Name: CheckCollisionCircleLine + Return type: bool + Description: Check if circle collides with a line created betweeen two points [p1] and [p2] + Param[1]: center (type: Vector2) + Param[2]: radius (type: float) + Param[3]: p1 (type: Vector2) + Param[4]: p2 (type: Vector2) +Function 267: CheckCollisionPointRec() (2 input parameters) Name: CheckCollisionPointRec Return type: bool Description: Check if point is inside rectangle Param[1]: point (type: Vector2) Param[2]: rec (type: Rectangle) -Function 267: CheckCollisionPointCircle() (3 input parameters) +Function 268: CheckCollisionPointCircle() (3 input parameters) Name: CheckCollisionPointCircle Return type: bool Description: Check if point is inside circle Param[1]: point (type: Vector2) Param[2]: center (type: Vector2) Param[3]: radius (type: float) -Function 268: CheckCollisionPointTriangle() (4 input parameters) +Function 269: CheckCollisionPointTriangle() (4 input parameters) Name: CheckCollisionPointTriangle Return type: bool Description: Check if point is inside a triangle @@ -2598,14 +2606,22 @@ Function 268: CheckCollisionPointTriangle() (4 input parameters) Param[2]: p1 (type: Vector2) Param[3]: p2 (type: Vector2) Param[4]: p3 (type: Vector2) -Function 269: CheckCollisionPointPoly() (3 input parameters) +Function 270: CheckCollisionPointLine() (4 input parameters) + Name: CheckCollisionPointLine + Return type: bool + Description: Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold] + Param[1]: point (type: Vector2) + Param[2]: p1 (type: Vector2) + Param[3]: p2 (type: Vector2) + Param[4]: threshold (type: int) +Function 271: CheckCollisionPointPoly() (3 input parameters) Name: CheckCollisionPointPoly Return type: bool Description: Check if point is within a polygon described by array of vertices Param[1]: point (type: Vector2) Param[2]: points (type: const Vector2 *) Param[3]: pointCount (type: int) -Function 270: CheckCollisionLines() (5 input parameters) +Function 272: CheckCollisionLines() (5 input parameters) Name: CheckCollisionLines Return type: bool Description: Check the collision between two lines defined by two points each, returns collision point by reference @@ -2614,22 +2630,6 @@ Function 270: CheckCollisionLines() (5 input parameters) Param[3]: startPos2 (type: Vector2) Param[4]: endPos2 (type: Vector2) Param[5]: collisionPoint (type: Vector2 *) -Function 271: CheckCollisionPointLine() (4 input parameters) - Name: CheckCollisionPointLine - Return type: bool - Description: Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold] - Param[1]: point (type: Vector2) - Param[2]: p1 (type: Vector2) - Param[3]: p2 (type: Vector2) - Param[4]: threshold (type: int) -Function 272: CheckCollisionCircleLine() (4 input parameters) - Name: CheckCollisionCircleLine - Return type: bool - Description: Check if circle collides with a line created betweeen two points [p1] and [p2] - Param[1]: center (type: Vector2) - Param[2]: radius (type: float) - Param[3]: p1 (type: Vector2) - Param[4]: p2 (type: Vector2) Function 273: GetCollisionRec() (2 input parameters) Name: GetCollisionRec Return type: Rectangle diff --git a/parser/output/raylib_api.xml b/parser/output/raylib_api.xml index 20d2b9a47..6de5933d4 100644 --- a/parser/output/raylib_api.xml +++ b/parser/output/raylib_api.xml @@ -1659,6 +1659,12 @@ + + + + + + @@ -1674,6 +1680,12 @@ + + + + + + @@ -1686,18 +1698,6 @@ - - - - - - - - - - - - From 75a4c5bf20ff3ef75b64362f007227489d7e08d4 Mon Sep 17 00:00:00 2001 From: Asdqwe Date: Tue, 22 Oct 2024 19:28:20 -0300 Subject: [PATCH 2/7] Update core_input_gamepad example (#4416) --- examples/core/core_input_gamepad.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/core/core_input_gamepad.c b/examples/core/core_input_gamepad.c index 656f7c244..7a8b7e4bb 100644 --- a/examples/core/core_input_gamepad.c +++ b/examples/core/core_input_gamepad.c @@ -20,9 +20,9 @@ #include "raylib.h" // NOTE: Gamepad name ID depends on drivers and OS -#define XBOX360_LEGACY_NAME_ID "Xbox Controller" -#define XBOX360_NAME_ID "Xbox 360 Controller" -#define PS3_NAME_ID "Sony PLAYSTATION(R)3 Controller" +#define XBOX_ALIAS_1 "xbox" +#define XBOX_ALIAS_2 "x-box" +#define PS_ALIAS "playstation" //------------------------------------------------------------------------------------ // Program main entry point @@ -67,7 +67,7 @@ int main(void) { DrawText(TextFormat("GP%d: %s", gamepad, GetGamepadName(gamepad)), 10, 10, 10, BLACK); - if (TextIsEqual(GetGamepadName(gamepad), XBOX360_LEGACY_NAME_ID) || TextIsEqual(GetGamepadName(gamepad), XBOX360_NAME_ID)) + if (TextFindIndex(TextToLower(GetGamepadName(gamepad)), XBOX_ALIAS_1) > -1 || TextFindIndex(TextToLower(GetGamepadName(gamepad)), XBOX_ALIAS_2) > -1) { DrawTexture(texXboxPad, 0, 0, DARKGRAY); @@ -120,7 +120,7 @@ int main(void) //DrawText(TextFormat("Xbox axis LT: %02.02f", GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_TRIGGER)), 10, 40, 10, BLACK); //DrawText(TextFormat("Xbox axis RT: %02.02f", GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_TRIGGER)), 10, 60, 10, BLACK); } - else if (TextIsEqual(GetGamepadName(gamepad), PS3_NAME_ID)) + else if (TextFindIndex(TextToLower(GetGamepadName(gamepad)), PS_ALIAS) > -1) { DrawTexture(texPs3Pad, 0, 0, DARKGRAY); From 7a4a84a5619754b8170737726a14b368e8cbc5bf Mon Sep 17 00:00:00 2001 From: Asdqwe Date: Tue, 22 Oct 2024 19:59:50 -0300 Subject: [PATCH 3/7] [rcore] Fix #4405 (#4420) * Fix #4405 at runtime * Add parameter validation * Remove default global deadzone --- src/rcore.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rcore.c b/src/rcore.c index a1771d18e..9734972cf 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -3295,8 +3295,7 @@ float GetGamepadAxisMovement(int gamepad, int axis) if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (axis < MAX_GAMEPAD_AXIS)) { float movement = value < 0.0f ? CORE.Input.Gamepad.axisState[gamepad][axis] : fabsf(CORE.Input.Gamepad.axisState[gamepad][axis]); - // 0.1f = GAMEPAD_AXIS_MINIMUM_DRIFT/DELTA - if (movement > value + 0.1f) value = CORE.Input.Gamepad.axisState[gamepad][axis]; + if (movement > value) value = CORE.Input.Gamepad.axisState[gamepad][axis]; } return value; From fe6da67066bcbb6e43e719ce5ef3e9f424e7cbdf Mon Sep 17 00:00:00 2001 From: Asdqwe Date: Wed, 23 Oct 2024 11:31:27 -0300 Subject: [PATCH 4/7] [examples] Add deadzone handling to `core_input_gamepad` example (#4422) * Add deadzone handling to core_input_gamepad example * Rename variables --- examples/core/core_input_gamepad.c | 50 ++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/examples/core/core_input_gamepad.c b/examples/core/core_input_gamepad.c index 7a8b7e4bb..43dc65499 100644 --- a/examples/core/core_input_gamepad.c +++ b/examples/core/core_input_gamepad.c @@ -41,6 +41,14 @@ int main(void) Texture2D texPs3Pad = LoadTexture("resources/ps3.png"); Texture2D texXboxPad = LoadTexture("resources/xbox.png"); + // Set axis deadzones + const float leftStickDeadzoneX = 0.1f; + const float leftStickDeadzoneY = 0.1f; + const float rightStickDeadzoneX = 0.1f; + const float rightStickDeadzoneY = 0.1f; + const float leftTriggerDeadzone = -0.9f; + const float rightTriggerDeadzone = -0.9f; + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -67,6 +75,22 @@ int main(void) { DrawText(TextFormat("GP%d: %s", gamepad, GetGamepadName(gamepad)), 10, 10, 10, BLACK); + // Get axis values + float leftStickX = GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_X); + float leftStickY = GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_Y); + float rightStickX = GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_X); + float rightStickY = GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_Y); + float leftTrigger = GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_TRIGGER); + float rightTrigger = GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_TRIGGER); + + // Calculate deadzones + if (leftStickX > -leftStickDeadzoneX && leftStickX < leftStickDeadzoneX) leftStickX = 0.0f; + if (leftStickY > -leftStickDeadzoneY && leftStickY < leftStickDeadzoneY) leftStickY = 0.0f; + if (rightStickX > -rightStickDeadzoneX && rightStickX < rightStickDeadzoneX) rightStickX = 0.0f; + if (rightStickY > -rightStickDeadzoneY && rightStickY < rightStickDeadzoneY) rightStickY = 0.0f; + if (leftTrigger < leftTriggerDeadzone) leftTrigger = -1.0f; + if (rightTrigger < rightTriggerDeadzone) rightTrigger = -1.0f; + if (TextFindIndex(TextToLower(GetGamepadName(gamepad)), XBOX_ALIAS_1) > -1 || TextFindIndex(TextToLower(GetGamepadName(gamepad)), XBOX_ALIAS_2) > -1) { DrawTexture(texXboxPad, 0, 0, DARKGRAY); @@ -100,22 +124,22 @@ int main(void) if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_THUMB)) leftGamepadColor = RED; DrawCircle(259, 152, 39, BLACK); DrawCircle(259, 152, 34, LIGHTGRAY); - DrawCircle(259 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_X)*20), - 152 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_Y)*20), 25, leftGamepadColor); + DrawCircle(259 + (int)(leftStickX*20), + 152 + (int)(leftStickY*20), 25, leftGamepadColor); // Draw axis: right joystick Color rightGamepadColor = BLACK; if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_THUMB)) rightGamepadColor = RED; DrawCircle(461, 237, 38, BLACK); DrawCircle(461, 237, 33, LIGHTGRAY); - DrawCircle(461 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_X)*20), - 237 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_Y)*20), 25, rightGamepadColor); + DrawCircle(461 + (int)(rightStickX*20), + 237 + (int)(rightStickY*20), 25, rightGamepadColor); // Draw axis: left-right triggers DrawRectangle(170, 30, 15, 70, GRAY); DrawRectangle(604, 30, 15, 70, GRAY); - DrawRectangle(170, 30, 15, (int)(((1 + GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_TRIGGER))/2)*70), RED); - DrawRectangle(604, 30, 15, (int)(((1 + GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_TRIGGER))/2)*70), RED); + DrawRectangle(170, 30, 15, (int)(((1 + leftTrigger)/2)*70), RED); + DrawRectangle(604, 30, 15, (int)(((1 + rightTrigger)/2)*70), RED); //DrawText(TextFormat("Xbox axis LT: %02.02f", GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_TRIGGER)), 10, 40, 10, BLACK); //DrawText(TextFormat("Xbox axis RT: %02.02f", GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_TRIGGER)), 10, 60, 10, BLACK); @@ -150,24 +174,24 @@ int main(void) // Draw axis: left joystick Color leftGamepadColor = BLACK; if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_THUMB)) leftGamepadColor = RED; - DrawCircle(319, 255, 35, leftGamepadColor); + DrawCircle(319, 255, 35, BLACK); DrawCircle(319, 255, 31, LIGHTGRAY); - DrawCircle(319 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_X) * 20), - 255 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_Y) * 20), 25, leftGamepadColor); + DrawCircle(319 + (int)(leftStickX*20), + 255 + (int)(leftStickY*20), 25, leftGamepadColor); // Draw axis: right joystick Color rightGamepadColor = BLACK; if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_THUMB)) rightGamepadColor = RED; DrawCircle(475, 255, 35, BLACK); DrawCircle(475, 255, 31, LIGHTGRAY); - DrawCircle(475 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_X) * 20), - 255 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_Y) * 20), 25, rightGamepadColor); + DrawCircle(475 + (int)(rightStickX*20), + 255 + (int)(rightStickY*20), 25, rightGamepadColor); // Draw axis: left-right triggers DrawRectangle(169, 48, 15, 70, GRAY); DrawRectangle(611, 48, 15, 70, GRAY); - DrawRectangle(169, 48, 15, (int)(((1 - GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_TRIGGER)) / 2) * 70), RED); - DrawRectangle(611, 48, 15, (int)(((1 - GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_TRIGGER)) / 2) * 70), RED); + DrawRectangle(169, 48, 15, (int)(((1 + leftTrigger)/2)*70), RED); + DrawRectangle(611, 48, 15, (int)(((1 + rightTrigger)/2)*70), RED); } else { From df38564f62de55bff8ba06575e597aef9581fc25 Mon Sep 17 00:00:00 2001 From: Cypress <140924725+cypressru@users.noreply.github.com> Date: Wed, 23 Oct 2024 15:03:50 +0000 Subject: [PATCH 5/7] Grammar fix in CONTRIBUTING.md (#4423) "Can you write some tutorial/example?" "Can you write some tutorials/examples?" --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 78f953baf..d70617c13 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ Hello contributors! Welcome to raylib! Do you enjoy raylib and want to contribute? Nice! You can help with the following points: - `C programming` - Can you write/review/test/improve the code? -- `Documentation/Tutorials/Example` - Can you write some tutorial/example? +- `Documentation/Tutorials/Example` - Can you write some tutorials/examples? - `Porting to other platforms` - Can you port/adapt/compile raylib on other systems? - `Web Development` - Can you help [with the website](https://github.com/raysan5/raylib.com)? - `Testing` - Can you find some bugs in raylib? From 6f4407cb1575f1c7528403c935267a59bd71f5e3 Mon Sep 17 00:00:00 2001 From: Franz Date: Wed, 23 Oct 2024 17:04:15 +0200 Subject: [PATCH 6/7] Fix typo in rshapes.c (#4421) --- src/rshapes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rshapes.c b/src/rshapes.c index e9b5ca87b..1479a6f37 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -1650,7 +1650,7 @@ void DrawSplineLinear(const Vector2 *points, int pointCount, float thick, Color prevNormal = normal; } -#else // !SUPPORT_SPLINE_MITTERS +#else // !SUPPORT_SPLINE_MITERS Vector2 delta = { 0 }; float length = 0.0f; From 157ee79a8ee31f722a5c208d3ec095c8021ebf76 Mon Sep 17 00:00:00 2001 From: Asdqwe Date: Wed, 23 Oct 2024 15:31:57 -0300 Subject: [PATCH 7/7] Add drawing for generic gamepad on core_input_gamepad example (#4424) --- examples/core/core_input_gamepad.c | 60 ++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/examples/core/core_input_gamepad.c b/examples/core/core_input_gamepad.c index 43dc65499..538e1c389 100644 --- a/examples/core/core_input_gamepad.c +++ b/examples/core/core_input_gamepad.c @@ -119,7 +119,6 @@ int main(void) if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_TRIGGER_1)) DrawCircle(536, 61, 20, RED); // Draw axis: left joystick - Color leftGamepadColor = BLACK; if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_THUMB)) leftGamepadColor = RED; DrawCircle(259, 152, 39, BLACK); @@ -195,9 +194,64 @@ int main(void) } else { - DrawText("- GENERIC GAMEPAD -", 280, 180, 20, GRAY); - // TODO: Draw generic gamepad + // Draw background: generic + DrawRectangleRounded((Rectangle){ 175, 110, 460, 220}, 0.3f, 0.0f, DARKGRAY); + + // Draw buttons: basic + DrawCircle(365, 170, 12, RAYWHITE); + DrawCircle(405, 170, 12, RAYWHITE); + DrawCircle(445, 170, 12, RAYWHITE); + DrawCircle(516, 191, 17, RAYWHITE); + DrawCircle(551, 227, 17, RAYWHITE); + DrawCircle(587, 191, 17, RAYWHITE); + DrawCircle(551, 155, 17, RAYWHITE); + if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_MIDDLE_LEFT)) DrawCircle(365, 170, 10, RED); + if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_MIDDLE)) DrawCircle(405, 170, 10, GREEN); + if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_MIDDLE_RIGHT)) DrawCircle(445, 170, 10, BLUE); + if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_LEFT)) DrawCircle(516, 191, 15, GOLD); + if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) DrawCircle(551, 227, 15, BLUE); + if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT)) DrawCircle(587, 191, 15, GREEN); + if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_UP)) DrawCircle(551, 155, 15, RED); + + // Draw buttons: d-pad + DrawRectangle(245, 145, 28, 88, RAYWHITE); + DrawRectangle(215, 174, 88, 29, RAYWHITE); + DrawRectangle(247, 147, 24, 84, BLACK); + DrawRectangle(217, 176, 84, 25, BLACK); + if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_UP)) DrawRectangle(247, 147, 24, 29, RED); + if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) DrawRectangle(247, 147 + 54, 24, 30, RED); + if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) DrawRectangle(217, 176, 30, 25, RED); + if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) DrawRectangle(217 + 54, 176, 30, 25, RED); + + // Draw buttons: left-right back + DrawRectangleRounded((Rectangle){ 215, 98, 100, 10}, 0.5f, 0.0f, DARKGRAY); + DrawRectangleRounded((Rectangle){ 495, 98, 100, 10}, 0.5f, 0.0f, DARKGRAY); + if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_TRIGGER_1)) DrawRectangleRounded((Rectangle){ 215, 98, 100, 10}, 0.5f, 0.0f, RED); + if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_TRIGGER_1)) DrawRectangleRounded((Rectangle){ 495, 98, 100, 10}, 0.5f, 0.0f, RED); + + // Draw axis: left joystick + Color leftGamepadColor = BLACK; + if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_THUMB)) leftGamepadColor = RED; + DrawCircle(345, 260, 40, BLACK); + DrawCircle(345, 260, 35, LIGHTGRAY); + DrawCircle(345 + (int)(leftStickX*20), + 260 + (int)(leftStickY*20), 25, leftGamepadColor); + + // Draw axis: right joystick + Color rightGamepadColor = BLACK; + if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_THUMB)) rightGamepadColor = RED; + DrawCircle(465, 260, 40, BLACK); + DrawCircle(465, 260, 35, LIGHTGRAY); + DrawCircle(465 + (int)(rightStickX*20), + 260 + (int)(rightStickY*20), 25, rightGamepadColor); + + // Draw axis: left-right triggers + DrawRectangle(151, 110, 15, 70, GRAY); + DrawRectangle(644, 110, 15, 70, GRAY); + DrawRectangle(151, 110, 15, (int)(((1 + leftTrigger)/2)*70), RED); + DrawRectangle(644, 110, 15, (int)(((1 + rightTrigger)/2)*70), RED); + } DrawText(TextFormat("DETECTED AXIS [%i]:", GetGamepadAxisCount(0)), 10, 50, 10, MAROON);