Skip to content

Fix gamepad hot-plug detection (controller connected after launch now works)#1045

Open
NSDeathman wants to merge 1 commit intosmartcmd:mainfrom
NSDeathman:main
Open

Fix gamepad hot-plug detection (controller connected after launch now works)#1045
NSDeathman wants to merge 1 commit intosmartcmd:mainfrom
NSDeathman:main

Conversation

@NSDeathman
Copy link

Problem

Currently, the game checks InputManager.IsPadConnected(0) once at startup to determine whether a gamepad is available. If a controller is connected after the program has already started, this flag remains false, and the input system never switches to gamepad mode — even when buttons or sticks are used.

Solution

Remove the static IsPadConnected check from the main input loop. Instead, directly evaluate whether any gamepad input (buttons or stick movements) is present. The underlying input functions (ButtonPressed, GetJoypadStick_...) safely return false/0.0f when no controller is connected. Once a gamepad is plugged in and the player uses it, controllerUsed becomes true and the input mode switches to gamepad as expected.

This change:

  • Eliminates the need for runtime connection polling.
  • Works with any controller that becomes available after launch.
  • Simplifies the input‑mode logic.

Testing

Verified that a gamepad connected after the game is running is immediately recognized as soon as a button is pressed. No regressions observed with keyboard/mouse input.

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.

1 participant