Input Device Manager

Overview

The InputDeviceManager is a static class that manages input devices, player inputs, and control schemes across the application. It provides centralized input management for both single-player and multiplayer scenarios.

This manager handles player input registration, control scheme tracking, and action map management for loading states.

Info: The InputDeviceManager is automatically used by LunaUIManager and doesn't require manual initialization in most cases.

Integration with Other Components

LunaUIManager Integration

The InputDeviceManager is automatically initialized and managed by LunaUIManager. The LunaUIManager calls OnEnable() and OnDisable() methods and handles player input registration through its OnPlayerJoined and OnPlayerLeft events.

InputPrompt Integration

InputPrompt components automatically subscribe to InputDeviceManager events to update their display when:

  • Control schemes change (OnControlSchemeChange event)
  • Players join or leave (OnPlayerAdded/OnPlayerRemoved events)
  • Input bindings are updated

Properties

Player Inputs

Collection of all registered PlayerInput instances. Used for managing multiple players in local multiplayer scenarios.

csharp
public static List<PlayerInput> PlayerInputs { get; }

Current Control Schemes

List of current control schemes for each player. Tracks the active input method (keyboard, gamepad, etc.) for each registered player.

csharp
public static List<InputIconControlScheme> CurrentSchemes { get; }

Escape Action Names

List of action names that trigger escape functionality. These actions are automatically bound to escape events when players are registered.

csharp
public static List<string> EscapeActionNames { get; }

Loading Action Maps

List of action map names that should be enabled during loading states. These maps are automatically managed during loading transitions.

csharp
public static List<string> LoadingActionMaps { get; }

Events

Player Events

Events triggered when players are added or removed from the input system.

csharp
public static event Action<PlayerInput, int> OnPlayerAdded; public static event Action<PlayerInput, int> OnPlayerRemoved;

Control Scheme Change

Event triggered when a player's control scheme changes (e.g., switching from keyboard to gamepad).

csharp
public static event Action<InputIconControlScheme> OnControlSchemeChange;

Initialization Methods

OnEnable

Initializes the InputDeviceManager with escape action names, loading action maps, and multiplayer settings. Called automatically by LunaUIManager.

csharp
public static void OnEnable(List<string> escapeActionNames, List<string> loadingActionMaps, bool localMultiplayer)

OnDisable

Cleans up the InputDeviceManager by unsubscribing from input system events. Called automatically when the manager is disabled.

csharp
public static void OnDisable()

Player Management

AddPlayerInput

Registers a new PlayerInput instance with the manager. Automatically binds escape actions and updates control scheme tracking.

csharp
public static void AddPlayerInput(PlayerInput playerInput)

RemovePlayerInput

Unregisters a PlayerInput instance from the manager. Cleans up escape action bindings and removes from tracking lists.

csharp
public static void RemovePlayerInput(PlayerInput playerInput)

Control Scheme Management

UpdateControlScheme

Updates the control scheme for a specific player input index. Triggers the OnControlSchemeChange event if the scheme has changed.

csharp
public static void UpdateControlScheme(int inputIndex, bool forceInvoke = false) // or public static void UpdateControlScheme(InputIconControlScheme newScheme, int inputIndex, bool forceInvoke = false)

Action Map Management

Loading State Methods

Methods for managing action maps during loading states. These are called automatically by loading transitions.

csharp
public static void OnLoadingStart() public static void OnLoadingEnd()

Action Map Control

Utility methods for enabling and disabling specific action maps across input assets.

csharp
public static void SetEnabledActionMaps(InputActionAsset asset, ICollection<string> mapsToEnable) public static void SetDisabledActionMaps(InputActionAsset asset, ICollection<string> mapsToDisable) public static void ActionMapEnableOthers(InputActionAsset inputActionAsset, List<string> actionMapsToEnable)

Usage Examples

Listening to Player Events

Example of how to listen to player join/leave events for UI updates or game logic.

csharp
void Start() { InputDeviceManager.OnPlayerAdded += OnPlayerJoined; InputDeviceManager.OnPlayerRemoved += OnPlayerLeft; } void OnPlayerJoined(PlayerInput playerInput, int playerIndex) { Debug.Log($"Player {playerIndex} joined with device: {playerInput.devices[0].displayName}"); // Update UI, spawn player, etc. } void OnPlayerLeft(PlayerInput playerInput, int playerIndex) { Debug.Log($"Player {playerIndex} left"); // Clean up player data, update UI, etc. }

Control Scheme Changes

Example of how to respond to control scheme changes for UI updates.

csharp
void Start() { InputDeviceManager.OnControlSchemeChange += OnControlSchemeChanged; } void OnControlSchemeChanged(InputIconControlScheme newScheme) { // Update input prompts, button icons, etc. switch (newScheme) { case InputIconControlScheme.Keyboard: // Show keyboard prompts break; case InputIconControlScheme.Gamepad: // Show gamepad prompts break; } }

Info: In most cases, you don't need to manually interact with InputDeviceManager. It's automatically managed by LunaUIManager and works seamlessly with the UI system.

Settings

Theme

Light

Contrast

Material

Dark

Dim

Material Dark

System

Sidebar(Light & Contrast only)

Light
Dark

Font Family

DM Sans

Wix

Inclusive Sans

AR One Sans

Direction

LTR
RTL