Skip to content
Eduard Gushchin edited this page Jun 21, 2026 · 5 revisions

Home | API by Category | Complete API Index | API Compatibility

Field Value
Full name Electron2D.Input
Namespace Electron2D
Kind class
Category Input

Overview

Provides process-wide action input state.

Syntax

public static class Electron2D.Input

Remarks

The input state is fed by Electron2D.SceneTree.DispatchInput(Electron2D.InputEvent) through the action bindings registered in Electron2D.InputMap. It stores frame-local transition state such as Electron2D.Input.IsActionJustPressed(System.String,System.Boolean).

0.1.0 Preview supports keyboard bindings, mouse button bindings, gamepad bindings and direct Electron2D.InputEventAction events. Touch input is delivered as screen touch and drag events and is not an action binding in this baseline.

Thread Safety

All methods synchronize access to the process-wide input state.

Since

This class is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.InputMap

Members

Member Kind Summary
GetActionStrength(System.String, System.Boolean) Method Gets the current strength of an action.
GetConnectedJoypads() Method Gets the connected gamepad device ids.
GetJoyAxis(System.Int32, Electron2D.JoyAxis) Method Gets the last known value for a gamepad axis.
GetJoyName(System.Int32) Method Gets the display name for a connected gamepad.
GetJoyVibrationDuration(System.Int32) Method Gets the active vibration duration for a gamepad.
GetJoyVibrationStrength(System.Int32) Method Gets the active vibration strength for a gamepad.
GetVector(System.String, System.String, System.String, System.String, System.Single) Method Gets a 2D vector from four directional actions.
IsActionJustPressed(System.String, System.Boolean) Method Checks whether an action became pressed during the current frame.
IsActionPressed(System.String, System.Boolean) Method Checks whether an action is currently pressed.
IsJoyButtonPressed(System.Int32, Electron2D.JoyButton) Method Checks whether a gamepad button is currently pressed.
IsJoyKnown(System.Int32) Method Checks whether a connected gamepad uses a known mapping.
StartJoyVibration(System.Int32, System.Single, System.Single, System.Single) Method Starts gamepad vibration when the device supports it.
StopJoyVibration(System.Int32) Method Stops gamepad vibration.

Member Details

GetActionStrength(System.String, System.Boolean)

Kind: Method

public static System.Single GetActionStrength(System.String, System.Boolean)(System.String action, System.Boolean exactMatch)

Summary

Gets the current strength of an action.

Remarks

This method follows the validation and lifetime rules of its declaring type.

Parameters

  • action: The action name to query.
  • exactMatch: Reserved for exact modifier/device matching in future input work.

Returns

The action strength in the range 0.0 through 1.0, or 0.0 for unknown or released actions.

Exceptions

  • System.ArgumentException: Thrown when action is empty.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.InputMap.ActionGetDeadzone(System.String)

GetConnectedJoypads()

Kind: Method

public static System.Int32[] GetConnectedJoypads()()

Summary

Gets the connected gamepad device ids.

Remarks

Device ids are runtime-local identifiers reported by the platform input layer. They are not stable across process restarts and should not be persisted in project files.

Returns

A stable ascending snapshot of connected gamepad device ids.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Input.GetJoyName(System.Int32)
  • Electron2D.Input.IsJoyKnown(System.Int32)

GetJoyAxis(System.Int32, Electron2D.JoyAxis)

Kind: Method

public static System.Single GetJoyAxis(System.Int32, Electron2D.JoyAxis)(System.Int32 device, Electron2D.JoyAxis axis)

Summary

Gets the last known value for a gamepad axis.

Remarks

The value is updated when an Electron2D.InputEventJoypadMotion is dispatched through Electron2D.SceneTree. Unknown devices and invalid axes fail closed and return zero.

Parameters

  • device: The runtime-local gamepad device id.
  • axis: The axis to query.

Returns

The normalized axis value in the range -1.0 through 1.0, or 0.0 when the device or axis is unknown.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.InputEventJoypadMotion

GetJoyName(System.Int32)

Kind: Method

public static System.String GetJoyName(System.Int32)(System.Int32 device)

Summary

Gets the display name for a connected gamepad.

Remarks

This method follows the validation and lifetime rules of its declaring type.

Parameters

  • device: The runtime-local gamepad device id.

Returns

The device name, or an empty string when the device is unknown or has no reported name.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Input.GetConnectedJoypads

GetJoyVibrationDuration(System.Int32)

Kind: Method

public static System.Single GetJoyVibrationDuration(System.Int32)(System.Int32 device)

Summary

Gets the active vibration duration for a gamepad.

Remarks

A duration of 0.0 can also represent an indefinite active effect. Use Electron2D.Input.GetJoyVibrationStrength(System.Int32) to distinguish an indefinite active effect from an inactive device.

Parameters

  • device: The runtime-local gamepad device id.

Returns

The requested vibration duration in seconds, or 0.0 when no vibration is active or the device is unknown.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Input.StartJoyVibration(System.Int32,System.Single,System.Single,System.Single)
  • Electron2D.Input.StopJoyVibration(System.Int32)

GetJoyVibrationStrength(System.Int32)

Kind: Method

public static Electron2D.Vector2 GetJoyVibrationStrength(System.Int32)(System.Int32 device)

