fix: cross-platform gamepad button mapping, d-pad, analog triggers ($100 bounty #2886)#3320
Open
RanuK12 wants to merge 2 commits into
Open
fix: cross-platform gamepad button mapping, d-pad, analog triggers ($100 bounty #2886)#3320RanuK12 wants to merge 2 commits into
RanuK12 wants to merge 2 commits into
Conversation
…anukita:a4ec82] Fixes armory3d#2886 - Controller type detection from gamepad.id (Xbox vs PS) - Auto-switch buttons array based on detected type - D-pad from hat switch axes (axis 4/5) - Analog trigger started/released with threshold (0.5) - Bounds checking in buttonListener - Y-axis inversion fix for Android - Removed unused connects retry loop
Author
|
/claim |
…elseif [ranukita:a4ec82]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2886
What was fixed
1. Controller type detection & button mapping
Auto-detects Xbox vs PlayStation controllers from
gamepad.idstring and switches betweenbuttonsXBOXandbuttonsPSarrays accordingly. Fixes swapped buttons (square↔triangle, L3↔R3, etc) on PS4/PS3 controllers.2. D-Pad from hat switch (axis 4/5)
SDL-based backends (Krom, native) report the D-pad as hat switch axes (axis 4=horizontal, axis 5=vertical) instead of button events. Added handling in
axisListener()to convert these to proper up/down/left/right button states.3. Analog trigger started/released
L2/R2 triggers are analog (0.0–1.0). Previously
started()would fire every frame the trigger was held. Now tracks previous value and only firesstartedwhen crossing the 0.5 threshold, andreleasedwhen dropping below.4. Array bounds safety
Some controllers report button indices beyond the 18-button array. Added bounds check in
buttonListener()to prevent crashes.5. Android Y-axis fix
Runtime check
isAndroid ? -value : valuefor Y-axis inversion on Android (detected from gamepad.id or compile target).6. Cleanup
Removed unused
connectsretry loop.Verification
down(),started(),released())connect()fromgamepad.idbuttonIndex()