Struct gdnative_bindings_lily::InputDefault [−][src]
pub struct InputDefault { /* fields omitted */ }
Expand description
core class InputDefault
inherits Input
(unsafe).
Official documentation
See the documentation of this class in the Godot engine’s official documentation. The method descriptions are generated from it and typically contain code samples in GDScript, not Rust.
Class hierarchy
InputDefault inherits methods from:
Safety
All types in the Godot API have “interior mutability” in Rust parlance.
To enforce that the official thread-safety guidelines are
followed, the typestate pattern is used in the Ref
and TRef
smart pointers,
and the Instance
API. The typestate Access
in these types tracks whether the
access is unique, shared, or exclusive to the current thread. For more information,
see the type-level documentation on Ref
.
Methods from Deref<Target = Input>
This will simulate pressing the specified action.
The strength can be used for non-boolean actions, it’s ranged between 0 and 1 representing the intensity of the given action.
Note: This method will not cause any [method Node._input] calls. It is intended to be used with [method is_action_pressed] and [method is_action_just_pressed]. If you want to simulate _input
, use [method parse_input_event] instead.
Default Arguments
strength
-1.0
If the specified action is already pressed, this will release it.
Adds a new mapping entry (in SDL2 format) to the mapping database. Optionally update already connected devices.
Default Arguments
update_existing
-false
Returns the acceleration of the device’s accelerometer, if the device has one. Otherwise, the method returns [constant 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 iOS, Android, and UWP. On other platforms, it always returns [constant Vector3.ZERO].
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 as the keyboard, the value returned will be 0 or 1.
Returns an [Array] containing the device IDs of all currently connected joypads.
Returns the currently assigned cursor shape (see [enum CursorShape]).
Returns the gravity of the device’s accelerometer, if the device has one. Otherwise, the method returns [constant Vector3.ZERO]. Note: This method only works on Android and iOS. On other platforms, it always returns [constant Vector3.ZERO].
Returns the rotation rate in rad/s around a device’s X, Y, and Z axes of the gyroscope, if the device has one. Otherwise, the method returns [constant Vector3.ZERO]. Note: This method only works on Android. On other platforms, it always returns [constant Vector3.ZERO].
Returns the current value of the joypad axis at given index (see [enum JoystickList]).
Returns the index of the provided axis name.
Receives a [enum JoystickList] axis and returns its equivalent name as a string.
Returns the index of the provided button name.
Receives a gamepad button from [enum JoystickList] and returns its equivalent name as a string.
Returns a SDL2-compatible device GUID on platforms that use gamepad remapping. Returns "Default Gamepad"
otherwise.
Returns the name of the joypad at the specified device index.
Returns the duration of the current vibration effect in seconds.
Returns the strength of the joypad vibration: x is the strength of the weak motor, and y is the strength of the strong motor.
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.
Returns the the magnetic field strength in micro-Tesla for all axes of the device’s magnetometer, if the device has one. Otherwise, the method returns [constant Vector3.ZERO]. Note: This method only works on Android and UWP. On other platforms, it always returns [constant Vector3.ZERO].
Returns mouse buttons as a bitmask. If multiple mouse buttons are pressed at the same time, the bits are added together.
Returns the mouse mode. See the constants for more information.
Returns true
when the user starts pressing the action event, meaning it’s true
only on the frame that the user pressed down the button.
This is useful for code that needs to run only once when an action is pressed, instead of every frame while it’s pressed.
Returns true
when the user stops pressing the action event, meaning it’s true
only on the frame that the user released the button.
Returns true
if you are pressing the action event. Note that if an action has multiple buttons assigned and more than one of them is pressed, releasing one button will release the action, even if some other button assigned to this action is still pressed.
Returns true
if you are pressing the joypad button (see [enum JoystickList]).
Returns true
if the system knows the specified device. This means that it sets all button and axis indices exactly as defined in [enum JoystickList]. Unknown joypads are not expected to match these constants, but you can still retrieve events from them.
Returns true
if you are pressing the key. You can pass a [enum KeyList] constant.
Returns true
if you are pressing the mouse button specified with [enum ButtonList].
pub fn joy_connection_changed(
&self,
device: i64,
connected: bool,
name: impl Into<GodotString>,
guid: impl Into<GodotString>
)
pub fn joy_connection_changed(
&self,
device: i64,
connected: bool,
name: impl Into<GodotString>,
guid: impl Into<GodotString>
)
Notifies the Input singleton that a connection has changed, to update the state for the device
index.
This is used internally and should not have to be called from user scripts. See [signal joy_connection_changed] for the signal emitted when this is triggered internally.
Sample code is GDScript unless otherwise noted.
Feeds an InputEvent to the game. Can be used to artificially trigger input events from code. Also generates [method Node._input] calls. Example:
var a = InputEventAction.new()
a.action = "ui_cancel"
a.pressed = true
Input.parse_input_event(a)
Removes all mappings from the internal database that match the given GUID.
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 [enum CursorShape] for the list of shapes.
image
’s size must be lower than 256×256.
hotspot
must be within image
’s size.
Note: AnimatedTextures aren’t supported as custom mouse cursors. If using an AnimatedTexture, only the first frame will be displayed.
Note: Only images imported with the Lossless, Lossy or Uncompressed compression modes are supported. The Video RAM compression mode can’t be used for custom cursors.
Default Arguments
shape
-0
hotspot
-Vector2( 0, 0 )
Sets the default cursor shape to be used in the viewport instead of [constant CURSOR_ARROW]. Note: If you want to change the default cursor shape for Control’s nodes, use [member Control.mouse_default_cursor_shape] instead. Note: This method generates an InputEventMouseMotion to update cursor immediately.
Default Arguments
shape
-0
Sets the mouse mode. See the constants for more information.
Enables or disables the accumulation of similar input events sent by the operating system. 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. Input accumulation is enabled by default. It can be disabled to get slightly more precise/reactive input at the cost of increased CPU usage. In applications where drawing freehand lines is required, input accumulation should generally be disabled while the user is drawing the line to get results that closely follow the actual input.
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).
Note: Not every hardware is compatible with long effect durations; it is recommended to restart an effect if it has to be played for more than a few seconds.
Default Arguments
duration
-0
Stops the vibration of the joypad.
Vibrate Android and iOS devices. Note: It needs VIBRATE permission for Android at export settings. iOS does not support duration.
Default Arguments
duration_ms
-500
Sets the mouse position to the specified vector.
Trait Implementations
type RefKind = ManuallyManaged
type RefKind = ManuallyManaged
Creates an explicitly null reference of Self
as a method argument. This makes type
inference easier for the compiler compared to Option
. Read more
Creates a new instance of Self
using a zero-argument constructor, as a Unique
reference. Read more
Performs a dynamic reference downcast to target type. Read more
Performs a static reference upcast to a supertype that is guaranteed to be valid. Read more
Creates a persistent reference to the same Godot object with shared thread access. Read more
unsafe fn assume_thread_local(&self) -> Ref<Self, ThreadLocal> where
Self: GodotObject<RefKind = RefCounted>,
unsafe fn assume_thread_local(&self) -> Ref<Self, ThreadLocal> where
Self: GodotObject<RefKind = RefCounted>,
Creates a persistent reference to the same Godot object with thread-local thread access. Read more
Creates a persistent reference to the same Godot object with unique access. Read more
Recovers a instance ID previously returned by Object::get_instance_id
if the object is
still alive. See also TRef::try_from_instance_id
. Read more
Auto Trait Implementations
impl RefUnwindSafe for InputDefault
impl !Send for InputDefault
impl !Sync for InputDefault
impl Unpin for InputDefault
impl UnwindSafe for InputDefault