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.
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.
Current Control Schemes
List of current control schemes for each player. Tracks the active input method (keyboard, gamepad, etc.) for each registered player.
Escape Action Names
List of action names that trigger escape functionality. These actions are automatically bound to escape events when players are registered.
Loading Action Maps
List of action map names that should be enabled during loading states. These maps are automatically managed during loading transitions.
Events
Player Events
Events triggered when players are added or removed from the input system.
Control Scheme Change
Event triggered when a player's control scheme changes (e.g., switching from keyboard to gamepad).
Initialization Methods
OnEnable
Initializes the InputDeviceManager with escape action names, loading action maps, and multiplayer settings. Called automatically by LunaUIManager.
OnDisable
Cleans up the InputDeviceManager by unsubscribing from input system events. Called automatically when the manager is disabled.
Player Management
AddPlayerInput
Registers a new PlayerInput instance with the manager. Automatically binds escape actions and updates control scheme tracking.
RemovePlayerInput
Unregisters a PlayerInput instance from the manager. Cleans up escape action bindings and removes from tracking lists.
Control Scheme Management
UpdateControlScheme
Updates the control scheme for a specific player input index. Triggers the OnControlSchemeChange event if the scheme has changed.
Action Map Management
Loading State Methods
Methods for managing action maps during loading states. These are called automatically by loading transitions.
Action Map Control
Utility methods for enabling and disabling specific action maps across input assets.
Usage Examples
Listening to Player Events
Example of how to listen to player join/leave events for UI updates or game logic.
Control Scheme Changes
Example of how to respond to control scheme changes for UI updates.
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.