Skip to content

Archived on 2026-10-24. This is a historical implementation note, not current setup instructions or an active task list. Original claims, code examples, file paths, and completion statements have not all been revalidated. Use the current documentation and issue register for maintenance decisions.

Joystick Refresh System - Setup Guide

Overview

Simple joystick detection refresh system for your game. When a user clicks the "Detect Joystick" button in settings, a popup appears showing the number of connected controllers, with a refresh button to rescan and update the joystick names.

Current Implementation Status

IN USE: JoystickRefreshPanel - Simple popup for controller detection NOT IN USE (commented out): - JoystickDetectionPage - Complex page with controller selection - JoystickDetectionView - List of detected controllers with layout override - ControllerItem - Individual controller items

The complex system with controller selection and Xbox/PlayStation layout override has been created but is currently commented out. You can uncomment and use it later if you need those features.

What Was Created

1. Enhanced InputManager (Assets/Script/App/Managers/InputManager.cs)

  • Added RefreshJoysticks() - Rescans for connected controllers
  • Added GetConnectedJoystickCount() - Returns number of connected controllers
  • Added GetDetectedJoystickNames() - Returns array of joystick names
  • Added ControllerLayout enum - Xbox/PlayStation layout types
  • Added DetectControllerLayout() - Detects layout from joystick name

2. JoystickRefreshPanel (Assets/Script/App/UI/Views/JoystickRefreshPanel.cs) - CURRENTLY IN USE

Simple popup component that: - Shows joystick detection status - Displays number of detected controllers - Has a Refresh button to rescan - Has a Close button - Auto-hides after 3 seconds - Updates joystick names in the UI when refreshed

3. Updated SettingsInterface (Assets/Script/Game/Utilities/SettingsInterface.cs)

  • Added JoystickRefreshPanel reference field
  • Added OnDetectJoystickButtonClicked() method to show the panel

4. JoystickDetectionPage, JoystickDetectionView, ControllerItem - COMMENTED OUT

These files exist but are currently not in use. They provide: - Full page integration with MenuController - List of all detected controllers - Controller selection - Manual Xbox/PlayStation layout override - Can be uncommented and used in the future if needed

Unity Setup Steps (5 minutes)

Step 1: Create the Refresh Panel UI

  1. In your Settings scene, create a new UI Panel (Right-click > UI > Panel)
  2. Name it "JoystickRefreshPanel"
  3. Make it a child of your Canvas (but not inside other panels)
  4. Add the JoystickRefreshPanel component to it
  5. Create this structure under the panel:
JoystickRefreshPanel (JoystickRefreshPanel component)
├── Background (Image)
├── PanelContent (Vertical Layout Group)
│   ├── StatusText (TMP_Text) - "1 controller detected"
│   ├── JoystickCountText (TMP_Text) - "1"
│   ├── ButtonsContainer (Horizontal Layout Group)
│   │   ├── RefreshButton (Button) - "Refresh"
│   │   └── CloseButton (Button) - "Close"

Step 2: Configure JoystickRefreshPanel Component

Assign references in the Inspector: - statusText: Drag the StatusText TMP_Text component - joystickCountText: Drag the JoystickCountText TMP_Text component - refreshButton: Drag the RefreshButton - closeButton: Drag the CloseButton - panelGameObject: The panel GameObject itself (should auto-assign) - autoHideDelay: Keep at 3 seconds (or adjust as needed)

Important: Make sure the panel is initially disabled (GameObject unchecked in Inspector)

Step 3: Wire Up the Detect Joystick Button

  1. Find your detectJoystickButton in your settings UI
  2. In the Button component's OnClick() event:
  3. Click the + button
  4. Drag your SettingsInterface GameObject to the object slot
  5. Select SettingsInterface.OnDetectJoystickButtonClicked from the function dropdown
  1. Select your SettingsInterface GameObject
  2. In the Inspector, find the new "Joystick Refresh Panel" section
  3. Drag your JoystickRefreshPanel GameObject to the joystickRefreshPanel field

Step 5: Test It

  1. Enter Play mode
  2. Open your settings menu
  3. Click the "Detect Joystick" button
  4. The popup should appear showing controller count
  5. Click "Refresh" - it should rescan and update the count
  6. The joystick names in your settings should update
  7. The panel should auto-hide after 3 seconds (or click Close)

How It Works

  1. User clicks "Detect Joystick" button in settings
  2. JoystickRefreshPanel shows with current controller count
  3. User clicks Refresh:
  4. Calls InputManager.RefreshJoysticks() to rescan
  5. Updates the displayed count
  6. Calls GameSettings.JoystickSetUI() for both players
  7. This updates the joystick names displayed in settings
  8. Panel auto-hides after 3 seconds (or user clicks Close)

Troubleshooting

Panel doesn't appear when button clicked

  • Check that detectJoystickButton has the OnDetectJoystickButtonClicked() function assigned
  • Verify joystickRefreshPanel field in SettingsInterface is assigned
  • Make sure the panel GameObject is disabled initially (unchecked in Inspector)

Joystick names don't update

  • Check that GameSettings.Instance is not null
  • Verify that JoystickSetUI() is being called (add Debug.Log if needed)
  • Make sure Save data has correct preset IDs

Compilation error about JoystickRefreshPanel

  • Unity might need a moment to compile the new file
  • If error persists, try Assets > Reimport All
  • Move JoystickRefreshPanel.cs to the same folder as SettingsInterface.cs

Panel doesn't auto-hide

  • Check that autoHideDelay is set to a reasonable value (3 seconds)
  • Make sure no other scripts are interfering with the panel

Remote Play Scenario

For Steam Remote Play or similar:

  1. Start the game remotely
  2. Connect controller to the remote client
  3. Open settings and click "Detect Joystick"
  4. Click "Refresh" - it will detect the new controller
  5. Joystick names in settings will update to show the connected controller
  6. Players can now use the controller!

Current Controller Setup

Your system has: - 2 Keyboard presets (P1_Keyboard, P2_Keyboard) - 2 Joystick presets (P1_Joystick, P2_Joystick) - Joysticks activate automatically when plugged in - The refresh button just updates the joystick names displayed in settings

Notes

  • The InputManager enhancements are already in place from the previous joystick detection work
  • This is a minimal solution focused on your specific need
  • No complex controller selection or layout switching needed
  • Simply shows count and refreshes the joystick list