Summary

Gets the active vibration strength for a gamepad.

Remarks

Unknown or unsupported devices return Electron2D.Vector2.Zero.

Parameters

  • device: The runtime-local gamepad device id.

Returns

A vector where Electron2D.Vector2.X is the weak motor strength and Electron2D.Vector2.Y is the strong motor strength. Both components are in the range 0.0 through 1.0.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Input.StartJoyVibration(System.Int32,System.Single,System.Single,System.Single)
  • Electron2D.Input.StopJoyVibration(System.Int32)

GetVector(System.String, System.String, System.String, System.String, System.Single)

Kind: Method

public static Electron2D.Vector2 GetVector(System.String, System.String, System.String, System.String, System.Single)(System.String negativeX, System.String positiveX, System.String negativeY, System.String positiveY, System.Single deadzone)

Summary

Gets a 2D vector from four directional actions.

Remarks

This method follows the validation and lifetime rules of its declaring type.

Parameters

  • negativeX: The action used for negative X movement.
  • positiveX: The action used for positive X movement.
  • negativeY: The action used for negative Y movement.
  • positiveY: The action used for positive Y movement.
  • deadzone: The vector deadzone. Use a negative value to average the four action deadzones from Electron2D.InputMap.

Returns

A vector whose components are built from action strengths and whose length is clamped to 1.0.

Exceptions

  • System.ArgumentException: Thrown when any action name is empty or deadzone is not finite.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Input.GetActionStrength(System.String,System.Boolean)

IsActionJustPressed(System.String, System.Boolean)

Kind: Method

public static System.Boolean IsActionJustPressed(System.String, System.Boolean)(System.String action, System.Boolean exactMatch)

Summary

Checks whether an action became pressed during the current frame.

Remarks

This method follows the validation and lifetime rules of its declaring type.

Parameters

  • action: The action name to query.
  • exactMatch: Reserved for exact modifier/device matching in future input work.

Returns

true when the action transitioned from released to pressed since the previous transition flush; otherwise, false.

Exceptions

  • System.ArgumentException: Thrown when action is empty.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Input.IsActionPressed(System.String,System.Boolean)

IsActionPressed(System.String, System.Boolean)

Kind: Method

public static System.Boolean IsActionPressed(System.String, System.Boolean)(System.String action, System.Boolean exactMatch)

Summary

Checks whether an action is currently pressed.

Remarks

This method follows the validation and lifetime rules of its declaring type.

Parameters

  • action: The action name to query.
  • exactMatch: Reserved for exact modifier/device matching in future input work.

Returns

true when the action currently has a positive strength; otherwise, false.

Exceptions

  • System.ArgumentException: Thrown when action is empty.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Input.GetActionStrength(System.String,System.Boolean)

IsJoyButtonPressed(System.Int32, Electron2D.JoyButton)

Kind: Method

public static System.Boolean IsJoyButtonPressed(System.Int32, Electron2D.JoyButton)(System.Int32 device, Electron2D.JoyButton button)

Summary

Checks whether a gamepad button is currently pressed.

Remarks

The state is updated by Electron2D.InputEventJoypadButton dispatch. Invalid buttons and unknown devices return false.

Parameters

  • device: The runtime-local gamepad device id.
  • button: The button to query.

Returns

true when the button is pressed on the connected device; otherwise, false.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.InputEventJoypadButton

IsJoyKnown(System.Int32)

Kind: Method

public static System.Boolean IsJoyKnown(System.Int32)(System.Int32 device)

Summary

Checks whether a connected gamepad uses a known mapping.

Remarks

Devices created from button or axis events without metadata are treated as unknown until the platform input layer supplies mapping information.

Parameters

  • device: The runtime-local gamepad device id.

Returns

true when the device is connected and its mapping is known; otherwise, false.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Input

StartJoyVibration(System.Int32, System.Single, System.Single, System.Single)

Kind: Method

public static System.Void StartJoyVibration(System.Int32, System.Single, System.Single, System.Single)(System.Int32 device, System.Single weakMagnitude, System.Single strongMagnitude, System.Single duration)

Summary

Starts gamepad vibration when the device supports it.

Remarks

Magnitudes are clamped to 0.0 through 1.0. Unknown devices and devices without vibration support are ignored without throwing.

This baseline records the requested state for the platform backend. It does not expose native haptic handles through the public API.

Parameters

  • device: The runtime-local gamepad device id.
  • weakMagnitude: The weak motor strength.
  • strongMagnitude: The strong motor strength.
  • duration: The duration in seconds. Values less than or equal to 0.0 request an indefinite effect.

Exceptions

  • System.ArgumentException: Thrown when weakMagnitude, strongMagnitude or duration is not finite.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Input.GetJoyVibrationStrength(System.Int32)
  • Electron2D.Input.StopJoyVibration(System.Int32)

StopJoyVibration(System.Int32)

Kind: Method

public static System.Void StopJoyVibration(System.Int32)(System.Int32 device)

Summary

Stops gamepad vibration.

Remarks

Unknown devices and devices without vibration support are ignored without throwing.

Parameters

  • device: The runtime-local gamepad device id.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Input.StartJoyVibration(System.Int32,System.Single,System.Single,System.Single)

Clone this wiki locally