Skip to content

fix: cross-platform gamepad button mapping, d-pad, analog triggers ($100 bounty #2886)#3320

Open
RanuK12 wants to merge 2 commits into
armory3d:mainfrom
RanuK12:ranukita/gamepad-fix-2886
Open

fix: cross-platform gamepad button mapping, d-pad, analog triggers ($100 bounty #2886)#3320
RanuK12 wants to merge 2 commits into
armory3d:mainfrom
RanuK12:ranukita/gamepad-fix-2886

Conversation

@RanuK12

@RanuK12 RanuK12 commented Jun 22, 2026

Copy link
Copy Markdown

Closes #2886

What was fixed

1. Controller type detection & button mapping

Auto-detects Xbox vs PlayStation controllers from gamepad.id string and switches between buttonsXBOX and buttonsPS arrays 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 fires started when crossing the 0.5 threshold, and released when 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 : value for Y-axis inversion on Android (detected from gamepad.id or compile target).

6. Cleanup

Removed unused connects retry loop.

Verification

  • All existing public API unchanged (down(), started(), released())
  • Controller detection happens once on connect() from gamepad.id
  • Button name arrays match the SDL GameController standard mapping
  • D-pad hat axes mapped to logical button names via buttonIndex()

…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
@RanuK12

RanuK12 commented Jun 22, 2026

Copy link
Copy Markdown
Author

/claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perfectly ( normal ) working gamepad logic nodes on pc and android phone

1 participant