Skip to content

Input

Brine2D

Brine2D.Input Namespace

Classes
CompositeKeyBinding Binds a combination of keys that must all be held simultaneously (e.g., Ctrl+S). Press is triggered when the final key completes the combo. Release is triggered when any key in the combo is released this frame, provided all keys were either held or released this frame (i.e., the combo was active).
GamepadAxisBinding Binds a gamepad stick axis (−1 to 1) with per-axis deadzone applied. Note: this uses a per-axis (not radial) deadzone comparison. A stick at 45° with small magnitude may report as active here while GetGamepadLeftStick(int) / GetGamepadRightStick(int) return System.Numerics.Vector2.Zero due to their radial deadzone. Use the stick helpers or GamepadStickBinding when you need consistent 2D directional input.
GamepadButtonBinding Binds a single gamepad button.
GamepadButtonPressedEvent Raised when a gamepad button is pressed.
GamepadButtonReleasedEvent Raised when a gamepad button is released.
GamepadConnectedEvent Raised when a gamepad is connected.
GamepadDisconnectedEvent Raised when a gamepad is disconnected.
GamepadStickBinding Binds a gamepad stick (left or right) and returns one axis of the radial-deadzone result. Use Brine2D.Input.GamepadStick.Left or Brine2D.Input.GamepadStick.Right to select the stick, and GamepadStickAxis to select X or Y. This applies the same radial deadzone as GetGamepadLeftStick(int) / GetGamepadRightStick(int), giving consistent 2D behavior through the binding system. Edge detection (Brine2D.Input.GamepadStickBinding.IsPressed(Brine2D.Input.IInputContext) / Brine2D.Input.GamepadStickBinding.IsReleased(Brine2D.Input.IInputContext)) delegates to the underlying per-axis methods but cross-checks the radial deadzone result so that Brine2D.Input.GamepadStickBinding.IsPressed(Brine2D.Input.IInputContext) cannot fire when the radial magnitude is below threshold.
GamepadTriggerBinding Binds a gamepad trigger (0 to 1) using GetGamepadTrigger(GamepadAxis, int). Unlike GamepadAxisBinding, this clamps to the 0–1 range and uses the trigger-specific pressed/released detection.
HeadlessInputContext No-op input context for headless mode (servers, testing). All input queries return false/zero - allows game logic to run without SDL.
InputAction A named logical input action with one or more physical bindings. Supports runtime rebinding. Query methods check all bindings and return the first positive match (for digital) or the largest magnitude (for analog).
InputActionMap A named collection of InputAction instances. Typically one map per game context (e.g., "Player", "UI", "Vehicle"). Set Enabled to false to suppress all actions in this map without unregistering them.
InputBinding Base type for all input bindings. Maps a physical input to a queryable state.
InputContext SDL3 implementation of the input context. Subscribes to internal SDL events and maintains per-frame input state. Publishes high-level, framework-agnostic events for user code.
InputContextCollectionExtensions
InputLayerManager Manages input layers and routes input to them in priority order. All layers are always invoked each frame; the consumed flag is forwarded so lower-priority layers can perform cleanup even when input was already claimed.
InputMapping Pure, stateless mapping tables between SDL3 input types and Brine2D input types. No dependencies — fully unit testable without SDL3 initialised.
InputOptions Configuration options for the input system.
KeyAxisBinding Binds two keys to a single axis (−1 to 1). Useful for keyboard-driven movement (e.g., A/D or Left/Right).
KeyBinding Binds a single keyboard key.
KeyPressedEvent Raised when a key is pressed.
KeyReleasedEvent Raised when a key is released.
MouseButtonBinding Binds a single mouse button.
MouseButtonPressedEvent Raised when a mouse button is pressed.
MouseButtonReleasedEvent Raised when a mouse button is released.
MouseDeltaBinding Binds one axis of the mouse delta (movement) to an analog value. Use Brine2D.Input.MouseDeltaAxis.X for horizontal and Brine2D.Input.MouseDeltaAxis.Y for vertical. Brine2D.Input.MouseDeltaBinding.ReadValue(Brine2D.Input.IInputContext) returns the raw delta for that axis this frame.
MouseMovedEvent Raised when the mouse is moved.
MouseScrollBinding Binds the vertical mouse scroll wheel to an analog value. Brine2D.Input.MouseScrollBinding.IsDown(Brine2D.Input.IInputContext) returns true when scroll delta is non-zero this frame. Brine2D.Input.MouseScrollBinding.ReadValue(Brine2D.Input.IInputContext) returns the raw scroll delta for the frame.
MouseScrolledEvent Raised when the mouse wheel is scrolled.
MouseScrollXBinding Binds the horizontal mouse scroll wheel to an analog value. Brine2D.Input.MouseScrollXBinding.IsDown(Brine2D.Input.IInputContext) returns true when horizontal scroll delta is non-zero this frame. Brine2D.Input.MouseScrollXBinding.ReadValue(Brine2D.Input.IInputContext) returns the raw horizontal scroll delta for the frame.
Interfaces
IInputContext Provides input handling for keyboard, mouse, and gamepad.
IInputLayer Represents a layer that can intercept and consume input events. Layers are processed in priority order (UI typically has highest priority). Every layer is always called each frame; the consumed parameter indicates whether a higher-priority layer already claimed that input category. Layers receiving consumed: true should skip gameplay logic but may perform bookkeeping (e.g., canceling a drag or resetting hover state).
Enums
GamepadAxis Gamepad axis identifiers.
GamepadButton Defines the standard gamepad button codes using Xbox-style layout conventions. These mappings are cross-platform compatible with PlayStation and other controller types.
GamepadStick Specifies which gamepad stick to bind.
GamepadStickAxis Specifies which axis of a gamepad stick to bind.
Key Keyboard key codes for input handling.
MouseButton Mouse button codes.
MouseDeltaAxis Specifies which axis of mouse movement to bind.