fix(controller): guard btnHome against gamepads without a buttons array - #1005
Open
Endymi0n74 wants to merge 1 commit into
Open
fix(controller): guard btnHome against gamepads without a buttons array#1005Endymi0n74 wants to merge 1 commit into
Endymi0n74 wants to merge 1 commit into
Conversation
Gamepad objects are not guaranteed to expose a `buttons` array at every poll (reported on a GameSir G7 SE, redphx#991): `currentGamepad.buttons[16]` then throws, the exception kills the whole polling loop and controller input silently stops working until a reload. Use `currentGamepad.buttons?.[16]`: when the array is missing, `btnHome` is `undefined`, the controller-shortcuts block becomes a no-op and the rest of the poll (gamepad input delivery) keeps running. No behavioral change for gamepads that report buttons normally. Branch ready locally — not opened yet (awaiting the maintainer's feedback window on the perf PRs before sending more).
3 tasks
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.
Fixes the crash class reported in #991: controller input silently stops working —
pollGamepadthrowsCannot read properties of undefined (reading 'pressed').Root cause
poll-gamepadreads the Home button state on every poll:Gamepad objects are not guaranteed to expose a
buttonsarray at every poll (observed on a GameSir G7 SE). When the array is missing,buttons[16]throws, the exception kills the whole polling loop and controller input silently stops working until a reload — the exact symptom in #991.Fix
buttonsis missing,btnHomeisundefined→ the controller-shortcuts block becomes a no-op.Verification
buttons[16]gone.@redphx — happy to adjust if you'd rather guard
currentGamepaditself too.