Interface IScyllaInputBridge
Defines the contract for input bridges that translate raw hardware input into the normalized Scylla input abstraction layer.
Namespace: Scylla.Input
Assembly: ScyllaInput.dll
Syntax
public interface IScyllaInputBridge
Remarks
The bridge pattern decouples the Scylla Input module from any particular input backend. A bridge implementation wraps a specific input library or API (such as Unity's Input System) and exposes all device queries through this common interface. Callers interact exclusively with the bridge - they never touch the underlying input library directly.
Multiple bridges can be registered with IInputBridgeManager at once and queried in priority order, per device type, or in combination, depending on the configured InputBridgeQueryMode. Each bridge reports its own Priority so the manager can rank them.
Bridges follow an explicit lifecycle: Initialize() is called once when
the bridge is registered (or when the manager itself initializes), Update()
is called once per frame by the manager, and Shutdown() is called when
the bridge is unregistered or the module shuts down. A bridge should only report
IsAvailable as true after successful initialization.
The default built-in implementation is UnityInputSystemBridge, which wraps Unity's Input System package with a priority of 100.
Properties
BridgeID
Gets the unique string identifier for this bridge instance.
Declaration
string BridgeID { get; }
Property Value
| Type | Description |
|---|---|
| string | A non-null, non-empty string that uniquely identifies this bridge within the IInputBridgeManager. Used as a key for registration, lookup, and per-device-type routing. Two bridges with the same ID cannot both be registered. |
IsAvailable
Gets whether this bridge is currently initialized and able to service input queries.
Declaration
bool IsAvailable { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Priority
Gets the dispatch priority for this bridge. Higher values are queried first.
Declaration
int Priority { get; }
Property Value
| Type | Description |
|---|---|
| int | Any integer. The built-in UnityInputSystemBridge uses a priority of 100. When SingleBridge or PriorityChain is active, bridges with a higher priority value are consulted before bridges with a lower value. Priority can be overridden at runtime via SetBridgePriority(string, int). |
Methods
GetCurrentGamepad()
Returns a reference to the primary active gamepad device.
Declaration
Gamepad GetCurrentGamepad()
Returns
| Type | Description |
|---|---|
| Gamepad | The first connected UnityEngine.InputSystem.Gamepad as tracked by this bridge, or |
GetDeviceType(InputDevice)
Classifies an input device into one of the known InputDeviceType categories.
Declaration
InputDeviceType GetDeviceType(InputDevice device)
Parameters
| Type | Name | Description |
|---|---|---|
| InputDevice | device | The device to classify. May be |
Returns
| Type | Description |
|---|---|
| InputDeviceType | The InputDeviceType that best describes |
GetDevices()
Returns the list of all input devices that are currently recognized and enabled by this bridge.
Declaration
IReadOnlyList<InputDevice> GetDevices()
Returns
| Type | Description |
|---|---|
| IReadOnlyList<InputDevice> | A read-only snapshot of the active device list. Never |
GetGamepadLeftStick()
Returns the current value of the left analog stick on the active gamepad.
Declaration
Vector2 GetGamepadLeftStick()
Returns
| Type | Description |
|---|---|
| Vector2 | A UnityEngine.Vector2 with both components in the range [-1, 1], where (0, 0) is the resting center position; UnityEngine.Vector2.zero if no gamepad is connected or if the bridge is unavailable. |
GetGamepadLeftTrigger()
Returns the current analog value of the left trigger on the active gamepad.
Declaration
float GetGamepadLeftTrigger()
Returns
| Type | Description |
|---|---|
| float | A value in the range [0, 1], where 0 means fully released and 1 means fully
depressed; |
GetGamepadRightStick()
Returns the current value of the right analog stick on the active gamepad.
Declaration
Vector2 GetGamepadRightStick()
Returns
| Type | Description |
|---|---|
| Vector2 | A UnityEngine.Vector2 with both components in the range [-1, 1], where (0, 0) is the resting center position; UnityEngine.Vector2.zero if no gamepad is connected or if the bridge is unavailable. |
GetGamepadRightTrigger()
Returns the current analog value of the right trigger on the active gamepad.
Declaration
float GetGamepadRightTrigger()
Returns
| Type | Description |
|---|---|
| float | A value in the range [0, 1], where 0 means fully released and 1 means fully
depressed; |
GetLastUsedDevice()
Returns the most recently active input device as determined by this bridge.
Declaration
InputDevice GetLastUsedDevice()
Returns
| Type | Description |
|---|---|
| InputDevice | The UnityEngine.InputSystem.InputDevice that last produced input (key press, mouse movement,
or gamepad axis activity), or |
GetMouseDelta()
Returns the mouse movement delta accumulated since the previous frame.
Declaration
Vector2 GetMouseDelta()
Returns
| Type | Description |
|---|---|
| Vector2 | The per-frame mouse displacement in pixels as a UnityEngine.Vector2; UnityEngine.Vector2.zero if the mouse did not move, if no mouse is connected, or if the bridge is unavailable. |
GetMousePosition()
Returns the current mouse cursor position in screen-space pixel coordinates, with (0, 0) at the bottom-left corner of the screen.
Declaration
Vector2 GetMousePosition()
Returns
| Type | Description |
|---|---|
| Vector2 | The mouse position as a UnityEngine.Vector2 in pixels; UnityEngine.Vector2.zero if no mouse is connected or if the bridge is unavailable. |
GetMouseScrollDelta()
Returns the scroll wheel input delta for the current frame.
Declaration
Vector2 GetMouseScrollDelta()
Returns
| Type | Description |
|---|---|
| Vector2 | A UnityEngine.Vector2 where |
Initialize()
Initializes the bridge, setting up its connection to the underlying input backend and populating the initial device list.
Declaration
void Initialize()
Remarks
Called by Initialize() for all bridges that are
already registered at manager initialization time, or immediately upon registration
if the manager has already been initialized. Implementations must set
IsAvailable to true only after successful setup. Calling
Initialize() a second time without an intervening Shutdown()
should be a no-op (or emit a warning) rather than re-initializing internal state.
IsAnyKeyPressed()
Returns whether at least one keyboard key is currently held down.
Declaration
bool IsAnyKeyPressed()
Returns
| Type | Description |
|---|---|
| bool |
|
IsGamepadButtonPressed(GamepadButton)
Returns whether the specified gamepad button is currently held down.
Declaration
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 and recognized by this bridge.
Declaration
bool IsGamepadConnected()
Returns
| Type | Description |
|---|---|
| bool |
|
IsKeyPressed(Key)
Returns whether the specified keyboard key is currently held down.
Declaration
bool IsKeyPressed(Key key)
Parameters
| Type | Name | Description |
|---|---|---|
| Key | key | The key to test, as a Unity Input System UnityEngine.InputSystem.Key value. |
Returns
| Type | Description |
|---|---|
| bool |
|
IsMouseButtonPressed(int)
Returns whether the specified mouse button is currently held down.
Declaration
bool IsMouseButtonPressed(int button)
Parameters
| Type | Name | Description |
|---|---|---|
| int | button | The zero-based button index: 0 = left, 1 = right, 2 = middle, 3 = forward,
4 = back. Indices outside the range 0-4 always return |
Returns
| Type | Description |
|---|---|
| bool |
|
IsMouseConnected()
Returns whether a mouse device is currently connected and recognized by this bridge.
Declaration
bool IsMouseConnected()
Returns
| Type | Description |
|---|---|
| bool |
|
Shutdown()
Shuts down the bridge, releasing all resources and event subscriptions acquired during initialization.
Declaration
void Shutdown()
Remarks
Called by IInputBridgeManager when the bridge is unregistered via
UnregisterBridge(string) or when the manager itself
shuts down. After this call, IsAvailable must return false
and all input query methods must return their default zero/false values. Calling
Shutdown() on an already-shutdown bridge should be a safe no-op.
Update()
Updates per-frame bridge state, such as tracking the most recently used device.
Declaration
void Update()
Remarks
Called once per frame by Update() for every bridge
where IsAvailable is true. Implementations that do not require
per-frame maintenance may leave this as an empty body.
WasGamepadButtonPressedThisFrame(GamepadButton)
Returns whether the specified gamepad button transitioned from released to pressed during the current frame.
Declaration
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 from pressed to released during the current frame.
Declaration
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 from released to pressed during the current frame.
Declaration
bool WasKeyPressedThisFrame(Key key)
Parameters
| Type | Name | Description |
|---|---|---|
| Key | key | The key to test, as a Unity Input System UnityEngine.InputSystem.Key value. |
Returns
| Type | Description |
|---|---|
| bool |
|
WasKeyReleasedThisFrame(Key)
Returns whether the specified keyboard key transitioned from pressed to released during the current frame.
Declaration
bool WasKeyReleasedThisFrame(Key key)
Parameters
| Type | Name | Description |
|---|---|---|
| Key | key | The key to test, as a Unity Input System UnityEngine.InputSystem.Key value. |
Returns
| Type | Description |
|---|---|
| bool |
|
WasMouseButtonPressedThisFrame(int)
Returns whether the specified mouse button transitioned from released to pressed during the current frame.
Declaration
bool WasMouseButtonPressedThisFrame(int button)
Parameters
| Type | Name | Description |
|---|---|---|
| int | button | The zero-based button index: 0 = left, 1 = right, 2 = middle, 3 = forward,
4 = back. Indices outside the range 0-4 always return |
Returns
| Type | Description |
|---|---|
| bool |
|
WasMouseButtonReleasedThisFrame(int)
Returns whether the specified mouse button transitioned from pressed to released during the current frame.
Declaration
bool WasMouseButtonReleasedThisFrame(int button)
Parameters
| Type | Name | Description |
|---|---|---|
| int | button | The zero-based button index: 0 = left, 1 = right, 2 = middle, 3 = forward,
4 = back. Indices outside the range 0-4 always return |
Returns
| Type | Description |
|---|---|
| bool |
|
Events
OnDeviceConnected
Raised when a new input device is connected or reconnected through this bridge.
Declaration
event Action<InputDevice> OnDeviceConnected
Event Type
| Type | Description |
|---|---|
| Action<InputDevice> |
Remarks
The IInputBridgeManager subscribes to this event on each registered bridge and re-raises it as its own OnDeviceConnected event, so consumers do not need to subscribe to individual bridges.
OnDeviceDisconnected
Raised when a previously connected input device is disconnected through this bridge.
Declaration
event Action<InputDevice> OnDeviceDisconnected
Event Type
| Type | Description |
|---|---|
| Action<InputDevice> |
Remarks
The IInputBridgeManager subscribes to this event on each registered bridge and re-raises it as its own OnDeviceDisconnected event, so consumers do not need to subscribe to individual bridges.