Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Auto-Assign Controllers #706

Open
wants to merge 29 commits into
base: master
Choose a base branch
from

Conversation

uncavo-hdmi
Copy link

Feature: Auto-Assign Controllers

This PR introduces an auto-assigning controllers feature to Ryujinx, enhancing user experience by automatically detecting and assigning connected controllers to player slots. This streamlines the setup process, allowing users to start playing without manual configuration.

Changes & Enhancements:

  • When the feature is enabled, controllers are automatically assigned to players when connected and removed when disconnected.
  • When the feature is enabled, the Input settings page now automatically refreshes when a controller is connected.
  • Added an option in the Input settings page to enable or disable the feature.

Auto-Assign Controllers Feature

  • When enabled, this feature assigns predefined colors to each player's controller (e.g., Player 1's controller will have a blue LED, Player 2's will have red, etc.).
  • Manual customization remains available, even when the feature is enabled.

Implementation Details:

  • Assignment Logic: Controllers are assigned sequentially, starting from Player 1.

    • When two controllers are connected, they are assigned to Player 1 and Player 2, respectively.
    • If three controllers are connected and the one assigned to Player 2 disconnects, the remaining controllers will automatically shift to ensure each player slot is filled, with Player 1 retaining their controller and Player 3 becoming Player 2.
  • Enable feature: The feature can be toggled on or off using a checkbox in the Input settings page. By default, it is disabled.

  • No Conflicts: This feature does not interfere with manual controller assignments, profile selection logic, or controller binding settings. It only modifies the configuration file when new controllers are connected.

  • No configuration loss: When controllers are disconnected, no controller configuration will be erased (unless manually deassigned using "Disabled").

  • Initial controller config: Since a configuration is necessary to successfully use a controller, this feature provides default controller configurations:

    • Joycon Left Controller: Uses a custom horizontal configuration.
    • Joycon Right Controller: Uses a custom horizontal configuration.
    • Any other controller: Use the default configuration of the Switch Pro Controller.
  • Ignore Applet: When the feature is enabled, it automatically enables the Ignore Applet setting and disables the checkbox, preventing it from being toggled on or off. This ensures seamless controller detection without applet interference.


Why add this feature?

Manually assigning controllers can be cumbersome, especially in scenarios where users have multiple controllers or frequently connect/disconnect devices. This feature aims to simplify the setup process by automatically assigning controllers, saving time and reducing the hassle of manual configuration.


Known issues

  1. File Organization

    • Currently, AutoAssignController.cs (main class) and ControllerAssignmentManager.cs (helper class) are placed in Ryujinx/Input.
    • I'm unsure if this aligns with the existing project architecture and would appreciate suggestions on the best location for these files.
  2. Issues with Joy-Con Configurations

    During testing to create default configurations for each controller, I encountered several issues with the Joy-Con controllers:

    • The right Joy-Con can be easily configured to be used horizontally (by rotating 90° clockwise), but there is no simple way to achieve this with the left Joy-Con.
    • When using the left Joy-Con alone, I noticed that the Minus button is incorrectly mapped to the Plus button.
    • When using the right Joy-Con alone, I noticed that the Right Stick is incorrectly mapped to the Left Stick.
    • The motion controls have issues with the axes. As far as I remember, the default configuration for single Joy-Cons has the controller oriented incorrectly.
  3. Controller Reassignment Bug (Unrelated to This PR)

    This issue was encountered while testing, but I confirmed that it also occurs in the main Ryujinx repository. This is not caused by changes in this PR, but I am documenting it here in case anyone else encounters it (the same applies to the next issue).

    Steps to Reproduce:

     1. Start Ryujinx.
     2. Launch any game (tested with Super Mario Bros. Wonder).
     3. Go to Settings > Input, set your controller for Player 1, and click "Ok."
     4. Open Settings > Input again, set Player 1 to "Disabled," and click "Ok."
     5. Go back to Settings > Input, set your controller for Player 1, and click "Ok."
    

    Expected Behavior: The controller should function normally after being reassigned.

    Actual Behavior: The controller stops working after switching from “Disabled” back to an assigned controller.

    Additional note: It appears to happen only when switching from 'Disabled' back to a controller

  4. Crash on Game Relaunch (Unrelated to This PR)

    Steps to Reproduce:

     1. Start any game.
     2. Once the game has loaded, press "Esc" to return to the menu.
     3. Attempt to relaunch the game.
    

    Expected Behavior: The game should start normally.

    Actual Behavior: The emulator crashes on the "Loading" screen when attempting to restart the game.


…tionality; update gamepad connection handling to load configuration while in Input settings.
… order caused the configuration to load incorrectly.
…pad connection changes; improve controller assignment logic and ensure proper LED color settings
…ion methods; changed some settings for LED color
…in settings (no easy way to constantly update it)
@github-actions github-actions bot added the gui Affects the Avalonia UI or translations. label Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gui Affects the Avalonia UI or translations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant