MouseMode
Input.swift:35enum MouseModeenum MouseModeimport SwiftGodotFramework to write Godot Game Extensions using the Swift Programming Language.
class InputA singleton for handling inputs.
case visibleMakes the mouse cursor visible if it is hidden.
case hiddenMakes the mouse cursor hidden if it is visible.
case capturedCaptures the mouse. The mouse will be hidden and its position locked at the center of the window manager’s window.
case confinedConfines the mouse cursor to the game window, and make it visible.
case confinedHiddenConfines the mouse cursor to the game window, and make it hidden.
static var emulateMouseFromTouch: Bool { get set }If true, sends mouse input events when tapping or swiping on the touchscreen. See also ProjectSettings/inputDevices/pointing/emulateMouseFromTouch.
static var emulateTouchFromMouse: Bool { get set }If true, sends touch input events when clicking or dragging the mouse. See also ProjectSettings/inputDevices/pointing/emulateTouchFromMouse.
static var mouseMode: Input.MouseMode { get set }Controls the mouse mode. See MouseMode for more information.
static var shared: InputThe shared instance of this class
static var useAccumulatedInput: Bool { get set }If true, similar input events sent by the operating system are accumulated. When input accumulation is enabled, all input events generated during a frame will be merged and emitted when the frame is done rendering. Therefore, this limits the number of input method calls per second to the rendering FPS.
static func actionPress(action: StringName, strength: Double = 1.0) This will simulate pressing the specified action.
static func actionRelease(action: StringName) If the specified action is already pressed, this will release it.
static func addJoyMapping(_ mapping: String, updateExisting: Bool = false) Adds a new mapping entry (in SDL2 format) to the mapping database. Optionally update already connected devices.
static func flushBufferedEvents() Sends all input events which are in the current buffer to the game loop. These events may have been buffered as a result of accumulated input (useAccumulatedInput) or agile input flushing (ProjectSettings/inputDevices/buffering/agileEventFlushing).
static func getAccelerometer() -> Vector3 Returns the acceleration in m/s² of the device’s accelerometer sensor, if the device has one. Otherwise, the method returns Vector3.ZERO.
static func getActionRawStrength(action: StringName, exactMatch: Bool = false) -> Double Returns a value between 0 and 1 representing the raw intensity of the given action, ignoring the action’s deadzone. In most cases, you should use getActionStrength(action:exactMatch:) instead.
static func getActionStrength(action: StringName, exactMatch: Bool = false) -> Double Returns a value between 0 and 1 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. If the action is mapped to a control that has no axis such as the keyboard, the value returned will be 0 or 1.
static func getAxis(negativeAction: StringName, positiveAction: StringName) -> Double Get axis input by specifying two actions, one negative and one positive.
static func getConnectedJoypads() -> VariantCollection<Int64> Returns an GArray containing the device IDs of all currently connected joypads.
static func getCurrentCursorShape() -> Input.CursorShape Returns the currently assigned cursor shape (see CursorShape).
static func getGravity() -> Vector3 Returns the gravity in m/s² of the device’s accelerometer sensor, if the device has one. Otherwise, the method returns Vector3.ZERO.
static func getGyroscope() -> Vector3 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.
static func getJoyAxis(device: Int32, axis: JoyAxis) -> Double Returns the current value of the joypad axis at given index (see JoyAxis).
static func getJoyGuid(device: Int32) -> String Returns an SDL2-compatible device GUID on platforms that use gamepad remapping, e.g. 030000004c050000c405000000010000. Returns "Default Gamepad" otherwise. Godot uses the SDL2 game controller database to determine gamepad names and mappings based on this GUID.
static func getJoyInfo(device: Int32) -> GDictionary 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.
static func getJoyName(device: Int32) -> String Returns the name of the joypad at the specified device index, e.g. PS4 Controller. Godot uses the SDL2 game controller database to determine gamepad names.
static func getJoyVibrationDuration(device: Int32) -> Double Returns the duration of the current vibration effect in seconds.
static func getJoyVibrationStrength(device: Int32) -> Vector2 Returns the strength of the joypad vibration: x is the strength of the weak motor, and y is the strength of the strong motor.
static func getLastMouseScreenVelocity() -> Vector2 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.
static func getLastMouseVelocity() -> Vector2 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.
static func getMagnetometer() -> Vector3 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.
static func getMouseButtonMask() -> MouseButtonMask Returns mouse buttons as a bitmask. If multiple mouse buttons are pressed at the same time, the bits are added together. Equivalent to mouseGetButtonState.
static func getVector(negativeX: StringName, positiveX: StringName, negativeY: StringName, positiveY: StringName, deadzone: Double = -1.0) -> Vector2 Gets an input vector by specifying four actions for the positive and negative X and Y axes.
static func isActionJustPressed(action: StringName, exactMatch: Bool = false) -> Bool Returns true when the user has started pressing the action event in the current frame or physics tick. It will only return true on the frame or tick that the user pressed down the button.
static func isActionJustReleased(action: StringName, exactMatch: Bool = false) -> Bool 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.
static func isActionPressed(action: StringName, exactMatch: Bool = false) -> Bool Returns true if you are pressing the action event.
static func isAnythingPressed() -> Bool 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 actionPress(action:strength:).
static func isJoyButtonPressed(device: Int32, button: JoyButton) -> Bool Returns true if you are pressing the joypad button (see JoyButton).
static func isJoyKnown(device: Int32) -> Bool 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.
static func isKeyLabelPressed(keycode: Key) -> Bool 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.
static func isKeyPressed(keycode: Key) -> Bool Returns true if you are pressing the Latin key in the current keyboard layout. You can pass a Key constant.
static func isMouseButtonPressed(button: MouseButton) -> Bool Returns true if you are pressing the mouse button specified with MouseButton.
static func isPhysicalKeyPressed(keycode: Key) -> Bool 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.
static func parseInputEvent(_ event: InputEvent?) Feeds an InputEvent to the game. Can be used to artificially trigger input events from code. Also generates _input(event:) calls.
static func removeJoyMapping(guid: String) Removes all mappings from the internal database that match the given GUID.
static func setAccelerometer(value: Vector3) 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.
static func setCustomMouseCursor(image: Resource?, shape: Input.CursorShape = .arrow, hotspot: Vector2 = Vector2 (x: 0, y: 0)) Sets a custom mouse cursor image, which is only visible inside the game window. The hotspot can also be specified. Passing null to the image parameter resets to the system cursor. See CursorShape for the list of shapes.
static func setDefaultCursorShape(_ shape: Input.CursorShape = .arrow) Sets the default cursor shape to be used in the viewport instead of .cursorArrow.
static func setGravity(value: Vector3) 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.
static func setGyroscope(value: Vector3) 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.
static func setMagnetometer(value: Vector3) 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.
static func shouldIgnoreDevice(vendorId: Int32, productId: Int32) -> Bool Queries whether an input device should be ignored or not. Devices can be ignored by setting the environment variable SDL_GAMECONTROLLER_IGNORE_DEVICES. Read the SDL documentation for more information.
static func startJoyVibration(device: Int32, weakMagnitude: Double, strongMagnitude: Double, duration: Double = 0) Starts to vibrate the joypad. Joypads usually come with two rumble motors, a strong and a weak one. weakMagnitude is the strength of the weak motor (between 0 and 1) and strongMagnitude 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). The vibration can be stopped early by calling stopJoyVibration(device:).
static func stopJoyVibration(device: Int32) Stops the vibration of the joypad started with startJoyVibration(device:weakMagnitude:strongMagnitude:duration:).
static func vibrateHandheld(durationMs: Int32 = 500, amplitude: Double = -1.0) Vibrate the handheld device for the specified duration in milliseconds.
static func warpMouse(position: Vector2) 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.
override class var godotClassName: StringName { get }var joyConnectionChanged: Signal1 { get }Emitted when a joypad device has been connected or disconnected.
enum CursorShapeclass Signal1Signal support.
protocol CaseIterableA type that provides a collection of all of its values.
protocol CustomDebugStringConvertibleA type with a customized textual representation suitable for debugging purposes.
protocol EquatableA type that can be compared for value equality.
protocol Hashable : EquatableA type that can be hashed into a Hasher to produce an integer hash value.
protocol RawRepresentable<RawValue>A type that can be converted to and from an associated raw value.
init?(rawValue: Int64) var debugDescription: String { get }A textual representation of this instance, suitable for debugging
var hashValue: Int { get }static func != (lhs: Self, rhs: Self) -> Bool Returns a Boolean value indicating whether two values are not equal.
func hash(into hasher: inout Hasher)