Skip to content

fix: stop multiple-joystick warning from repeatedly stealing control#2799

Open
rafaellehmkuhl wants to merge 1 commit into
bluerobotics:masterfrom
rafaellehmkuhl:issue-2798-multiple-joysticks-handling
Open

fix: stop multiple-joystick warning from repeatedly stealing control#2799
rafaellehmkuhl wants to merge 1 commit into
bluerobotics:masterfrom
rafaellehmkuhl:issue-2798-multiple-joysticks-handling

Conversation

@rafaellehmkuhl

Copy link
Copy Markdown
Member

Summary

The "Multiple joystick controllers detected" warning is triggered when Cockpit detects another ground control station sending MANUAL_CONTROL/RC_CHANNELS_OVERRIDE to the vehicle (checkForOtherManualControlSources), not when two physical gamepads are plugged in. On busy test days with multiple computers/vehicles, that detection trips often.

The check ran inside processJoystickConnectionEvent, which fires on every joystick connect/disconnect (gamepad polling, Bluetooth roaming, etc.). Once another source was detected, enableForwarding was set to false — and since forwarding was now off, the next reconnect re-ran the check, re-disabled forwarding, and re-showed the dialog. That's the reported "popup keeps spawning" + "user loses control" loop. The only workaround was the joystick config view's onUnmounted hook force-enabling forwarding (the "twiddle the sticks and click out" trick).

This PR makes the conflict check run only when forwarding is neither already active nor explicitly prevented, so the joystick already in use keeps control and the dialog is shown at most once.

  • Skip the conflict check/warning when enableForwarding is already on or preventJoystickForwarding is set — reconnections no longer re-disable forwarding or re-pop the dialog.
  • Add a checkingForOtherManualControlSources in-flight guard so concurrent connection events can't race to show the dialog more than once (the async check can wait up to ~3s).
  • Drop the old early return (which also skipped disconnect cleanup and currentMainJoystick refresh); that logic now runs via continue.

Test plan

  • With a single joystick and no other GCS: forwarding enables on connect, no dialog.
  • With another GCS sending MANUAL_CONTROL: dialog shows once, forwarding disabled.
  • Disconnect/reconnect the joystick repeatedly after the warning → dialog does not re-appear and control is not repeatedly stolen.
  • Re-enable forwarding via the top-right joystick widget → stays enabled across reconnects.
  • Disconnect all joysticks → forwarding disabled; currentMainJoystick updates correctly.

Fixes #2798.

When another GCS was detected sending MANUAL_CONTROL, forwarding was disabled
and the warning dialog shown. Because the conflict check ran on every joystick
(re)connection, the dialog kept popping up and forwarding kept being disabled,
making users lose control of the vehicle on busy test days. Only run the check
when forwarding is neither active nor already prevented, and guard against
concurrent checks racing to show the dialog more than once.
@github-actions

Copy link
Copy Markdown

Automated PR Review (Claude)

0. Summary

Verdict: READY TO MERGE

This PR fixes a bug where the "Multiple joystick controllers detected" warning dialog kept re-appearing and repeatedly disabling forwarding on every joystick reconnection event, effectively stealing control from users. The fix adds three guard conditions — forwarding already active, forwarding already prevented, or a check already in flight — so the conflict detection runs at most once. The old return (which short-circuited the entire function, skipping disconnect cleanup and currentMainJoystick refresh) is correctly replaced with continue. The try/finally pattern ensures the in-flight guard is always cleared. Clean, well-scoped fix.

1. Correctness & Implementation Bugs — ✅

2. AGENTS.md Adherence — ✅

3. Security — ✅

4. Performance — ✅

5. UI / UX — ✅

6. Code Quality & Style — ✅

7. Commit Hygiene — ✅

8. Tests — ✅

9. Documentation — ✅

10. Nitpicks / Optional — ✅

Generated by Claude. This is advisory; a human reviewer must still approve.

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.

Multiple joysticks situation can maybe be better handled

1 participant