docs
Systems
Infrastructure
InputSystem
Public API Reference

ClickDetector

Public class. Evaluates press and release timing to raise a click only when the press is short enough.

Constructor

public ClickDetector(float threshold)
  • threshold: the maximum press duration in seconds that still counts as a click.

Events

public event Action<Vector3> OnClick;

Raised on release when the press lasted no longer than the threshold. The argument is the release position.

Methods

public void Reset()

Clears the stored press time. A later release will not raise OnClick until a new press is recorded.

Internal members

These are internal. Only code in the same assembly can call them. InputManager calls them.

internal void OnPressed(Vector3 position)

Records Time.time as the press time. The position argument is not used.

internal void OnReleased(Vector3 position)

Does nothing if no press was recorded. Otherwise it computes the elapsed time, clears the press time, and raises OnClick with position if the elapsed time is within the threshold.

DoubleClickDetector

Public class. Detects two clicks that arrive within a time window.

Constructor

public DoubleClickDetector(float threshold)
  • threshold: the maximum time in seconds between two presses that still counts as a double-click.

Events

public event Action OnDoubleClick;

Raised when a second click arrives within the threshold of the first.

Methods

public void RegisterClick(float currentTime)
  • currentTime: the time of the click, usually Time.time.

The first call stores the time. A later call within the threshold raises OnDoubleClick and clears the stored time, so the next click starts fresh. A later call outside the threshold replaces the stored time.

public void Reset()

Clears the stored first-click time.

InputConstants

Public static class with timing and distance thresholds.

public const float ClickThreshold = 0.2f;
public const float DoubleClickTime = 0.3f;
public const float DragThreshold = 10f;
  • ClickThreshold: maximum press-to-release time in seconds for a click.
  • DoubleClickTime: maximum time in seconds between two presses for a double-click.
  • DragThreshold: distance in pixels the pointer must move while pressed before the press counts as a drag.

InputEventVerb

Public enum. Describes what happened to the pointer or touch.

public enum InputEventVerb
{
    Pressed = 0,
    Released = 1,
    Held = 2,
    Moved = 3,
    Clicked = 4,
    DoubleClicked = 5,
    Started = 6,
    Ended = 7,
}
  • Pressed: the pointer or touch went down.
  • Released: the pointer or touch went up.
  • Held: the pointer or touch is down. Raised every frame while held.
  • Moved: the pointer moved to a new position. Raised by the mouse path only.
  • Clicked: a single click or tap without a drag.
  • DoubleClicked: a double click or double tap.
  • Started: a drag started. The subject says what.
  • Ended: a drag ended. The subject says what.

InputSubject

Public enum. Describes what an input event is about.

public enum InputSubject
{
    Pointer = 0,
    Drag = 1,
}
  • Pointer: the pointer or touch itself.
  • Drag: a drag, used with Started and Ended.

InputKeyNames

Public static class with the string names behind the input param keys.

public const string ScreenPosition = "core.input.screenPosition";
public const string Subject = "core.input.subject";

The class also defines a private Base constant, which is not part of the public surface.

InputParamKeys

Public static class with typed param keys for input events.

public static readonly ParamKey<Vector3> ScreenPosition;
public static readonly ParamKey<InputSubject> Subject;
  • ScreenPosition: the screen position of the input, in pixels.
  • Subject: the subject of the input event. The builder sets it automatically.

InputFlowController

Public class. Derives from FlowController. Owns the Input domain.

protected override Domain Domain { get; }  // returns Domain.Input
public override void Init();
protected override void HandleCommand(ICommand cmd);
  • Domain: returns Domain.Input.
  • Init: calls the base Init, creates an InputManager, and registers it with the update system.
  • HandleCommand: logs a warning and ignores the command. The Input domain does not handle commands yet.

InputManager

Public class. Implements IUpdateable. Created by InputFlowController.

internal InputManager();
public void OnUpdate();
  • The constructor is internal. It creates a DoubleClickDetector and a ClickDetector, and it subscribes both to send DoubleClicked and Clicked events.
  • OnUpdate: runs the touch path on Android and the mouse path on other platforms. It is called once per frame by the update system.

The class also has private methods for mouse handling, touch handling, hit resolution, and interaction dispatch. These are not part of the public surface.

IInteractable

Public interface in SaffronLibrary.Prime.Systems.Input.Interfaces.

public interface IInteractable
{
    void OnInteraction();
}
  • OnInteraction: called on each IInteractable component found on a pressed object or its parents.

IInteractionResponder

Public interface in SaffronLibrary.Prime.Systems.Input.Interfaces.

public interface IInteractionResponder
{
    void OnInteracted();
}
  • OnInteracted: intended as a callback after an interaction cycle completes.

InputMessageBuilder

Public sealed class. Derives from the shared MessageBuilder base, which is documented elsewhere.

public static InputMessageBuilder Create(InputEventVerb verb, InputSubject subject);
protected override Domain TargetDomain { get; }  // returns Domain.Input
protected override Message CreateMessage(int verb);
  • Create: starts a new input event with the given verb and subject. The subject is added as a param.
  • TargetDomain: returns Domain.Input.
  • CreateMessage: creates an Event on the Input domain with the given verb.

The fluent methods AddParam, BuildMessage, Send, ErrorMessage, and AddParamCollection come from the base builder.

The constructor is private. Use Create.