Class UnityInputSystemBridge
The default IScyllaInputBridge implementation that wraps Unity's Input System package to provide keyboard, mouse, and gamepad input to the Scylla Input module.
Implements
Inherited Members
Namespace: Scylla.Input
Assembly: ScyllaInput.dll
Syntax
public class UnityInputSystemBridge : IScyllaInputBridge
Remarks
This bridge is automatically registered by ScyllaInput at startup with a
priority of 100. It subscribes to InputSystem.onDeviceChange to maintain
an accurate list of connected devices and raises OnDeviceConnected
and OnDeviceDisconnected when devices are added or removed.
Per-frame, Update() polls keyboard, mouse, and gamepad activity to track the last used device. Priority order for last-used detection is: keyboard key press, then mouse movement or button press, then gamepad stick or button activity.
Mouse buttons beyond index 4 are not supported and will always return false.
Similarly, gamepad button enum values not covered by GetGamepadButtonControl
return false rather than throwing.
Properties
BridgeID
Gets the unique string identifier for this bridge instance.
Declaration
public 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
public bool IsAvailable { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Priority
Gets the dispatch priority for this bridge. Higher values are queried first.
Declaration
public 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
public 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
public 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
public 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
public 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
public 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
public 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
public 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
public 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
public 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
public 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
public 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
public 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
public bool IsAnyKeyPressed()
Returns
| Type | Description |
|---|---|
| bool |
|
IsGamepadButtonPressed(GamepadButton)
Returns whether the specified gamepad button is currently held down.
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 and recognized by this bridge.
Declaration
public bool IsGamepadConnected()
Returns
| Type | Description |
|---|---|
| bool |
|
IsKeyPressed(Key)
Returns whether the specified keyboard key is currently held down.
Declaration
public 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
public 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
public bool IsMouseConnected()
Returns
| Type | Description |
|---|---|
| bool |
|
Shutdown()
Shuts down the bridge, releasing all resources and event subscriptions acquired during initialization.
Declaration
public 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
public 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
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 from pressed to released during the current frame.
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 from released to pressed during the current frame.
Declaration
public 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
public 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
public 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
public 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
public 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
public 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.