Scylla Framework
  • API Reference
Search Results for

    Show / Hide Table of Contents
    • Scylla.Input
      • AutoResolveChange
      • AutoResolveResult
      • BindingConflict
      • BindingStorageSettings
      • BindingStorageType
      • BridgeSettings
      • BufferedInput
      • ConfigActionEntry
      • ConfigBindingEntry
      • ConfigConflict
      • ConfigSchemeGroup
      • ContextValidationMessage
      • ContextValidationSeverity
      • ControlScheme
      • ControlSchemeChangedEvent
      • ControlSchemeManager
      • ControlSchemeType
      • GamepadButton
      • GamepadType
      • IBindingStorage
      • IControlSchemeManager
      • IInputActionManager
      • IInputBindingManager
      • IInputBridgeManager
      • IInputBufferManager
      • IInputContextManager
      • IInputHintsManager
      • IInputListener
      • IScyllaInputBridge
      • InputActionCanceledEvent
      • InputActionManager
      • InputActionPerformedEvent
      • InputActionStartedEvent
      • InputBindingManager
      • InputBindingsLoadedEvent
      • InputBindingsSavedEvent
      • InputBridgeManager
      • InputBridgeQueryMode
      • InputBufferConsumedEvent
      • InputBufferManager
      • InputBufferedEvent
      • InputConflictResolution
      • InputContext
      • InputContextChangedEvent
      • InputContextDefinition
      • InputContextManager
      • InputContextPoppedEvent
      • InputContextPushedEvent
      • InputDeviceChangedEvent
      • InputDeviceConnectedEvent
      • InputDeviceDisconnectedEvent
      • InputDeviceType
      • InputDeviceUtil
      • InputDisabledEvent
      • InputEnabledEvent
      • InputEventType
      • InputHint
      • InputHintChangedEvent
      • InputHintsManager
      • InputIconSet
      • InputIconSet.IconMapping
      • InputIconSetChangedEvent
      • InputLoggingSettings
      • InputRebindCancelledEvent
      • InputRebindCompletedEvent
      • InputRebindManager
      • InputRebindOperation
      • InputRebindStartedEvent
      • InputRebindUtils
      • JSONFileBindingStorage
      • ManagedRebindCancelledEvent
      • ManagedRebindCompletedEvent
      • ManagedRebindDataRefreshedEvent
      • ManagedRebindStartedEvent
      • PlayerPrefsBindingStorage
      • RebindMode
      • RebindSettings
      • ScyllaInput
      • ScyllaInput.Meta
      • ScyllaInputAction
      • ScyllaInputActionMap
      • ScyllaInputBinding
      • ScyllaInputConfiguration
      • ScyllaInputContextConfiguration
      • ScyllaKey
      • ScyllaKeyConverter
      • ScyllaModifier
      • UnityInputSystemBridge
    • Scylla.Input.Editor
      • ControlSchemeDrawer
      • DeviceStatusWidget
      • IconMappingDrawer
      • InputIconSetEditor
      • ScyllaInputConfigurationEditor
      • ScyllaInputContextConfigurationEditor
      • ScyllaInputDependencyProvider
      • ScyllaInputEditor
      • ScyllaInputMenuItems
      • ScyllaInputWizard

    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.

    Inheritance
    object
    UnityInputSystemBridge
    Implements
    IScyllaInputBridge
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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

    true if the bridge has been successfully initialized and its underlying input backend is operational; false before Initialize() completes or after Shutdown() is called. The IInputBridgeManager skips bridges that report false during Update() and during input queries.

    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 null if no gamepad is connected or if the bridge is unavailable. The returned reference is the raw Unity Input System device object - callers should not cache it long-term as it may become invalid if the gamepad disconnects.

    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 null, in which case Unknown is returned.

    Returns
    Type Description
    InputDeviceType

    The InputDeviceType that best describes device, or Unknown if the device is unrecognized or null.

    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 null; may be empty if no devices are connected or if the bridge has not yet been initialized.

    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; 0f if no gamepad is connected or if the bridge is unavailable.

    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; 0f if no gamepad is connected or if the bridge is unavailable.

    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 null if no device has been used since initialization or if the previously used device has since disconnected.

    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 y represents vertical scroll (positive = up) and x represents horizontal scroll (positive = right); UnityEngine.Vector2.zero if no scroll occurred, if no mouse is connected, or if the bridge is unavailable.

    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

    true if any key is pressed; false if no key is down, if no keyboard is connected, or if the bridge is unavailable.

    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

    true if the button is actively pressed this frame; false if not pressed, if no gamepad is connected, or if the bridge is unavailable.

    IsGamepadConnected()

    Returns whether at least one gamepad is currently connected and recognized by this bridge.

    Declaration
    public bool IsGamepadConnected()
    Returns
    Type Description
    bool

    true if a gamepad is available; false if no gamepad is connected or if the bridge is unavailable.

    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

    true if the key is actively pressed this frame; false if the key is not pressed, if no keyboard is connected, or if the bridge is unavailable.

    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 false.

    Returns
    Type Description
    bool

    true if the button is actively pressed this frame; false if the button is not pressed, if no mouse is connected, or if the bridge is unavailable.

    IsMouseConnected()

    Returns whether a mouse device is currently connected and recognized by this bridge.

    Declaration
    public bool IsMouseConnected()
    Returns
    Type Description
    bool

    true if at least one mouse is connected and enabled; false otherwise or if the bridge is unavailable.

    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

    true only on the exact frame the button was first pressed; false in all subsequent frames while held, if no gamepad is connected, or if the bridge is unavailable.

    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

    true only on the exact frame the button was released; false in all other frames, if no gamepad is connected, or if the bridge is unavailable.

    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

    true only on the exact frame the key was first pressed; false in all subsequent frames while the key remains held, if no keyboard is connected, or if the bridge is unavailable.

    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

    true only on the exact frame the key was released; false in all other frames, if no keyboard is connected, or if the bridge is unavailable.

    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 false.

    Returns
    Type Description
    bool

    true only on the exact frame the button was first pressed; false in all subsequent frames while held, if no mouse is connected, or if the bridge is unavailable.

    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 false.

    Returns
    Type Description
    bool

    true only on the exact frame the button was released; false in all other frames, if no mouse is connected, or if the bridge is unavailable.

    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.

    Implements

    IScyllaInputBridge
    In this article
    Back to top Scylla Framework - Input Module API Documentation