Auto-detect and dynamically expand player/gamepad slots#80
Conversation
Co-authored-by: lunarcloud <1565970+lunarcloud@users.noreply.github.com>
Co-authored-by: lunarcloud <1565970+lunarcloud@users.noreply.github.com>
|
@copilot I think it would make more sense to automatically detect the max and update it based on the navigator gamepad API |
Co-authored-by: lunarcloud <1565970+lunarcloud@users.noreply.github.com>
Implemented auto-detection and dynamic expansion. The system now:
Changes in commit 1059af8. |
Co-authored-by: lunarcloud <1565970+lunarcloud@users.noreply.github.com>
|
@copilot fix the type error failing the CI action |
Co-authored-by: lunarcloud <1565970+lunarcloud@users.noreply.github.com>
|
@copilot the build is failing due to some complex jsdoc type stuff. perhaps instead of inlining complex types, it'll be easier to understand and maintain by making new typedefs? I want the CI Build to pass before I'll accept this PR. |
Co-authored-by: lunarcloud <1565970+lunarcloud@users.noreply.github.com>
Fixed JSDoc parsing errors by creating a JSDoc can now parse the types correctly, and all CI steps pass (lint, type-check, build:types, build-prod, test). Commit 019d75e. |
Describe your changes
GameInput previously hardcoded support for exactly 4 players. Modern browsers via
navigator.getGamepads()can support more. This change implements automatic detection and dynamic expansion of player slots while maintaining backward compatibility.Core changes:
navigator.getGamepads().lengthon initializationMath.max(options?.maxPlayers ?? 4, detectedMax, 4)to determine initial allocationreinitialize()#initializePlayerArrays(count)helper method for initialization and expansionPlayers[]- GameInputPlayer instances#firstPress[]- first button press trackingConnection.Gamepads[]- gamepad cacheConnection.GamePadMapping{}- index mappinggetPlayer()andgetGamepad()bounds checking to use dynamic lengthdestroy()to clear arrays dynamically@privateJSDoc tag from private identifier methodGamepadEventHandlertypedef to simplify complex JSDoc types and fix documentation build errorsBehavior:
maxPlayersoption forces a specific maximum, overriding auto-detectionUsage:
Describe your testing
navigator.getGamepads()reinitialize()Issue ticket number and link
#80
Checklist before requesting a review
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.