public static class Input
A Singleton that deals with inputs. This includes key presses, mouse buttons and movement, joypads, and input actions. Actions and their events can be set in the Project Settings / Input Map tab. Or be set with InputMap.
public static void ActionPress(string action)
public static void ActionRelease(string action)
public static void AddJoyMapping(string mapping, bool updateExisting = false)
public static Vector3 GetAccelerometer()
If the device has an accelerometer, this will return the acceleration. Otherwise, it returns an empty Vector3.
public static Array GetConnectedJoypads()
Returns an Array containing the device IDs of all currently connected joypads.
public static Vector3 GetGravity()
If the device has an accelerometer, this will return the gravity. Otherwise, it returns an empty Vector3.
public static Vector3 GetGyroscope()
If the device has a gyroscope, this will return the rate of rotation in rad/s around a device’s x, y, and z axis. Otherwise, it returns an empty Vector3.
public static float GetJoyAxis(int device, int axis)
public static int GetJoyAxisIndexFromString(string axis)
public static string GetJoyAxisString(int axisIndex)
public static int GetJoyButtonIndexFromString(string button)
public static string GetJoyButtonString(int buttonIndex)
public static string GetJoyGuid(int device)
public static string GetJoyName(int device)
public static float GetJoyVibrationDuration(int device)
public static Vector2 GetJoyVibrationStrength(int device)
public static Vector2 GetLastMouseSpeed()
Returns the mouse speed for the last time the cursor was moved, and this until the next frame where the mouse moves. This means that even if the mouse is not moving, this function will still return the value of the last motion.
public static Vector3 GetMagnetometer()
public static int GetMouseButtonMask()
public static MouseMode GetMouseMode()
public static bool IsActionJustPressed(string action)
truewhen the user starts pressing the action event, meaning it’s true only on the frame that the user pressed down the button.
public static bool IsActionJustReleased(string action)
public static bool IsActionPressed(string action)
public static bool IsJoyButtonPressed(int device, int button)
public static bool IsJoyKnown(int device)
trueif the system knows the specified device. This means that it sets all button and axis indices exactly as defined in the
JOY_*constants (see [@GlobalScope]). Unknown joypads are not expected to match these constants, but you can still retrieve events from them.
public static bool IsKeyPressed(int scancode)
public static bool IsMouseButtonPressed(int button)
public static void JoyConnectionChanged(int device, bool connected, string name, string guid)
public static void ParseInputEvent(InputEvent @event)
Feeds an InputEvent to the game. Can be used to artificially trigger input events from code.
public static void RemoveJoyMapping(string guid)
public static void SetCustomMouseCursor(Resource image, CursorShape shape = CursorShape.Arrow, Vector2? hotspot = default(Vector2?))
public static void SetMouseMode(MouseMode mode)
public static void StartJoyVibration(int device, float weakMagnitude, float strongMagnitude, float duration = 0f)
Starts to vibrate the joypad. Joypads usually come with two rumble motors, a strong and a weak one. weak_magnitude is the strength of the weak motor (between 0 and 1) and strong_magnitude is the strength of the strong motor (between 0 and 1). duration is the duration of the effect in seconds (a duration of 0 will try to play the vibration indefinitely).
public static void StopJoyVibration(int device)
public static void WarpMousePosition(Vector2 to)
"joy_connection_changed" (int index, bool connected)
|Arrow||0||Arrow cursor. Standard, default pointing cursor.|
|Ibeam||1||I-beam cursor. Usually used to show where the text cursor will appear when the mouse is clicked.|
|PointingHand||2||Pointing hand cursor. Usually used to indicate the pointer is over a link or other interactable item.|
|Cross||3||Cross cursor. Typically appears over regions in which a drawing operation can be performance or for selections.|
|Wait||4||Wait cursor. Indicates that the application is busy performing an operation.|
|Busy||5||Busy cursor. See [code]CURSOR_WAIT[/code].|
|Drag||6||Drag cursor. Usually displayed when dragging something.|
|CanDrop||7||Can drop cursor. Usually displayed when dragging something to indicate that it can be dropped at the current position.|
|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.|
|Vsize||9||Vertical resize mouse cursor. A double headed vertical arrow. It tells the user they can resize the window or the panel vertically.|
|Hsize||10||Horizontal resize mouse cursor. A double headed horizontal arrow. It tells the user they can resize the window or the panel horizontally.|
|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.|
|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 [code]CURSOR_BDIAGSIZE[/code]. It tells the user they can resize the window or the panel both horizontally and vertically.|
|Move||13||Move cursor. Indicates that something can be moved.|
|Vsplit||14||Vertical split mouse cursor. On Windows, it’s the same as [code]CURSOR_VSIZE[/code].|
|Hsplit||15||Horizontal split mouse cursor. On Windows, it’s the same as [code]CURSOR_HSIZE[/code].|
|Help||16||Help cursor. Usually a question mark.|
|Visible||0||Makes the mouse cursor visible if it is hidden.|
|Hidden||1||Makes the mouse cursor hidden if it is visible.|
|Captured||2||Captures the mouse. The mouse will be hidden and unable to leave the game window. But it will still register movement and mouse button presses.|
|Confined||3||Makes the mouse cursor visible but confines it to the game window.|