Class InputBridgeManager
Concrete implementation of IInputBridgeManager that coordinates input queries across one or more registered IScyllaInputBridge instances.
Implements
Inherited Members
Namespace: Scylla.Input
Assembly: ScyllaInput.dll
Syntax
public class InputBridgeManager : IInputBridgeManager
Remarks
Bridges are stored in a priority-sorted list and queried according to the active
QueryMode. All input query methods delegate to one of three internal
helpers - QueryBool, QueryFloat, and QueryVector2 - each of
which implements the full InputBridgeQueryMode switch.
By default the manager operates in SingleBridge mode with HighestPriority. This matches the behavior of a classic single-bridge setup and requires no additional configuration.
Device connection and disconnection events from individual bridges are forwarded through the manager's own OnDeviceConnected and OnDeviceDisconnected events, so consumers only need to subscribe once.
Properties
ActiveBridge
Gets the highest-priority bridge that is currently registered.
Declaration
public IScyllaInputBridge ActiveBridge { get; }
Property Value
| Type | Description |
|---|---|
| IScyllaInputBridge | The first entry in the priority-sorted Bridges list, or |
Bridges
Gets the full list of registered bridges in descending priority order.
Declaration
public IReadOnlyList<IScyllaInputBridge> Bridges { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<IScyllaInputBridge> | A read-only view of all bridges, sorted so that the highest-priority bridge is at index 0. The list is re-sorted whenever a bridge is registered or its priority changes via SetBridgePriority(string, int). |
ConflictResolution
Gets or sets the strategy used to resolve conflicting analog values when multiple bridges each return a non-zero result.
Declaration
public InputConflictResolution ConflictResolution { get; set; }
Property Value
| Type | Description |
|---|---|
| InputConflictResolution | One of the InputConflictResolution values. Defaults to HighestPriority. This setting is most relevant when QueryMode is CombineAll or PriorityChain. |
QueryMode
Gets or sets the strategy used to select which bridge(s) answer input queries.
Declaration
public InputBridgeQueryMode QueryMode { get; set; }
Property Value
| Type | Description |
|---|---|
| InputBridgeQueryMode | One of the InputBridgeQueryMode values. Defaults to SingleBridge, which provides the same behavior as a single-bridge setup. Changes take effect immediately on the next input query. |
Methods
ClearBridgeForInputType(InputDeviceType)
Removes the per-input-type bridge assignment for the given device category, reverting to the default ActiveBridge for that type.
Declaration
public void ClearBridgeForInputType(InputDeviceType inputType)
Parameters
| Type | Name | Description |
|---|---|---|
| InputDeviceType | inputType | The InputDeviceType whose routing assignment should be cleared. If no assignment exists, the call is a safe no-op. |
GetAllDevices()
Returns the list of all input devices reported by the active bridge.
Declaration
public IReadOnlyList<InputDevice> GetAllDevices()
Returns
| Type | Description |
|---|---|
| IReadOnlyList<InputDevice> | A read-only list of currently connected and enabled devices as seen by the ActiveBridge; an empty list if no bridges are registered or the active bridge reports no devices. |
Remarks
This method currently delegates to the ActiveBridge only. In future multi-bridge scenarios, device lists from all bridges may be merged.
GetBridge(string)
Retrieves a registered bridge by its ID.
Declaration
public IScyllaInputBridge GetBridge(string bridgeID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | bridgeID | The BridgeID to look up. |
Returns
| Type | Description |
|---|---|
| IScyllaInputBridge | The registered IScyllaInputBridge with the given ID, or |
GetBridgeForInputType(InputDeviceType)
Returns the bridge ID that is currently assigned to handle a specific input device type.
Declaration
public string GetBridgeForInputType(InputDeviceType inputType)
Parameters
| Type | Name | Description |
|---|---|---|
| InputDeviceType | inputType | The InputDeviceType to query. |
Returns
| Type | Description |
|---|---|
| string | The BridgeID of the assigned bridge, or |
GetBridgePriority(string)
Returns the effective priority of a registered bridge, accounting for any runtime override set via SetBridgePriority(string, int).
Declaration
public int GetBridgePriority(string bridgeID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | bridgeID | The BridgeID to query. |
Returns
| Type | Description |
|---|---|
| int | The override priority if one has been set, otherwise the bridge's own
Priority value, or |
GetCurrentGamepad()
Returns a reference to the primary active gamepad as reported by the bridge designated for gamepad queries.
Declaration
public Gamepad GetCurrentGamepad()
Returns
| Type | Description |
|---|---|
| Gamepad | The current UnityEngine.InputSystem.Gamepad, or |
GetDeviceType(InputDevice)
Classifies an input device into one of the known InputDeviceType categories using the active bridge's classification logic.
Declaration
public InputDeviceType GetDeviceType(InputDevice device)
Parameters
| Type | Name | Description |
|---|---|---|
| InputDevice | device | The device to classify. May be |
Returns
| Type | Description |
|---|---|
| InputDeviceType | The InputDeviceType that describes |
GetGamepadLeftStick()
Returns the current value of the left analog stick on the active gamepad, resolved through the active bridge selection strategy.
Declaration
public Vector2 GetGamepadLeftStick()
Returns
| Type | Description |
|---|---|
| Vector2 | A UnityEngine.Vector2 with components in [-1, 1]; UnityEngine.Vector2.zero if no gamepad is connected or no bridges are registered. |
GetGamepadLeftTrigger()
Returns the current analog value of the left trigger on the active gamepad, resolved through the active bridge selection strategy.
Declaration
public float GetGamepadLeftTrigger()
Returns
| Type | Description |
|---|---|
| float | A value in [0, 1] where 0 is fully released and 1 is fully pressed; |
GetGamepadRightStick()
Returns the current value of the right analog stick on the active gamepad, resolved through the active bridge selection strategy.
Declaration
public Vector2 GetGamepadRightStick()
Returns
| Type | Description |
|---|---|
| Vector2 | A UnityEngine.Vector2 with components in [-1, 1]; UnityEngine.Vector2.zero if no gamepad is connected or no bridges are registered. |
GetGamepadRightTrigger()
Returns the current analog value of the right trigger on the active gamepad, resolved through the active bridge selection strategy.
Declaration
public float GetGamepadRightTrigger()
Returns
| Type | Description |
|---|---|
| float | A value in [0, 1] where 0 is fully released and 1 is fully pressed; |
GetLastUsedDevice()
Returns the most recently used input device as reported by the active bridge.
Declaration
public InputDevice GetLastUsedDevice()
Returns
| Type | Description |
|---|---|
| InputDevice | The UnityEngine.InputSystem.InputDevice that last produced input, or |
GetMouseDelta()
Returns the per-frame mouse movement delta, resolved through the active bridge selection strategy.
Declaration
public Vector2 GetMouseDelta()
Returns
| Type | Description |
|---|---|
| Vector2 | Mouse displacement in pixels; UnityEngine.Vector2.zero if the mouse did not move or no mouse is available. |
GetMousePosition()
Returns the current mouse cursor position in screen-space pixel coordinates, resolved through the active bridge selection strategy.
Declaration
public Vector2 GetMousePosition()
Returns
| Type | Description |
|---|---|
| Vector2 | Mouse position as a UnityEngine.Vector2 with (0, 0) at the bottom-left; UnityEngine.Vector2.zero if no mouse is connected or no bridges are registered. |
GetMouseScrollDelta()
Returns the scroll wheel delta for the current frame, resolved through the active bridge selection strategy.
Declaration
public Vector2 GetMouseScrollDelta()
Returns
| Type | Description |
|---|---|
| Vector2 | Scroll delta where |
HasBridge(string)
Returns whether a bridge with the given ID is currently registered.
Declaration
public bool HasBridge(string bridgeID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | bridgeID | The BridgeID to test. |
Returns
| Type | Description |
|---|---|
| bool |
|
HasBridgeForInputType(InputDeviceType)
Returns whether a per-input-type bridge assignment exists for the given device category.
Declaration
public bool HasBridgeForInputType(InputDeviceType inputType)
Parameters
| Type | Name | Description |
|---|---|---|
| InputDeviceType | inputType | The InputDeviceType to test. |
Returns
| Type | Description |
|---|---|
| bool |
|
Initialize()
Initializes the manager and calls Initialize() on every currently registered bridge.
Declaration
public void Initialize()
Remarks
Bridges registered after this call are initialized immediately upon registration. Calling Initialize() more than once without an intervening Shutdown() is a no-op that emits a warning.
IsAnyKeyPressed()
Returns whether any keyboard key is currently held down, resolved through the active bridge selection strategy.
Declaration
public bool IsAnyKeyPressed()
Returns
| Type | Description |
|---|---|
| bool |
|
IsGamepadButtonPressed(GamepadButton)
Returns whether the specified gamepad button is currently held down, resolved through the active bridge selection strategy.
Declaration
public bool IsGamepadButtonPressed(GamepadButton button)
Parameters
| Type | Name | Description |
|---|---|---|
| GamepadButton | button | The gamepad button to test. |
Returns
| Type | Description |
|---|---|
| bool |
|
IsGamepadConnected()
Returns whether at least one gamepad is currently connected, resolved through the active bridge selection strategy.
Declaration
public bool IsGamepadConnected()
Returns
| Type | Description |
|---|---|
| bool |
|
IsKeyPressed(Key)
Returns whether the specified keyboard key is currently held down, resolved through the active bridge selection strategy.
Declaration
public bool IsKeyPressed(Key key)
Parameters
| Type | Name | Description |
|---|---|---|
| Key | key | The key to test. |
Returns
| Type | Description |
|---|---|
| bool |
|
IsMouseButtonPressed(int)
Returns whether the specified mouse button is currently held down, resolved through the active bridge selection strategy.
Declaration
public bool IsMouseButtonPressed(int button)
Parameters
| Type | Name | Description |
|---|---|---|
| int | button | Zero-based index: 0 = left, 1 = right, 2 = middle, 3 = forward, 4 = back. |
Returns
| Type | Description |
|---|---|
| bool |
|
IsMouseConnected()
Returns whether a mouse device is currently connected, resolved through the active bridge selection strategy.
Declaration
public bool IsMouseConnected()
Returns
| Type | Description |
|---|---|
| bool |
|
RegisterBridge(IScyllaInputBridge)
Registers a bridge with the manager and immediately incorporates it into input query routing.
Declaration
public void RegisterBridge(IScyllaInputBridge bridge)
Parameters
| Type | Name | Description |
|---|---|---|
| IScyllaInputBridge | bridge | The bridge to register. Must not be |
Remarks
If the manager has already been initialized when this method is called, the new bridge is initialized immediately. The internal priority list is re-sorted after registration so that the bridge is consulted in the correct order.
SetBridgeForInputType(InputDeviceType, string)
Designates a specific bridge to handle all queries for a given input device type when QueryMode is PerInputType.
Declaration
public void SetBridgeForInputType(InputDeviceType inputType, string bridgeID)
Parameters
| Type | Name | Description |
|---|---|---|
| InputDeviceType | inputType | The InputDeviceType category (e.g., Gamepad) for which the routing assignment should apply. |
| string | bridgeID | The BridgeID of the bridge that should service
queries for |
SetBridgePriority(string, int)
Overrides the priority of a registered bridge and re-sorts the bridge list.
Declaration
public void SetBridgePriority(string bridgeID, int priority)
Parameters
| Type | Name | Description |
|---|---|---|
| string | bridgeID | The BridgeID of the bridge to update. If the ID is not found, the call is a no-op with a warning. |
| int | priority | The new priority value. Higher values cause the bridge to be consulted before bridges with lower values. There is no enforced range; any integer is valid. |
Remarks
This override is stored separately from the bridge's own Priority property. The override takes precedence over the bridge's native priority for the lifetime of this manager.
Shutdown()
Shuts down the manager, calling Shutdown() on every registered bridge and clearing all internal state.
Declaration
public void Shutdown()
Remarks
After shutdown, all bridge registrations, priority overrides, and per-input-type routing assignments are discarded. The manager can be re-initialized by calling Initialize() again.
UnregisterBridge(string)
Unregisters the bridge with the given ID, shutting it down and removing it from all routing tables.
Declaration
public void UnregisterBridge(string bridgeID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | bridgeID | The BridgeID of the bridge to remove. If no bridge with this ID is registered, the call is a no-op with a warning. |
Remarks
The bridge's Shutdown() is called before removal. Any per-input-type routing assignments that reference this bridge ID remain in the routing table but will resolve to the ActiveBridge at query time until reassigned or cleared.
Update()
Advances per-frame state in all available bridges. Must be called once per frame.
Declaration
public void Update()
Remarks
Only bridges where IsAvailable is true
receive the Update() call. Bridges that report
unavailable are silently skipped.
WasGamepadButtonPressedThisFrame(GamepadButton)
Returns whether the specified gamepad button transitioned to pressed this frame, resolved through the active bridge selection strategy.
Declaration
public bool WasGamepadButtonPressedThisFrame(GamepadButton button)
Parameters
| Type | Name | Description |
|---|---|---|
| GamepadButton | button | The gamepad button to test. |
Returns
| Type | Description |
|---|---|
| bool |
|
WasGamepadButtonReleasedThisFrame(GamepadButton)
Returns whether the specified gamepad button transitioned to released this frame, resolved through the active bridge selection strategy.
Declaration
public bool WasGamepadButtonReleasedThisFrame(GamepadButton button)
Parameters
| Type | Name | Description |
|---|---|---|
| GamepadButton | button | The gamepad button to test. |
Returns
| Type | Description |
|---|---|
| bool |
|
WasKeyPressedThisFrame(Key)
Returns whether the specified keyboard key transitioned to pressed this frame, resolved through the active bridge selection strategy.
Declaration
public bool WasKeyPressedThisFrame(Key key)
Parameters
| Type | Name | Description |
|---|---|---|
| Key | key | The key to test. |
Returns
| Type | Description |
|---|---|
| bool |
|
WasKeyReleasedThisFrame(Key)
Returns whether the specified keyboard key transitioned to released this frame, resolved through the active bridge selection strategy.
Declaration
public bool WasKeyReleasedThisFrame(Key key)
Parameters
| Type | Name | Description |
|---|---|---|
| Key | key | The key to test. |
Returns
| Type | Description |
|---|---|
| bool |
|
WasMouseButtonPressedThisFrame(int)
Returns whether the specified mouse button transitioned to pressed this frame, resolved through the active bridge selection strategy.
Declaration
public bool WasMouseButtonPressedThisFrame(int button)
Parameters
| Type | Name | Description |
|---|---|---|
| int | button | Zero-based index: 0 = left, 1 = right, 2 = middle, 3 = forward, 4 = back. |
Returns
| Type | Description |
|---|---|
| bool |
|
WasMouseButtonReleasedThisFrame(int)
Returns whether the specified mouse button transitioned to released this frame, resolved through the active bridge selection strategy.
Declaration
public bool WasMouseButtonReleasedThisFrame(int button)
Parameters
| Type | Name | Description |
|---|---|---|
| int | button | Zero-based index: 0 = left, 1 = right, 2 = middle, 3 = forward, 4 = back. |
Returns
| Type | Description |
|---|---|
| bool |
|
Events
OnDeviceConnected
Raised when any input device is connected or reconnected through any registered bridge.
Declaration
public event Action<InputDevice> OnDeviceConnected
Event Type
| Type | Description |
|---|---|
| Action<InputDevice> |
Remarks
Aggregates OnDeviceConnected events from all registered bridges. Subscribers do not need to monitor individual bridges.
OnDeviceDisconnected
Raised when any input device is disconnected through any registered bridge.
Declaration
public event Action<InputDevice> OnDeviceDisconnected
Event Type
| Type | Description |
|---|---|
| Action<InputDevice> |
Remarks
Aggregates OnDeviceDisconnected events from all registered bridges. Subscribers do not need to monitor individual bridges.