Signal1
Signal support.
Input.swift:1704class Signal1
Use the connect(flags:_:)
method to connect to the signal on the container object, and disconnect(_:)
to drop the connection.
You can also await the emitted
property for waiting for a single emission of the signal.
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (55) members.
Types
Type members
static var emulateMouseFromTouch: Bool
If
true
, sends mouse input events when tapping or swiping on the touchscreen. See alsoProjectSettings/inputDevices/pointing/emulateMouseFromTouch
.static var emulateTouchFromMouse: Bool
If
true
, sends touch input events when clicking or dragging the mouse. See alsoProjectSettings/inputDevices/pointing/emulateTouchFromMouse
.static var mouseMode: Input.MouseMode
Controls the mouse mode. See
MouseMode
for more information.static var useAccumulatedInput: Bool
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
) 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(String, updateExisting: Bool
) 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
) -> 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
) -> 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
) -> 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
) -> Bool Returns
true
when the user has started pressing the action event in the current frame or physics tick. It will only returntrue
on the frame or tick that the user pressed down the button.static func isActionJustReleased(action: StringName, exactMatch: Bool
) -> Bool Returns
true
when the user stops pressing the action event in the current frame or physics tick. It will only returntrue
on the frame or tick that the user releases the button.static func isActionPressed(action: StringName, exactMatch: Bool
) -> 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 returntrue
if any action is simulated via code by callingactionPress(action:strength:)
.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 thekeycode
printed on it. You can pass aKey
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 aKey
constant.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 aKey
constant.static func parseInputEvent(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, hotspot: Vector2
) 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. SeeCursorShape
for the list of shapes.static func setDefaultCursorShape(Input.CursorShape
) 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
) 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) andstrongMagnitude
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 callingstopJoyVibration(device:)
.static func stopJoyVibration(device: Int32
) Stops the vibration of the joypad started with
startJoyVibration(device:weakMagnitude:strongMagnitude:duration:)
.static func vibrateHandheld(durationMs: Int32, amplitude: Double
) 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.
class var godotClassName: StringName
Instance members
var joyConnectionChanged: Signal1
Emitted when a joypad device has been connected or disconnected.
Citizens in SwiftGodot
Instance members
var emitted: Void
You can await this property to wait for the signal to be emitted once
func connect(flags: Object.ConnectFlags, @escaping (_ device: Int64, _ connected: Bool) -> ()
) -> Object Connects the signal to the specified callback
func disconnect(Object
) Disconnects a signal that was previously connected, the return value from calling
connect(flags:_:)