InputSystem
The InputSystem turns raw mouse and touch input into clean, named events such as clicks, double-clicks, holds, and drags. It sits in the _Core/Infrastructure layer of SaffronLibrary, so other systems can respond to player input without reading the platform input API themselves.
Purpose in SaffronLibrary
Gameplay and UI code often needs the same answers: was this a tap or a drag, did the player double-click, and what did the pointer hit. This system answers those questions once, in one place. It also gives world objects a common IInteractable contract so that a press on a UI element can trigger that element's interaction logic.
Key Responsibilities
- Input detection:
InputManagerpolls mouse input on desktop and touch input on Android, and exposes presses, releases, holds, movement, drag start and end, clicks, and double-clicks as events. - Gesture classification:
ClickDetectorandDoubleClickDetectoruse timing windows to separate quick taps from holds and to recognize double-clicks. - Interaction routing:
InputManagerraycasts each press against the EventSystem and callsIInteractable.OnInteractionon matching components.InputHandlerforwards clicks and double-clicks to the UI system as UI events.
Who Should Use This
- Gameplay and UI developers who need to react to clicks, taps, or drags. Subscribe to
InputManager.Instancefor raw gestures, or listen for UI events if you only need clicks and double-clicks. - Engineers adding interactable world or UI objects who should implement
IInteractable. - Maintainers of the input pipeline, who should review the timing and threshold settings in
InputConstantsandInputManager.