Input
A singleton for handling inputs.
A singleton for handling inputs.
The Input singleton handles key presses, mouse buttons and movement, gamepads, and input actions. Actions and their events can be set in the Input Map tab in Project > Project Settings, or with the InputMap class.
Note: Input's methods reflect the global input state and are not affected by Control.AcceptEvent or Viewport.SetInputAsHandled, as those methods only deal with the way input is propagated in the EntityTree.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties6
EmulateMouseFromTouchProperty
public static bool EmulateMouseFromTouch { get; set; }If true, sends mouse input events when tapping or swiping on the touchscreen. See also ProjectSettings.input_devices/pointing/emulate_mouse_from_touch.
EmulateTouchFromMouseProperty
public static bool EmulateTouchFromMouse { get; set; }If true, sends touch input events when clicking or dragging the mouse. See also ProjectSettings.input_devices/pointing/emulate_touch_from_mouse.
IgnoreJoypadOnUnfocusedApplicationProperty
public static bool IgnoreJoypadOnUnfocusedApplication { get; set; }If true, joypad input (including motion sensors) and LED light changes will be ignored and joypad vibration will be stopped when the application is not focused.
MouseModeProperty
public static Input.MouseModeEnum MouseMode { get; set; }Controls the mouse mode.
SingletonProperty
public static InputInstance Singleton { get; }UseAccumulatedInputProperty
public static bool UseAccumulatedInput { get; set; }Enables coalescing compatible events before delivery, such as summing several mouse-motion displacements. Does not merge arbitrary event types or guarantee one call per handler per frame. With false, coalescing is disabled, but agile_event_flushing can retain buffering. Changing this property does not flush events already queued.
Methods86
ActionPressvoid
public static void ActionPress(StringName action, float strength = 1f);Programmatically presses an existing action with strength clamped to 0–1. It affects Input polling but does not dispatch an InputEvent or call _Input() by itself. Use ParseInputEvent() for a synthetic event and ActionRelease() to end a programmatic press.
| Name | Type | Default |
|---|---|---|
action | StringName | — |
strength | float | 1f |
ActionReleasevoid
public static void ActionRelease(StringName action);Releases the specified input action, if the action is currently pressed.
| Name | Type | Default |
|---|---|---|
action | StringName | — |
AddJoyMappingvoid
public static void AddJoyMapping(string mapping, bool updateExisting = false);Adds a new joypad mapping entry (in SDL format) to the mapping database, and optionally updates the already connected devices. Note: See SDL documentation for more information about the SDL controller mapping format.
| Name | Type | Default |
|---|---|---|
mapping | string | — |
updateExisting | bool | false |
ClearJoyMotionSensorsCalibrationvoid
public static void ClearJoyMotionSensorsCalibration(int device);Clears the calibration information for the specified joypad's motion sensors, if it has any and if they were calibrated.
See Input.StartJoyMotionSensorsCalibration for an example on how to use joypad motion sensors and calibration in your games.
Note: This feature is only supported on Windows, Linux, macOS, and iOS.
| Name | Type | Default |
|---|---|---|
device | int | — |
FlushBufferedEventsvoid
public static void FlushBufferedEvents();Delivers queued Input events in order. Can synchronously invoke input handlers before this method returns. The engine also flushes in its loop; use explicit calls for controlled ordering, not universal acceleration. An empty queue does not replay previous events. Does not freshly poll physical devices or measure input-to-display latency.
GetAccelerometerVector3
public static Vector3 GetAccelerometer();Returns the acceleration in m/s² of the device's accelerometer sensor, if the device has one. Otherwise, the method returns Vector3.Zero.
Note this method returns an empty Vector3 when running from the editor even when your device has an accelerometer. You must export your project to a supported device to read values from the accelerometer.
Note: This method only works on Android and iOS. On other platforms, it always returns Vector3.Zero.
Note: For Android, ProjectSettings.input_devices/sensors/enable_accelerometer must be enabled.
Vector3GetActionRawStrengthfloat
public static float GetActionRawStrength(StringName action, bool exactMatch = false);Returns a value between 0.0 and 1.0 representing the raw intensity of the given action, ignoring the action's deadzone. In most cases, you should use Input.GetActionStrength instead.
If exact_match is false, it ignores additional input modifiers for InputEventKey and InputEventMouseButton events, and the direction for InputEventJoypadMotion events.
| Name | Type | Default |
|---|---|---|
action | StringName | — |
exactMatch | bool | false |
floatGetActionStrengthfloat
public static float GetActionStrength(StringName action, bool exactMatch = false);Returns a value between 0.0 and 1.0 representing the intensity of the given action. In a joypad, for example, the further away the axis (analog sticks or L2, R2 triggers) is from the dead zone, the closer the value will be to 1.0. If the action is mapped to a control that has no axis such as the keyboard, the value returned will be 0.0 or 1.0.
If exact_match is false, it ignores additional input modifiers for InputEventKey and InputEventMouseButton events, and the direction for InputEventJoypadMotion events.
| Name | Type | Default |
|---|---|---|
action | StringName | — |
exactMatch | bool | false |
floatGetAxisfloat
public static float GetAxis(StringName negativeAction, StringName positiveAction);Returns positive-action strength minus negative-action strength. Uses GetActionStrength and therefore differs from GetVector's circular two-axis handling.
| Name | Type | Default |
|---|---|---|
negativeAction | StringName | — |
positiveAction | StringName | — |
negativeActionExisting negative-direction action name.
positiveActionExisting positive-direction action name.
floatNormally -1 to 1; zero can mean no input or cancellation between both directions.
GetConnectedJoypadsReckfell.Collections.Array<int>
public static Reckfell.Collections.Array<int> GetConnectedJoypads();Returns IDs of devices marked connected. Do not assume the first ID is 0 or permanently identifies a player after reconnection.
Reckfell.Collections.Array<int>Array of current connected IDs; may be empty. A synthetic axis event alone does not establish a physical-device connection.
GetCurrentCursorShapeInput.CursorShape
public static Input.CursorShape GetCurrentCursorShape();Returns the currently assigned cursor shape.
Input.CursorShapeGetDeviceOrientationQuaternion
public static Quaternion GetDeviceOrientation();Returns the device's orientation as a Quaternion, using hardware-level sensor fusion for stable, drift-free results. If the device does not support orientation sensing, the method returns Quaternion.Identity.
The returned quaternion represents the rotation from the device coordinate frame to the world coordinate frame. In portrait mode, the device's coordinate system is: X right, Y up, Z towards viewer.
Note: This method only works on Android and iOS. On other platforms, it always returns Quaternion.Identity.
Note: For Android, ProjectSettings.input_devices/sensors/enable_device_orientation must be enabled.
QuaternionGetGravityVector3
public static Vector3 GetGravity();Returns the gravity in m/s² of the device's accelerometer sensor, if the device has one. Otherwise, the method returns Vector3.Zero.
Note: This method only works on Android and iOS. On other platforms, it always returns Vector3.Zero.
Note: For Android, ProjectSettings.input_devices/sensors/enable_gravity must be enabled.
Vector3GetGyroscopeVector3
public static Vector3 GetGyroscope();Returns the rotation rate in rad/s around a device's X, Y, and Z axes of the gyroscope sensor, if the device has one. Otherwise, the method returns Vector3.Zero.
Note: This method only works on Android and iOS. On other platforms, it always returns Vector3.Zero.
Note: For Android, ProjectSettings.input_devices/sensors/enable_gyroscope must be enabled.
Vector3GetJoyAccelerometerVector3
public static Vector3 GetJoyAccelerometer(int device);Returns the acceleration, including the force of gravity, in m/s² of the joypad's accelerometer sensor, if the joypad has one and it's currently enabled. Otherwise, the method returns Vector3.Zero. See also Input.GetJoyGravity and Input.SetJoyMotionSensorsEnabled.
For a joypad held in front of you, the returned axes are defined as follows:
+X ... -X: left ... right;
+Y ... -Y: bottom ... top;
+Z ... -Z: farther ... closer.
The gravity part value is measured as a vector with length of 9.8 away from the center of the Earth, which is a negative Y value.
Note: This feature is only supported on Windows, Linux, macOS, and iOS.
| Name | Type | Default |
|---|---|---|
device | int | — |
Vector3GetJoyAxisfloat
public static float GetJoyAxis(int device, JoyAxis axis);Reads a stored physical-axis value for a specific device. Does not apply an Input Map deadzone or prove the device is currently connected.
| Name | Type | Default |
|---|---|---|
device | int | — |
axis | JoyAxis | — |
deviceCurrent controller ID, not a player number. Use GetConnectedJoypads for the connected-device list.
axisJoyAxis selection, such as LeftX. Check direction and assignment on the target device.
floatStored axis value, or 0 when no entry exists. Zero is not a connection check.
GetJoyGravityVector3
public static Vector3 GetJoyGravity(int device);Returns the gravity in m/s² of the joypad's accelerometer sensor, if the joypad has one and it's currently enabled. Otherwise, the method returns Vector3.Zero. See also Input.GetJoyAccelerometer and Input.SetJoyMotionSensorsEnabled.
For a joypad held in front of you, the returned axes are defined as follows:
+X ... -X: left ... right;
+Y ... -Y: bottom ... top;
+Z ... -Z: farther ... closer.
The gravity part value is measured as a vector with length of 9.8 away from the center of the Earth, which is a negative Y value.
Note: This feature is only supported on Windows, Linux, macOS, and iOS.
| Name | Type | Default |
|---|---|---|
device | int | — |
Vector3GetJoyGuidstring
public static string GetJoyGuid(int device);Returns an SDL-compatible device GUID on platforms that use gamepad remapping, e.g. 030000004c050000c405000000010000. Returns an empty string if it cannot be found. Reckfell uses SDL's internal mappings, supplemented by community-contributed mappings, to determine gamepad names and mappings based on this GUID.
| Name | Type | Default |
|---|---|---|
device | int | — |
stringGetJoyGyroscopeVector3
public static Vector3 GetJoyGyroscope(int device);Reads calibrated gyroscope angular velocity. Check connection, sensor capability, enablement, and calibration state before use.
| Name | Type | Default |
|---|---|---|
device | int | — |
deviceController ID with prepared sensors.
Vector3Vector3 in radians per second. Missing data or ignored input returns zero; zero does not prove stillness or lack of drift.
GetJoyInfoReckfell.Collections.Dictionary
public static Reckfell.Collections.Dictionary GetJoyInfo(int device);Returns a dictionary with extra platform-specific information about the device, e.g. the raw gamepad name from the OS or the Steam Input index.
On Windows, Linux, macOS, and iOS, the dictionary contains the following fields:
raw_name: The name of the controller as it came from the OS, before getting renamed by the controller database.
vendor_id: The USB vendor ID of the device.
product_id: The USB product ID of the device.
serial_number: The serial number of the device. This key won't be present if the serial number is unavailable.
The dictionary can also include the following fields under selected platforms:
steam_input_index: The Steam Input gamepad index (Windows, Linux, and macOS only). If the device is not a Steam Input device this key won't be present.
xinput_index: The index of the controller in the XInput system (Windows only). This key won't be present for devices not handled by XInput.
Note: The returned dictionary is always empty on Android and Web.
| Name | Type | Default |
|---|---|---|
device | int | — |
Reckfell.Collections.DictionaryGetJoyMotionSensorsCalibrationReckfell.Collections.Dictionary
public static Reckfell.Collections.Dictionary GetJoyMotionSensorsCalibration(int device);Returns the calibration information about the specified joypad's motion sensors in the form of a Reckfell.Collections.Dictionary, if it has any and if they have been calibrated, otherwise returns an empty Reckfell.Collections.Dictionary.
The dictionary contains the following fields:
gyroscope_offset: average offset in gyroscope values from Vector2.Zero in rad/s.
See Input.StartJoyMotionSensorsCalibration for an example on how to use joypad motion sensors and calibration in your games.
Note: This feature is only supported on Windows, Linux, macOS, and iOS.
| Name | Type | Default |
|---|---|---|
device | int | — |
Reckfell.Collections.DictionaryGetJoyMotionSensorsRatefloat
public static float GetJoyMotionSensorsRate(int device);Returns the joypad's motion sensor rate in Hz, if the joypad has motion sensors and they're currently enabled. See also Input.SetJoyMotionSensorsEnabled.
Note: This feature is only supported on Windows, Linux, macOS, and iOS.
| Name | Type | Default |
|---|---|---|
device | int | — |
floatGetJoyNamestring
public static string GetJoyName(int device);Returns the name of the joypad at the specified device index, e.g. PS4 Controller. Reckfell uses the SDL game controller database to determine gamepad names.
| Name | Type | Default |
|---|---|---|
device | int | — |
stringGetJoyNumTouchpadsint
public static int GetJoyNumTouchpads(int device);Returns the number of touchpads on the specified joypad, if it has any. Otherwise, the method returns 0.
Note: This feature is only supported on Windows, Linux, macOS, and iOS.
| Name | Type | Default |
|---|---|---|
device | int | — |
intGetJoyTouchpadFingerPositionVector2
public static Vector2 GetJoyTouchpadFingerPosition(int device, int finger, int touchpad = 0);Returns the position of the specified finger on the specified touchpad on the joypad. The X and Y values, if the specified finger is touching the specified touchpad, are in the range from 0.0 to 1.0, with (0.0, 0.0) representing the top-left corner of the touchpad and (1.0, 1.0) representing the bottom-right corner.
If the joypad doesn't have the specified touchpad or the specified finger is not currently touching the touchpad, this method returns Vector2(-1.0, -1.0).
Note: This feature is only supported on Windows, Linux, macOS, and iOS.
| Name | Type | Default |
|---|---|---|
device | int | — |
finger | int | — |
touchpad | int | 0 |
Vector2GetJoyTouchpadFingerPressurefloat
public static float GetJoyTouchpadFingerPressure(int device, int finger, int touchpad = 0);Returns the pressure of the specified finger on the specified touchpad on the joypad. The return value, if the specified finger is touching the specified touchpad, is in the range from 0.0 to 1.0.
If the joypad doesn't have the specified touchpad or the specified finger is not currently touching the touchpad, this method returns -1.0.
Note: This feature is only supported on Windows, Linux, macOS, and iOS.
| Name | Type | Default |
|---|---|---|
device | int | — |
finger | int | — |
touchpad | int | 0 |
floatGetJoyTouchpadFingersint[]
public static int[] GetJoyTouchpadFingers(int device, int touchpad = 0);Returns an array of finger IDs that are currently touching the specified touchpad on the joypad. If the joypad doesn't have the specified touchpad or no fingers are currently touching this touchpad, this method returns an empty array.
Note: To retrieve the positions of the touchpad fingers, use Input.GetJoyTouchpadFingerPosition.
Note: This feature is only supported on Windows, Linux, macOS, and iOS.
| Name | Type | Default |
|---|---|---|
device | int | — |
touchpad | int | 0 |
int[]GetJoyVibrationDurationfloat
public static float GetJoyVibrationDuration(int device);Returns the duration of the current vibration effect in seconds.
Note: This method returns the same value that was passed to Input.StartJoyVibration, and this value does not change when the joypad's vibration runs out, it only gets reset after a call to Input.StopJoyVibration.
If you want to check if a joypad is still vibrating, use Input.IsJoyVibrating instead.
| Name | Type | Default |
|---|---|---|
device | int | — |
floatGetJoyVibrationRemainingDurationfloat
public static float GetJoyVibrationRemainingDuration(int device);Returns the remaining duration of the current vibration effect in seconds.
| Name | Type | Default |
|---|---|---|
device | int | — |
floatGetJoyVibrationStrengthVector2
public static Vector2 GetJoyVibrationStrength(int device);Returns the strength of the joypad vibration: x is the strength of the weak motor, and y is the strength of the strong motor.
Note: This method returns the same values that were passed to Input.StartJoyVibration, and these values do not change when the joypad's vibration runs out, they only get reset after a call to Input.StopJoyVibration.
If you want to check if a joypad is still vibrating, use Input.IsJoyVibrating instead.
| Name | Type | Default |
|---|---|---|
device | int | — |
Vector2GetLastMouseScreenVelocityVector2
public static Vector2 GetLastMouseScreenVelocity();Returns the last mouse velocity in screen coordinates. To provide a precise and jitter-free velocity, mouse velocity is only calculated every 0.1s. Therefore, mouse velocity will lag mouse movements.
Vector2GetLastMouseVelocityVector2
public static Vector2 GetLastMouseVelocity();Returns the last mouse velocity. To provide a precise and jitter-free velocity, mouse velocity is only calculated every 0.1s. Therefore, mouse velocity will lag mouse movements.
Vector2GetMagnetometerVector3
public static Vector3 GetMagnetometer();Returns the magnetic field strength in micro-Tesla for all axes of the device's magnetometer sensor, if the device has one. Otherwise, the method returns Vector3.Zero.
Note: This method only works on Android and iOS. On other platforms, it always returns Vector3.Zero.
Note: For Android, ProjectSettings.input_devices/sensors/enable_magnetometer must be enabled.
Vector3GetMouseButtonMaskMouseButtonMask
public static MouseButtonMask GetMouseButtonMask();Returns mouse buttons as a bitmask. If multiple mouse buttons are pressed at the same time, the bits are added together. Equivalent to DisplayServer.MouseGetButtonState.
MouseButtonMaskGetMouseModeInput.MouseModeEnum
public static Input.MouseModeEnum GetMouseMode();Input.MouseModeEnumGetVectorVector2
public static Vector2 GetVector(StringName negativeX, StringName positiveX, StringName negativeY, StringName positiveY, float deadzone = -1f);Builds a vector from four raw action strengths, applies a circular deadzone, and limits length to one. Preserves analog magnitude; do not unconditionally normalize when partial speed is required.
| Name | Type | Default |
|---|---|---|
negativeX | StringName | — |
positiveX | StringName | — |
negativeY | StringName | — |
positiveY | StringName | — |
deadzone | float | -1f |
negativeXNegative-X action, such as left.
positiveXPositive-X action, such as right.
negativeYNegative-Y action, typically up in 2D.
positiveYPositive-Y action, typically down in 2D.
deadzoneCircular deadzone. A negative value uses the four action deadzones' average. For an explicit threshold, supply a validated finite value from 0 inclusive to 1 exclusive.
Vector2Vector of length 0–1. At deadzone 0.2, raw (0.3, 0.4) produced (0.225, 0.3); (1, 1) was limited to unit length. This is not two independently processed GetAxis calls.
HasJoyLightbool
public static bool HasJoyLight(int device);Checks the selected device's registered light capability. Check connection and other capabilities separately; an API does not guarantee the feature on every controller.
| Name | Type | Default |
|---|---|---|
device | int | — |
deviceCurrent device ID from GetConnectedJoypads, not a player number.
booltrue for registered support; false for missing capability or an unknown ID. The unknown-ID fallback was executed.
HasJoyMotionSensorsbool
public static bool HasJoyMotionSensors(int device);Checks the selected device's registered motion sensors capability. Check connection and other capabilities separately; an API does not guarantee the feature on every controller.
| Name | Type | Default |
|---|---|---|
device | int | — |
deviceCurrent device ID from GetConnectedJoypads, not a player number.
booltrue for registered support; false for missing capability or an unknown ID. The unknown-ID fallback was executed.
HasJoyVibrationbool
public static bool HasJoyVibration(int device);Checks the selected device's registered vibration capability. Check connection and other capabilities separately; an API does not guarantee the feature on every controller.
| Name | Type | Default |
|---|---|---|
device | int | — |
deviceCurrent device ID from GetConnectedJoypads, not a player number.
booltrue for registered support; false for missing capability or an unknown ID. The unknown-ID fallback was executed.
IsActionJustPressedbool
public static bool IsActionJustPressed(StringName action, bool exactMatch = false);Returns true in the frame or physics tick where an action begins being pressed. Multiple reads in one tick can return true; it is not an event queue. Handle an event in _UnhandledInput() when UI must be allowed to consume it before gameplay.
| Name | Type | Default |
|---|---|---|
action | StringName | — |
exactMatch | bool | false |
boolIsActionJustPressedByEventbool
public static bool IsActionJustPressedByEvent(StringName action, InputEvent @event, bool exactMatch = false);Returns true when the user has started pressing the action event in the current frame or physics tick, and the first event that triggered action press in the current frame/physics tick was event. It will only return true on the frame or tick that the user pressed down the button.
This is useful for code that needs to run only once when an action is pressed, and the action is processed during input handling (e.g. Entity._Input).
If exact_match is false, it ignores additional input modifiers for InputEventKey and InputEventMouseButton events, and the direction for InputEventJoypadMotion events.
Note: Returning true does not imply that the action is still pressed. An action can be pressed and released again rapidly, and true will still be returned so as not to miss input.
Note: Due to keyboard ghosting, Input.IsActionJustPressed may return false even if one of the action's keys is pressed. See Input examples in the documentation for more information.
| Name | Type | Default |
|---|---|---|
action | StringName | — |
event | InputEvent | — |
exactMatch | bool | false |
boolIsActionJustReleasedbool
public static bool IsActionJustReleased(StringName action, bool exactMatch = false);Returns true when the user stops pressing the action event in the current frame or physics tick. It will only return true on the frame or tick that the user releases the button.
Note: Returning true does not imply that the action is still not pressed. An action can be released and pressed again rapidly, and true will still be returned so as not to miss input.
If exact_match is false, it ignores additional input modifiers for InputEventKey and InputEventMouseButton events, and the direction for InputEventJoypadMotion events.
Note: During input handling (e.g. Entity._Input), use InputEvent.IsActionReleased instead to query the action state of the current event. See also Input.IsActionJustReleasedByEvent.
| Name | Type | Default |
|---|---|---|
action | StringName | — |
exactMatch | bool | false |
boolIsActionJustReleasedByEventbool
public static bool IsActionJustReleasedByEvent(StringName action, InputEvent @event, bool exactMatch = false);Returns true when the user stops pressing the action event in the current frame or physics tick, and the first event that triggered action release in the current frame/physics tick was event. It will only return true on the frame or tick that the user releases the button.
This is useful when an action is processed during input handling (e.g. Entity._Input).
Note: Returning true does not imply that the action is still not pressed. An action can be released and pressed again rapidly, and true will still be returned so as not to miss input.
If exact_match is false, it ignores additional input modifiers for InputEventKey and InputEventMouseButton events, and the direction for InputEventJoypadMotion events.
| Name | Type | Default |
|---|---|---|
action | StringName | — |
event | InputEvent | — |
exactMatch | bool | false |
boolIsActionPressedbool
public static bool IsActionPressed(StringName action, bool exactMatch = false);Reports whether an Input Map action is held. This polls state rather than handling one event and does not consume a press. For a single reaction, use IsActionJustPressed() or an event in _UnhandledInput(). A UI-consumed event does not automatically block this polling.
| Name | Type | Default |
|---|---|---|
action | StringName | — |
exactMatch | bool | false |
boolIsAnythingPressedbool
public static bool IsAnythingPressed();Returns true if any action, key, joypad button, or mouse button is being pressed. This will also return true if any action is simulated via code by calling Input.ActionPress.
boolIsEmulatingMouseFromTouchbool
public static bool IsEmulatingMouseFromTouch();boolIsEmulatingTouchFromMousebool
public static bool IsEmulatingTouchFromMouse();boolIsIgnoringJoypadOnUnfocusedApplicationbool
public static bool IsIgnoringJoypadOnUnfocusedApplication();boolIsJoyButtonPressedbool
public static bool IsJoyButtonPressed(int device, JoyButton button);Returns true if you are pressing the joypad button at index button.
Note: If you want to check if a joypad button was just pressed, use Reckfell's input action system with Input.IsActionJustPressed or use the Entity._Input method like this instead:
public override void _Input(InputEvent @event)
{
if (@event is InputEventJoypadButton eventButton && eventButton.Pressed && eventButton.ButtonIndex == JoyButton.A)
{
// Your code here.
}
}| Name | Type | Default |
|---|---|---|
device | int | — |
button | JoyButton | — |
boolIsJoyKnownbool
public static bool IsJoyKnown(int device);Returns true if the system knows the specified device. This means that it sets all button and axis indices. Unknown joypads are not expected to match these constants, but you can still retrieve events from them.
| Name | Type | Default |
|---|---|---|
device | int | — |
boolIsJoyMotionSensorsAutoCalibrationEnabledbool
public static bool IsJoyMotionSensorsAutoCalibrationEnabled(int device);Returns true if automatic calibration is enabled on the joypad's motion sensors. Automatic calibration is enabled by default. See also Input.SetJoyMotionSensorsAutoCalibrationEnabled.
Note: This feature is only supported on Windows, Linux, macOS, and iOS.
| Name | Type | Default |
|---|---|---|
device | int | — |
boolIsJoyMotionSensorsCalibratedbool
public static bool IsJoyMotionSensorsCalibrated(int device);Reads the completed/supplied calibration flag. This does not assess stillness quality: StopJoyMotionSensorsCalibration sets it when the procedure ends.
| Name | Type | Default |
|---|---|---|
device | int | — |
deviceDevice ID whose state is inspected.
boolCurrent flag value; false with no sensor data. Even true requires drift validation on a real device.
IsJoyMotionSensorsCalibratingbool
public static bool IsJoyMotionSensorsCalibrating(int device);Returns true if the joypad's motion sensors are currently being manually calibrated.
See Input.StartJoyMotionSensorsCalibration for an example on how to use joypad motion sensors and calibration in your games.
Note: This feature is only supported on Windows, Linux, macOS, and iOS.
| Name | Type | Default |
|---|---|---|
device | int | — |
boolIsJoyMotionSensorsEnabledbool
public static bool IsJoyMotionSensorsEnabled(int device);Returns true if the requested joypad has motion sensors (gyroscope and/or accelerometer) and they are currently enabled. See also Input.SetJoyMotionSensorsEnabled and Input.HasJoyMotionSensors.
See Input.StartJoyMotionSensorsCalibration for an example on how to use joypad motion sensors and calibration in your games.
Note: This feature is only supported on Windows, Linux, macOS, and iOS.
| Name | Type | Default |
|---|---|---|
device | int | — |
boolIsJoyVibratingbool
public static bool IsJoyVibrating(int device);Returns true if the joypad is still vibrating after a call to Input.StartJoyVibration.
Unlike Input.GetJoyVibrationStrength and Input.GetJoyVibrationDuration, this method returns false after the joypad's vibration runs out.
| Name | Type | Default |
|---|---|---|
device | int | — |
boolIsKeyLabelPressedbool
public static bool IsKeyLabelPressed(Key keycode);Returns true if you are pressing the key with the keycode printed on it. You can pass a Key constant or any Unicode character code.
Note: If you want to check if a key was just pressed by using its label, use Reckfell's input action system with Input.IsActionJustPressed or use the Entity._Input method like this instead:
public override void _Input(InputEvent @event)
{
if (@event is InputEventKey eventKey && !eventKey.IsEcho() && eventKey.Pressed && eventKey.KeyLabel == Key.Space)
{
// Your code here.
}
}| Name | Type | Default |
|---|---|---|
keycode | Key | — |
boolIsKeyPressedbool
public static bool IsKeyPressed(Key keycode);Returns true if you are pressing the Latin key in the current keyboard layout. You can pass a Key constant.
Input.IsKeyPressed is only recommended over Input.IsPhysicalKeyPressed in non-game applications. This ensures that shortcut keys behave as expected depending on the user's keyboard layout, as keyboard shortcuts are generally dependent on the keyboard layout in non-game applications. If in doubt, use Input.IsPhysicalKeyPressed.
Note: Due to keyboard ghosting, Input.IsKeyPressed may return false even if one of the action's keys is pressed. See Input examples in the documentation for more information.
Note: If you want to check if a key was just pressed by using its keycode, use Reckfell's input action system with Input.IsActionJustPressed or use the Entity._Input method like this instead:
public override void _Input(InputEvent @event)
{
if (@event is InputEventKey eventKey && !eventKey.IsEcho() && eventKey.Pressed && eventKey.Keycode == Key.Space)
{
// Your code here.
}
}| Name | Type | Default |
|---|---|---|
keycode | Key | — |
boolIsMouseButtonPressedbool
public static bool IsMouseButtonPressed(MouseButton button);Returns true if you are pressing the mouse button specified with MouseButton.
Note: If you want to check if a mouse button was just pressed, use Reckfell's input action system with Input.IsActionJustPressed or use the Entity._Input method like this instead:
public override void _Input(InputEvent @event)
{
if (@event is InputEventMouseButton eventMouseButton && eventMouseButton.Pressed && eventMouseButton.ButtonIndex == MouseButton.Left)
{
// Your code here.
}
}| Name | Type | Default |
|---|---|---|
button | MouseButton | — |
boolIsPhysicalKeyPressedbool
public static bool IsPhysicalKeyPressed(Key keycode);Returns true if you are pressing the key in the physical location on the 101/102-key US QWERTY keyboard. You can pass a Key constant.
Input.IsPhysicalKeyPressed is recommended over Input.IsKeyPressed for in-game actions, as it will make Input.IsPhysicalKeyPressed will also ensure that the top row number keys work on any keyboard layout. If in doubt, use Input.IsPhysicalKeyPressed.
Note: Due to keyboard ghosting, Input.IsPhysicalKeyPressed may return false even if one of the action's keys is pressed. See Input examples in the documentation for more information.
Note: If you want to check if a key was just pressed by using its physical keycode, use Reckfell's input action system with Input.IsActionJustPressed or use the Entity._Input method like this instead:
public override void _Input(InputEvent @event)
{
if (@event is InputEventKey eventKey && !eventKey.IsEcho() && eventKey.Pressed && eventKey.PhysicalKeycode == Key.Space)
{
// Your code here.
}
}| Name | Type | Default |
|---|---|---|
keycode | Key | — |
boolIsUsingAccumulatedInputbool
public static bool IsUsingAccumulatedInput();Reads the UseAccumulatedInput flag. Does not report whether the event queue is empty or measure physical input latency.
boolCurrent event-coalescing flag. false does not imply that all buffering is disabled.
ParseInputEventvoid
public static void ParseInputEvent(InputEvent @event);Feeds an InputEvent to the game. Can be used to artificially trigger input events from code. Also generates Entity._Input calls.
var cancelEvent = new InputEventAction();
cancelEvent.Action = "ui_cancel";
cancelEvent.Pressed = true;
Input.ParseInputEvent(cancelEvent);Note: Calling this function has no influence on the operating system. So for example sending an InputEventMouseMotion will not move the OS mouse cursor to the specified position (use Input.WarpMouse instead) and sending InputEventKey won't toggle between active windows.
| Name | Type | Default |
|---|---|---|
event | InputEvent | — |
RemoveJoyMappingvoid
public static void RemoveJoyMapping(string guid);Removes all mappings from the internal database that match the given GUID. All currently connected joypads that use this GUID will become unmapped. On Android, Reckfell will map to an internal fallback mapping.
| Name | Type | Default |
|---|---|---|
guid | string | — |
SetAccelerometervoid
public static void SetAccelerometer(Vector3 value);Sets the acceleration value of the accelerometer sensor. Can be used for debugging on devices without a hardware sensor, for example in an editor on a PC. Note: This value can be immediately overwritten by the hardware sensor value on Android and iOS.
| Name | Type | Default |
|---|---|---|
value | Vector3 | — |
SetCustomMouseCursorvoid
public static void SetCustomMouseCursor(Resource image, Input.CursorShape shape = Input.CursorShape.Arrow, Vector2? hotspot = default);Sets the selected system cursor slot's image. An empty resource resets the slot to its system appearance. Does not choose every Control's shape or make a hidden/captured cursor visible. Skips the call under Engine.IsEditorHint.
| Name | Type | Default |
|---|---|---|
image | Resource | — |
shape | Input.CursorShape | Input.CursorShape.Arrow |
hotspot | Vector2? | default |
imageImage or Texture2D supplying the image. Shared limit is 256×256; test targets separately. Use transparency and lossless import. Reset with an empty resource reference, not an empty Image.
shapeCursorShape slot, default Arrow. Replacing Ibeam does not change the Arrow image.
hotspotClick point within the image, default (0, 0). Use finite coordinates of an existing pixel; CursorTheme rejects negative and edge values.
SetDefaultCursorShapevoid
public static void SetDefaultCursorShape(Input.CursorShape shape = Input.CursorShape.Arrow);Sets the default cursor shape to be used in the viewport instead of Input.CursorShape.Arrow.
Note: If you want to change the default cursor shape for Control's nodes, use Control.MouseDefaultCursorShape instead.
Note: This method generates an InputEventMouseMotion to update cursor immediately.
| Name | Type | Default |
|---|---|---|
shape | Input.CursorShape | Input.CursorShape.Arrow |
SetDeviceOrientationvoid
public static void SetDeviceOrientation(Quaternion value);Sets the device orientation quaternion. Can be used for debugging on devices without a hardware sensor, for example in an editor on a PC. Note: This value can be immediately overwritten by the hardware sensor value on Android and iOS.
| Name | Type | Default |
|---|---|---|
value | Quaternion | — |
SetEmulateMouseFromTouchvoid
public static void SetEmulateMouseFromTouch(bool enable);| Name | Type | Default |
|---|---|---|
enable | bool | — |
SetEmulateTouchFromMousevoid
public static void SetEmulateTouchFromMouse(bool enable);| Name | Type | Default |
|---|---|---|
enable | bool | — |
SetGravityvoid
public static void SetGravity(Vector3 value);Sets the gravity value of the accelerometer sensor. Can be used for debugging on devices without a hardware sensor, for example in an editor on a PC. Note: This value can be immediately overwritten by the hardware sensor value on Android and iOS.
| Name | Type | Default |
|---|---|---|
value | Vector3 | — |
SetGyroscopevoid
public static void SetGyroscope(Vector3 value);Sets the value of the rotation rate of the gyroscope sensor. Can be used for debugging on devices without a hardware sensor, for example in an editor on a PC. Note: This value can be immediately overwritten by the hardware sensor value on Android and iOS.
| Name | Type | Default |
|---|---|---|
value | Vector3 | — |
SetIgnoreJoypadOnUnfocusedApplicationvoid
public static void SetIgnoreJoypadOnUnfocusedApplication(bool enable);| Name | Type | Default |
|---|---|---|
enable | bool | — |
SetJoyLightvoid
public static void SetJoyLight(int device, Color color);Sets the joypad's LED light, if available, to the specified color. See also Input.HasJoyLight.
Note: There is no way to get the color of the light from a joypad. If you need to know the assigned color, store it separately.
Note: This feature is only supported on Windows, Linux, macOS, and iOS.
| Name | Type | Default |
|---|---|---|
device | int | — |
color | Color | — |
SetJoyMotionSensorsAutoCalibrationEnabledvoid
public static void SetJoyMotionSensorsAutoCalibrationEnabled(int device, bool enable);Enables or disables automatic calibration of the joypad's gyroscope. Automatic calibration is enabled by default, so most games don't need to call this or perform any calibration. While enabled, the gyroscope calibration is continuously refined whenever the joypad is detected to be held still, easing corrections in gradually. This removes the need for a dedicated calibration step in most games and keeps up with calibration drift, e.g. from the controller warming up during play. When automatic calibration is disabled, the last calibrated values remain in effect. Note: This feature is only supported on Windows, Linux, macOS, and iOS.
| Name | Type | Default |
|---|---|---|
device | int | — |
enable | bool | — |
SetJoyMotionSensorsCalibrationvoid
public static void SetJoyMotionSensorsCalibration(int device, Reckfell.Collections.Dictionary calibrationInfo);Sets the specified joypad's calibration information. See also Input.GetJoyMotionSensorsCalibration.
See Input.StartJoyMotionSensorsCalibration for an example on how to use joypad motion sensors and calibration in your games.
Note: This feature is only supported on Windows, Linux, macOS, and iOS.
| Name | Type | Default |
|---|---|---|
device | int | — |
calibrationInfo | Reckfell.Collections.Dictionary | — |
SetJoyMotionSensorsEnabledvoid
public static void SetJoyMotionSensorsEnabled(int device, bool enable);Requests sensor enablement/disablement through the device interface. Does not create support for an unknown ID or automatically calibrate. Do not disable sensors still used by another system.
| Name | Type | Default |
|---|---|---|
device | int | — |
enable | bool | — |
deviceCurrent sensor-capable controller ID.
enabletrue to enable, false to disable. Check IsJoyMotionSensorsEnabled separately.
SetMagnetometervoid
public static void SetMagnetometer(Vector3 value);Sets the value of the magnetic field of the magnetometer sensor. Can be used for debugging on devices without a hardware sensor, for example in an editor on a PC. Note: This value can be immediately overwritten by the hardware sensor value on Android and iOS.
| Name | Type | Default |
|---|---|---|
value | Vector3 | — |
SetMouseModevoid
public static void SetMouseMode(Input.MouseModeEnum mode);| Name | Type | Default |
|---|---|---|
mode | Input.MouseModeEnum | — |
SetUseAccumulatedInputvoid
public static void SetUseAccumulatedInput(bool enable);Sets the same flag as UseAccumulatedInput. Disabling neither delivers events already queued nor guarantees immediate delivery when agile_event_flushing is separately enabled.
| Name | Type | Default |
|---|---|---|
enable | bool | — |
enabletrue coalesces compatible events; false does not coalesce new ones. Does not change the separate agile_event_flushing setting.
ShouldIgnoreDevicebool
public static bool ShouldIgnoreDevice(int vendorId, int productId);Queries whether an input device should be ignored or not. Devices can be ignored by setting the environment variable SDL_GAMECONTROLLER_IGNORE_DEVICES. See SDL documentation for more information.
Note: Some 3rd party tools can contribute to the list of ignored devices. For example, SteamInput creates virtual devices from physical devices for remapping purposes. To avoid handling the same input device twice, the original device is added to the ignore list.
| Name | Type | Default |
|---|---|---|
vendorId | int | — |
productId | int | — |
boolStartJoyMotionSensorsCalibrationvoid
public static void StartJoyMotionSensorsCalibration(int device);Starts the process of manually calibrating the specified joypad's gyroscope, if it has one.
Once a joypad's gyroscope has been calibrated correctly (e.g. laying still on a table without being rotated), Input.GetJoyGyroscope will return values close or equal to Vector3.Zero when the joypad is not being rotated.
Since the gyroscope is calibrated automatically by default (see Input.SetJoyMotionSensorsAutoCalibrationEnabled), most games don't need to calibrate manually. If automatic calibration is enabled, it's paused while the manual calibration is in progress, and resumes when Input.StopJoyMotionSensorsCalibration is called.
Here's an example of how to use joypad gyroscope and gyroscope calibration in your games:
private const float GyroSensitivity = 10.0;
public override void _Ready()
{
// In this example we only use the first connected joypad (id 0).
if (!Input.GetConnectedJoypads().Contains(0))
{
return;
}
if (!Input.HasJoyMotionSensors(0))
{
return;
}
// We must enable the accelerometer and the gyroscope before using them.
Input.SetJoyMotionSensorsEnabled(0, true);
// (Tell the users here that they need to put their joypads on a flat surface and wait for confirmation.)
// Start the calibration process.
CalibrateMotion();
}
public override void _Process(double delta)
{
// Only move the object if the joypad motion sensors are calibrated.
if (Input.IsJoyMotionSensorsCalibrated(0))
{
MoveObject(delta);
}
}
private async Task CalibrateMotion()
{
Input.StartJoyMotionSensorsCalibration(0);
// Wait for some time.
await ToSignal(GetTree().CreateTimer(1.0), EntityTreeTimer.SignalName.Timeout);
Input.StopJoyMotionSensorsCalibration(0);
// The joypad is now calibrated.
}
private void MoveObject(double delta)
{
Entity3D node = ... ; // Put your object here.
Vector3 gyro = Input.GetJoyGyroscope(0);
Vector3 rotation = node.Rotation;
rotation.X -= -gyro.Y * GyroSensitivity * (float)delta; // Use rotation around the Y axis (yaw) here.
rotation.Y += -gyro.X * GyroSensitivity * (float)delta; // Use rotation around the X axis (pitch) here.
node.Rotation = rotation;
}Note: Accelerometer sensor doesn't usually require calibration. Note: This feature is only supported on Windows, Linux, macOS, and iOS.
| Name | Type | Default |
|---|---|---|
device | int | — |
StartJoyVibrationvoid
public static void StartJoyVibration(int device, float weakMagnitude, float strongMagnitude, float duration = 0f);Records a vibration request for the device, not an acknowledgement that motors moved. Check connection, HasJoyVibration, and finite numeric values first. Submit once per event rather than every frame.
| Name | Type | Default |
|---|---|---|
device | int | — |
weakMagnitude | float | — |
strongMagnitude | float | — |
duration | float | 0f |
deviceSelected connected controller ID.
weakMagnitudeWeak-motor intensity 0–1. The tutorial wrapper additionally rejects NaN and infinity.
strongMagnitudeStrong-motor intensity 0–1; a separate channel, not duration.
durationDuration in seconds. Supply a positive finite value. Default 0 does not guarantee infinite operation: the current SDL backend converts it to 65,535 ms.
StopJoyMotionSensorsCalibrationvoid
public static void StopJoyMotionSensorsCalibration(int device);Stops the manual calibration process of the specified joypad's motion sensors.
See Input.StartJoyMotionSensorsCalibration for an example on how to use joypad motion sensors and calibration in your games.
Note: This feature is only supported on Windows, Linux, macOS, and iOS.
| Name | Type | Default |
|---|---|---|
device | int | — |
StopJoyVibrationvoid
public static void StopJoyVibration(int device);Records zero intensities to stop the selected device's vibration. Does not acknowledge physical receipt by hardware.
| Name | Type | Default |
|---|---|---|
device | int | — |
deviceDevice ID receiving the stop request.
VibrateHandheld2 overloads
public static void VibrateHandheld(int durationMs);Starts vibrating the handheld device for the specified duration in milliseconds.
amplitude is the strength of the vibration, as a value between 0.0 and 1.0. If set to -1.0, the default vibration strength of the device is used.
Note: This method is implemented on Android, iOS, and Web. It has no effect on other platforms.
Note: For Android, Input.VibrateHandheld requires enabling the VIBRATE permission in the export preset. Otherwise, Input.VibrateHandheld will have no effect.
Note: For iOS, specifying the duration is only supported in iOS 13 and later.
Note: For Web, the amplitude cannot be changed.
Note: Some web browsers such as Safari and Firefox for Android do not support Input.VibrateHandheld.
Note: Device settings such as vibration on/off, "do not disturb" mode or specific haptic feedback on/off may prevent Input.VibrateHandheld effects.
| Name | Type | Default |
|---|---|---|
durationMs | int | — |
public static void VibrateHandheld(int durationMs = 500, float amplitude = -1f);Starts vibrating the handheld device for the specified duration in milliseconds.
amplitude is the strength of the vibration, as a value between 0.0 and 1.0. If set to -1.0, the default vibration strength of the device is used.
Note: This method is implemented on Android, iOS, and Web. It has no effect on other platforms.
Note: For Android, Input.VibrateHandheld requires enabling the VIBRATE permission in the export preset. Otherwise, Input.VibrateHandheld will have no effect.
Note: For iOS, specifying the duration is only supported in iOS 13 and later.
Note: For Web, the amplitude cannot be changed.
Note: Some web browsers such as Safari and Firefox for Android do not support Input.VibrateHandheld.
Note: Device settings such as vibration on/off, "do not disturb" mode or specific haptic feedback on/off may prevent Input.VibrateHandheld effects.
| Name | Type | Default |
|---|---|---|
durationMs | int | 500 |
amplitude | float | -1f |
WarpMousevoid
public static void WarpMouse(Vector2 position);Sets the mouse position to the specified vector, provided in pixels and relative to an origin at the upper left corner of the currently focused Window Manager game window.
Mouse position is clipped to the limits of the screen resolution, or to the limits of the game window if Input.MouseModeEnum is set to Input.MouseModeEnum.Confined or Input.MouseModeEnum.ConfinedHidden.
Note: Input.WarpMouse is only supported on Windows, macOS and Linux. It has no effect on Android, iOS and Web.
| Name | Type | Default |
|---|---|---|
position | Vector2 | — |
Signals and events1
JoyConnectionChangedEvent
public static event Input.JoyConnectionChangedEventHandler JoyConnectionChanged;Emitted when a joypad device has been connected or disconnected.
| Name | Type | Default |
|---|---|---|
device | long | — |
connected | bool | — |
Input.CursorShape
| Value | Description |
|---|---|
Arrow = 0 | Arrow cursor. Standard, default pointing cursor. |
Bdiagsize = 11 | Window resize mouse cursor. The cursor is a double-headed arrow that goes from the bottom left to the top right. It tells the user they can resize the window or the panel both horizontally and vertically. |
Busy = 5 | Busy cursor. Indicates that the application is busy performing an operation, and that it is still usable during the operation. |
CanDrop = 7 | Can drop cursor. Usually displayed when dragging something to indicate that it can be dropped at the current position. |
Cross = 3 | Cross cursor. Typically appears over regions in which a drawing operation can be performed or for selections. |
Drag = 6 | Drag cursor. Usually displayed when dragging something.
Note: Windows lacks a dragging cursor, so |
Fdiagsize = 12 | Window resize mouse cursor. The cursor is a double-headed arrow that goes from the top left to the bottom right, the opposite of |
Forbidden = 8 | Forbidden cursor. Indicates that the current action is forbidden (for example, when dragging something) or that the control at a position is disabled. |
Help = 16 | Help cursor. Usually a question mark. |
Hsize = 10 | Horizontal resize mouse cursor. A double-headed horizontal arrow. It tells the user they can resize the window or the panel horizontally. |
Hsplit = 15 | Horizontal split mouse cursor. On Windows, it's the same as |
Ibeam = 1 | I-beam cursor. Usually used to show where the text cursor will appear when the mouse is clicked. |
Move = 13 | Move cursor. Indicates that something can be moved. |
PointingHand = 2 | Pointing hand cursor. Usually used to indicate the pointer is over a link or other interactable item. |
Vsize = 9 | Vertical resize mouse cursor. A double-headed vertical arrow. It tells the user they can resize the window or the panel vertically. |
Vsplit = 14 | Vertical split mouse cursor. On Windows, it's the same as |
Wait = 4 | Wait cursor. Indicates that the application is busy performing an operation, and that it cannot be used during the operation (e.g. something is blocking its main thread). |
Input.MouseModeEnum
| Value | Description |
|---|---|
Captured = 2 | Captures the mouse. The mouse will be hidden and its position locked at the center of the window manager's window.
Note: If you want to process the mouse's movement in this mode, you need to use |
Confined = 3 | Confines the mouse cursor to the game window, and make it visible. |
Max = 5 | Max value of the |
Visible = 0 | Makes the mouse cursor visible if it is hidden. |