Skip to content

Comments

Add global option to disable automatic controller switching#796

Open
adamrb wants to merge 1 commit intoisXander:multiversion/devfrom
adamrb:feature/auto-switch-controllers-toggle
Open

Add global option to disable automatic controller switching#796
adamrb wants to merge 1 commit intoisXander:multiversion/devfrom
adamrb:feature/auto-switch-controllers-toggle

Conversation

@adamrb
Copy link

@adamrb adamrb commented Feb 17, 2026

Summary

  • Adds an "Auto-Switch Controllers" toggle in Global Settings (default: enabled) that controls whether the active controller automatically switches when input is detected from a different controller
  • When disabled, a "Current Controller" dropdown appears allowing manual selection from connected controllers (including a "Keyboard & Mouse" option)
  • The dropdown dynamically refreshes when controllers are hotplugged/unplugged while the settings screen is open
  • Bumps version to 3.0.0-beta.3

Motivation

The automatic controller switching makes it impossible to run multiple game instances side-by-side with different controllers, since pressing a button on controller B in one instance causes the other instance to also switch to controller B.

Test plan

  • Open Global Settings and verify "Auto-Switch Controllers" toggle appears in Miscellaneous, defaulting to enabled
  • With toggle enabled: press a button on controller B while controller A is active — B should become active
  • With toggle disabled: press a button on controller B while controller A is active — A should remain active
  • With toggle disabled: verify "Current Controller" dropdown appears and lists all connected controllers
  • Hotplug a controller while settings screen is open — dropdown should update
  • Verify setting persists after restart (check config JSON for auto_switch_controllers)

The automatic controller switching behavior (where the active controller
switches to whichever last provided input) makes it impossible to run
multiple game instances side-by-side with different controllers. This
adds a toggleable "Auto-Switch Controllers" option in global settings
(default: enabled) that gates the tickInactiveController() loop.

When disabled, a "Current Controller" dropdown appears allowing manual
controller selection. The dropdown dynamically refreshes on controller
hotplug events by rebuilding the settings screen.
Minecraft.getInstance().setScreen(createGlobalSettingsScreen(parent));
}
});

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause a memory leak. It's not good to create throw-away event registers. result and parent will now live for the entirety of the game lifecycle

if (controller.equals(getCurrentController().orElse(null))) continue;

wrapControllerError(
() -> tickInactiveController(controller),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't agree with how this is done here.

Inactive controllers should still be ticked. Move this if statement within tickInactiveController to stop the switch, not stop ticking completely.

org.gradle.parallel=true

modVersion=3.0.0-beta.2
modVersion=3.0.0-beta.3
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't bump versions in PRs.

Codec.list(Codec.STRING).fieldOf("seen_servers").forGetter(GlobalConfig::seenServers),
Codec.BOOL.fieldOf("show_splitscreen_ad").forGetter(GlobalConfig::showSplitscreenAd)
Codec.BOOL.fieldOf("show_splitscreen_ad").forGetter(GlobalConfig::showSplitscreenAd),
Codec.BOOL.optionalFieldOf("auto_switch_controllers", true).forGetter(GlobalConfig::autoSwitchControllers)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DTOs should not have optional fields.

  • Defaults for GlobalSettings should exist in GlobalSettings#<init>.
  • Config migration should be done within a DataFixer, see dev.isxander.controlify.dto.dfu.
    • You will need to a new schema version, and a new fix to add this default.

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.

2 participants