Skip to content

Fix joystick not being detected after reconnecting - #5094

Open
TheCrazy17 wants to merge 3 commits into
multitheftauto:masterfrom
TheCrazy17:fix/joystick-reconnect
Open

Fix joystick not being detected after reconnecting#5094
TheCrazy17 wants to merge 3 commits into
multitheftauto:masterfrom
TheCrazy17:fix/joystick-reconnect

Conversation

@TheCrazy17

Copy link
Copy Markdown
Contributor

Summary

Makes MTA keep looking for a joystick after startup instead of only checking once. Covers connecting a controller after MTA is already open, reconnecting one that was unplugged, and Xbox style pads that only show up through XInput. Also listens for Windows' own device notifications so a connect or disconnect gets picked up right away instead of waiting for the next retry.

Motivation

MTA only ever checked for a joystick once, right at startup. If nothing was plugged in yet, or if you unplugged and replugged a controller mid session, it never looked again until you restarted the game.

Fixes #5088.

Test plan

Open MTA with no controller connected, then plug one in and confirm it gets picked up without restarting. Unplug it and plug it back in, confirm it keeps working.

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

… check, and drop one that stops responding so a replug gets noticed.
@RushCuttle

Copy link
Copy Markdown

Tested:

  • disconnecting while in game and reconnecting, reconnects
  • first time connecting, after the game is already open and running, connects

Addresses all issues in #5088

@RushCuttle

Copy link
Copy Markdown
image Is this bump before connecting or disconnecting might be a problem ? I have a good PC so there was no frame drops.

@FileEX FileEX added bugfix Solution to a bug of any kind feedback Further information is requested labels Aug 9, 2026
FileEX
FileEX previously approved these changes Aug 14, 2026
@FileEX

FileEX commented Aug 14, 2026

Copy link
Copy Markdown
Member

Waiting for the feedback

@TheCrazy17

Copy link
Copy Markdown
Contributor Author

image Is this bump before connecting or disconnecting might be a problem ? I have a good PC so there was no frame drops.

Improved the PR by moving joystick detection and axis setup to a background thread and debouncing Windows device-change notifications. This gets rid of the small lag that occurred when connecting or disconnecting a controller. Tested with a real controller, and the stutter is gone now.

@RushCuttle

Copy link
Copy Markdown

fixed the issue

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

Labels

bugfix Solution to a bug of any kind feedback Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MTA is not registering controller device after it disconnects

3 participants