feat: updated engine
This commit is contained in:
parent
cbe99774ff
commit
f4cf6b3999
6607 changed files with 910135 additions and 430025 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="Input" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<class name="Input" inherits="Object" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A singleton for handling inputs.
|
||||
</brief_description>
|
||||
|
|
@ -18,8 +18,8 @@
|
|||
<param index="0" name="action" type="StringName" />
|
||||
<param index="1" name="strength" type="float" default="1.0" />
|
||||
<description>
|
||||
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.
|
||||
Simulates pressing the specified input action.
|
||||
The [param strength] can be used for non-boolean actions, it's ranged between [code]0.0[/code] and [code]1.0[/code] representing the intensity of the given action.
|
||||
[b]Note:[/b] 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 [code]_input[/code], use [method parse_input_event] instead.
|
||||
</description>
|
||||
</method>
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
<return type="void" />
|
||||
<param index="0" name="action" type="StringName" />
|
||||
<description>
|
||||
If the specified action is already pressed, this will release it.
|
||||
Releases the specified input action, if the action is currently pressed.
|
||||
</description>
|
||||
</method>
|
||||
<method name="add_joy_mapping">
|
||||
|
|
@ -35,13 +35,23 @@
|
|||
<param index="0" name="mapping" type="String" />
|
||||
<param index="1" name="update_existing" type="bool" default="false" />
|
||||
<description>
|
||||
Adds a new mapping entry (in SDL2 format) to the mapping database. Optionally update already connected devices.
|
||||
Adds a new joypad mapping entry (in SDL format) to the mapping database, and optionally updates the already connected devices.
|
||||
[b]Note:[/b] See [url=https://wiki.libsdl.org/SDL3/SDL_AddGamepadMapping#remarks]SDL documentation[/url] for more information about the SDL controller mapping format.
|
||||
</description>
|
||||
</method>
|
||||
<method name="clear_joy_motion_sensors_calibration" experimental="">
|
||||
<return type="void" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Clears the calibration information for the specified joypad's motion sensors, if it has any and if they were calibrated.
|
||||
See [method start_joy_motion_sensors_calibration] for an example on how to use joypad motion sensors and calibration in your games.
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="flush_buffered_events">
|
||||
<return type="void" />
|
||||
<description>
|
||||
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 ([member use_accumulated_input]) or agile input flushing ([member ProjectSettings.input_devices/buffering/agile_event_flushing]).
|
||||
Sends all buffered input events to the game loop. These events may have been buffered as a result of accumulated input ([member use_accumulated_input]) or agile input flushing ([member ProjectSettings.input_devices/buffering/agile_event_flushing]).
|
||||
The engine will already do this itself at key execution points (at least once per frame). However, this can be useful in advanced cases where you want precise control over the timing of event handling.
|
||||
</description>
|
||||
</method>
|
||||
|
|
@ -59,7 +69,7 @@
|
|||
<param index="0" name="action" type="StringName" />
|
||||
<param index="1" name="exact_match" type="bool" default="false" />
|
||||
<description>
|
||||
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 [method get_action_strength] instead.
|
||||
Returns a value between [code]0.0[/code] and [code]1.0[/code] representing the raw intensity of the given action, ignoring the action's deadzone. In most cases, you should use [method get_action_strength] instead.
|
||||
If [param exact_match] is [code]false[/code], it ignores additional input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events.
|
||||
</description>
|
||||
</method>
|
||||
|
|
@ -68,7 +78,7 @@
|
|||
<param index="0" name="action" type="StringName" />
|
||||
<param index="1" name="exact_match" type="bool" default="false" />
|
||||
<description>
|
||||
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.
|
||||
Returns a value between [code]0.0[/code] and [code]1.0[/code] 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 [code]1.0[/code]. If the action is mapped to a control that has no axis such as the keyboard, the value returned will be [code]0.0[/code] or [code]1.0[/code].
|
||||
If [param exact_match] is [code]false[/code], it ignores additional input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events.
|
||||
</description>
|
||||
</method>
|
||||
|
|
@ -77,7 +87,7 @@
|
|||
<param index="0" name="negative_action" type="StringName" />
|
||||
<param index="1" name="positive_action" type="StringName" />
|
||||
<description>
|
||||
Get axis input by specifying two actions, one negative and one positive.
|
||||
Returns axis input value by specifying two actions, one negative and one positive.
|
||||
This is a shorthand for writing [code]Input.get_action_strength("positive_action") - Input.get_action_strength("negative_action")[/code].
|
||||
</description>
|
||||
</method>
|
||||
|
|
@ -85,6 +95,7 @@
|
|||
<return type="int[]" />
|
||||
<description>
|
||||
Returns an [Array] containing the device IDs of all currently connected joypads.
|
||||
[b]Note:[/b] The order of connected joypads can not be guaranteed to be the same after a project and/or the editor is restarted, because Godot doesn't save the order of joypad connections. Joypads are registered in the order they are discovered by Godot.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_current_cursor_shape" qualifiers="const">
|
||||
|
|
@ -109,6 +120,19 @@
|
|||
[b]Note:[/b] For Android, [member ProjectSettings.input_devices/sensors/enable_gyroscope] must be enabled.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joy_accelerometer" qualifiers="const" experimental="">
|
||||
<return type="Vector3" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
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 [constant Vector3.ZERO]. See also [method get_joy_gravity] and [method set_joy_motion_sensors_enabled].
|
||||
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 [code]9.8[/code] away from the center of the Earth, which is a negative Y value.
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, and macOS. On iOS, joypad accelerometer sensor reading is not supported due to OS limitations.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joy_axis" qualifiers="const">
|
||||
<return type="float" />
|
||||
<param index="0" name="device" type="int" />
|
||||
|
|
@ -117,12 +141,38 @@
|
|||
Returns the current value of the joypad axis at index [param axis].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joy_gravity" qualifiers="const" experimental="">
|
||||
<return type="Vector3" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
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 [constant Vector3.ZERO]. See also [method get_joy_accelerometer] and [method set_joy_motion_sensors_enabled].
|
||||
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 [code]9.8[/code] away from the center of the Earth, which is a negative Y value.
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, and macOS. On iOS, joypad accelerometer sensor reading is not supported due to OS limitations.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joy_guid" qualifiers="const">
|
||||
<return type="String" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Returns an SDL-compatible device GUID on platforms that use gamepad remapping, e.g. [code]030000004c050000c405000000010000[/code]. Returns an empty string if it cannot be found. Godot uses SDL's internal mappings, supplemented by community-contributed mappings, to determine gamepad names and mappings based on this GUID.
|
||||
On Windows, all XInput joypad GUIDs will be overridden by Godot to [code]__XINPUT_DEVICE__[/code], because their mappings are the same.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joy_gyroscope" qualifiers="const" experimental="">
|
||||
<return type="Vector3" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Returns the rotation rate in rad/s around a joypad's X, Y, and Z axes of the gyroscope sensor, if the joypad has one and it's currently enabled. Otherwise, the method returns [constant Vector3.ZERO]. See also [method set_joy_motion_sensors_enabled].
|
||||
The rotation is positive in the counter-clockwise direction.
|
||||
For a joypad held in front of you, the returned axes are defined as follows:
|
||||
X: Angular speed around the X axis (pitch);
|
||||
Y: Angular speed around the Y axis (yaw);
|
||||
Z: Angular speed around the Z axis (roll).
|
||||
See [method start_joy_motion_sensors_calibration] for an example on how to use joypad gyroscope and gyroscope calibration in your games.
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joy_info" qualifiers="const">
|
||||
|
|
@ -130,21 +180,81 @@
|
|||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
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, and macOS, the dictionary contains the following fields:
|
||||
On Windows, Linux, macOS, and iOS, the dictionary contains the following fields:
|
||||
[code]raw_name[/code]: The name of the controller as it came from the OS, before getting renamed by the controller database.
|
||||
[code]vendor_id[/code]: The USB vendor ID of the device.
|
||||
[code]product_id[/code]: The USB product ID of the device.
|
||||
[code]steam_input_index[/code]: The Steam Input gamepad index, if the device is not a Steam Input device this key won't be present.
|
||||
On Windows, the dictionary can have an additional field:
|
||||
[code]xinput_index[/code]: The index of the controller in the XInput system. This key won't be present for devices not handled by XInput.
|
||||
[b]Note:[/b] The returned dictionary is always empty on Android, iOS, visionOS, and Web.
|
||||
[code]serial_number[/code]: 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:
|
||||
[code]steam_input_index[/code]: 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.
|
||||
[code]xinput_index[/code]: The index of the controller in the XInput system (Windows only). This key won't be present for devices not handled by XInput.
|
||||
[b]Note:[/b] The returned dictionary is always empty on Android and Web.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joy_motion_sensors_calibration" qualifiers="const" experimental="">
|
||||
<return type="Dictionary" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Returns the calibration information about the specified joypad's motion sensors in the form of a [Dictionary], if it has any and if they have been calibrated, otherwise returns an empty [Dictionary].
|
||||
The dictionary contains the following fields:
|
||||
[code]gyroscope_offset[/code]: average offset in gyroscope values from [constant Vector2.ZERO] in rad/s.
|
||||
See [method start_joy_motion_sensors_calibration] for an example on how to use joypad motion sensors and calibration in your games.
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joy_motion_sensors_rate" qualifiers="const" experimental="">
|
||||
<return type="float" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Returns the joypad's motion sensor rate in Hz, if the joypad has motion sensors and they're currently enabled. See also [method set_joy_motion_sensors_enabled].
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joy_name">
|
||||
<return type="String" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Returns the name of the joypad at the specified device index, e.g. [code]PS4 Controller[/code]. Godot uses the [url=https://github.com/gabomdq/SDL_GameControllerDB]SDL2 game controller database[/url] to determine gamepad names.
|
||||
Returns the name of the joypad at the specified device index, e.g. [code]PS4 Controller[/code]. Godot uses the [url=https://github.com/gabomdq/SDL_GameControllerDB]SDL game controller database[/url] to determine gamepad names.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joy_num_touchpads" qualifiers="const" experimental="">
|
||||
<return type="int" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Returns the number of touchpads on the specified joypad, if it has any. Otherwise, the method returns [code]0[/code].
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joy_touchpad_finger_position" qualifiers="const" experimental="">
|
||||
<return type="Vector2" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<param index="1" name="finger" type="int" />
|
||||
<param index="2" name="touchpad" type="int" default="0" />
|
||||
<description>
|
||||
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 [code]0.0[/code] to [code]1.0[/code], with [code](0.0, 0.0)[/code] representing the top-left corner of the touchpad and [code](1.0, 1.0)[/code] 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 [code]Vector2(-1.0, -1.0)[/code].
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joy_touchpad_finger_pressure" qualifiers="const" experimental="">
|
||||
<return type="float" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<param index="1" name="finger" type="int" />
|
||||
<param index="2" name="touchpad" type="int" default="0" />
|
||||
<description>
|
||||
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 [code]0.0[/code] to [code]1.0[/code].
|
||||
If the joypad doesn't have the specified touchpad or the specified finger is not currently touching the touchpad, this method returns [code]-1.0[/code].
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joy_touchpad_fingers" qualifiers="const" experimental="">
|
||||
<return type="PackedInt32Array" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<param index="1" name="touchpad" type="int" default="0" />
|
||||
<description>
|
||||
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.
|
||||
[b]Note:[/b] To retrieve the positions of the touchpad fingers, use [method get_joy_touchpad_finger_position].
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joy_vibration_duration">
|
||||
|
|
@ -152,6 +262,15 @@
|
|||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Returns the duration of the current vibration effect in seconds.
|
||||
[b]Note:[/b] This method returns the same value that was passed to [method start_joy_vibration], and this value does [b]not[/b] change when the joypad's vibration runs out, it only gets reset after a call to [method stop_joy_vibration].
|
||||
If you want to check if a joypad is still vibrating, use [method is_joy_vibrating] instead.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joy_vibration_remaining_duration" experimental="">
|
||||
<return type="float" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Returns the remaining duration of the current vibration effect in seconds.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joy_vibration_strength">
|
||||
|
|
@ -159,6 +278,8 @@
|
|||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Returns the strength of the joypad vibration: x is the strength of the weak motor, and y is the strength of the strong motor.
|
||||
[b]Note:[/b] This method returns the same values that were passed to [method start_joy_vibration], and these values do [b]not[/b] change when the joypad's vibration runs out, they only get reset after a call to [method stop_joy_vibration].
|
||||
If you want to check if a joypad is still vibrating, use [method is_joy_vibrating] instead.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_last_mouse_screen_velocity">
|
||||
|
|
@ -195,9 +316,9 @@
|
|||
<param index="3" name="positive_y" type="StringName" />
|
||||
<param index="4" name="deadzone" type="float" default="-1.0" />
|
||||
<description>
|
||||
Gets an input vector by specifying four actions for the positive and negative X and Y axes.
|
||||
This method is useful when getting vector input, such as from a joystick, directional pad, arrows, or WASD. The vector has its length limited to 1 and has a circular deadzone, which is useful for using vector input as movement.
|
||||
By default, the deadzone is automatically calculated from the average of the action deadzones. However, you can override the deadzone to be whatever you want (on the range of 0 to 1).
|
||||
Returns an input vector by specifying four actions for the positive and negative X and Y axes.
|
||||
This method is useful when getting vector input, such as from a joystick, directional pad, arrows, or WASD. The vector has its length limited to [code]1.0[/code] and has a circular deadzone, which is useful for using vector input as movement.
|
||||
By default, the deadzone is automatically calculated from the average of the action deadzones. However, you can override the deadzone to be whatever you want (on the range of [code]0.0[/code] to [code]1.0[/code]).
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_joy_light" qualifiers="const">
|
||||
|
|
@ -205,7 +326,24 @@
|
|||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the joypad has an LED light that can change colors and/or brightness. See also [method set_joy_light].
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, and macOS.
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_joy_motion_sensors" qualifiers="const" experimental="">
|
||||
<return type="bool" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the joypad has motion sensors (gyroscope and/or accelerometer).
|
||||
[b]Note:[/b] On iOS, joypad accelerometer sensor reading is not supported due to OS limitations.
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_joy_vibration" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the joypad supports vibration. See also [method start_joy_vibration].
|
||||
[b]Note:[/b] For macOS, vibration is only supported in macOS 11 and later. When connected via USB, vibration is only supported for major brand controllers (except Xbox One and Xbox Series X/S controllers) due to macOS limitations.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_action_just_pressed" qualifiers="const">
|
||||
|
|
@ -279,6 +417,23 @@
|
|||
<param index="1" name="button" type="int" enum="JoyButton" />
|
||||
<description>
|
||||
Returns [code]true[/code] if you are pressing the joypad button at index [param button].
|
||||
[b]Note:[/b] If you want to check if a joypad button was just pressed, use Godot's input action system with [method is_action_just_pressed] or use the [method Node._input] method like this instead:
|
||||
[codeblocks]
|
||||
[gdscript]
|
||||
func _input(event):
|
||||
if event is InputEventJoypadButton and event.is_pressed() and event.button_index == JOY_BUTTON_A:
|
||||
pass # Your code here.
|
||||
[/gdscript]
|
||||
[csharp]
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
if (@event is InputEventJoypadButton eventButton && eventButton.Pressed && eventButton.ButtonIndex == JoyButton.A)
|
||||
{
|
||||
// Your code here.
|
||||
}
|
||||
}
|
||||
[/csharp]
|
||||
[/codeblocks]
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_joy_known" keywords="is_gamepad_known, is_controller_known">
|
||||
|
|
@ -288,11 +443,63 @@
|
|||
Returns [code]true[/code] 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.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_joy_motion_sensors_calibrated" qualifiers="const" experimental="">
|
||||
<return type="bool" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the joypad's motion sensors have been calibrated.
|
||||
See [method start_joy_motion_sensors_calibration] for an example on how to use joypad motion sensors and calibration in your games.
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_joy_motion_sensors_calibrating" qualifiers="const" experimental="">
|
||||
<return type="bool" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the joypad's motion sensors are currently being calibrated.
|
||||
See [method start_joy_motion_sensors_calibration] for an example on how to use joypad motion sensors and calibration in your games.
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_joy_motion_sensors_enabled" qualifiers="const" experimental="">
|
||||
<return type="bool" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the requested joypad has motion sensors (gyroscope and/or accelerometer) and they are currently enabled. See also [method set_joy_motion_sensors_enabled] and [method has_joy_motion_sensors].
|
||||
See [method start_joy_motion_sensors_calibration] for an example on how to use joypad motion sensors and calibration in your games.
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_joy_vibrating" experimental="">
|
||||
<return type="bool" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the joypad is still vibrating after a call to [method start_joy_vibration].
|
||||
Unlike [method get_joy_vibration_strength] and [method get_joy_vibration_duration], this method returns [code]false[/code] after the joypad's vibration runs out.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_key_label_pressed" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="keycode" type="int" enum="Key" />
|
||||
<description>
|
||||
Returns [code]true[/code] if you are pressing the key with the [param keycode] printed on it. You can pass a [enum Key] constant or any Unicode character code.
|
||||
[b]Note:[/b] If you want to check if a key was just pressed by using its label, use Godot's input action system with [method is_action_just_pressed] or use the [method Node._input] method like this instead:
|
||||
[codeblocks]
|
||||
[gdscript]
|
||||
func _input(event):
|
||||
if event is InputEventKey and not event.is_echo() and event.is_pressed() and event.key_label == KEY_SPACE:
|
||||
pass # Your code here.
|
||||
[/gdscript]
|
||||
[csharp]
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
if (@event is InputEventKey eventKey && !eventKey.IsEcho() && eventKey.Pressed && eventKey.KeyLabel == Key.Space)
|
||||
{
|
||||
// Your code here.
|
||||
}
|
||||
}
|
||||
[/csharp]
|
||||
[/codeblocks]
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_key_pressed" qualifiers="const">
|
||||
|
|
@ -302,6 +509,23 @@
|
|||
Returns [code]true[/code] if you are pressing the Latin key in the current keyboard layout. You can pass a [enum Key] constant.
|
||||
[method is_key_pressed] is only recommended over [method is_physical_key_pressed] 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 [method is_physical_key_pressed].
|
||||
[b]Note:[/b] Due to keyboard ghosting, [method is_key_pressed] may return [code]false[/code] even if one of the action's keys is pressed. See [url=$DOCS_URL/tutorials/inputs/input_examples.html#keyboard-events]Input examples[/url] in the documentation for more information.
|
||||
[b]Note:[/b] If you want to check if a key was just pressed by using its keycode, use Godot's input action system with [method is_action_just_pressed] or use the [method Node._input] method like this instead:
|
||||
[codeblocks]
|
||||
[gdscript]
|
||||
func _input(event):
|
||||
if event is InputEventKey and not event.is_echo() and event.is_pressed() and event.keycode == KEY_SPACE:
|
||||
pass # Your code here.
|
||||
[/gdscript]
|
||||
[csharp]
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
if (@event is InputEventKey eventKey && !eventKey.IsEcho() && eventKey.Pressed && eventKey.Keycode == Key.Space)
|
||||
{
|
||||
// Your code here.
|
||||
}
|
||||
}
|
||||
[/csharp]
|
||||
[/codeblocks]
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_mouse_button_pressed" qualifiers="const">
|
||||
|
|
@ -309,6 +533,23 @@
|
|||
<param index="0" name="button" type="int" enum="MouseButton" />
|
||||
<description>
|
||||
Returns [code]true[/code] if you are pressing the mouse button specified with [enum MouseButton].
|
||||
[b]Note:[/b] If you want to check if a mouse button was just pressed, use Godot's input action system with [method is_action_just_pressed] or use the [method Node._input] method like this instead:
|
||||
[codeblocks]
|
||||
[gdscript]
|
||||
func _input(event):
|
||||
if event is InputEventMouseButton and event.is_pressed() and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
pass # Your code here.
|
||||
[/gdscript]
|
||||
[csharp]
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
if (@event is InputEventMouseButton eventMouseButton && eventMouseButton.Pressed && eventMouseButton.ButtonIndex == MouseButton.Left)
|
||||
{
|
||||
// Your code here.
|
||||
}
|
||||
}
|
||||
[/csharp]
|
||||
[/codeblocks]
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_physical_key_pressed" qualifiers="const">
|
||||
|
|
@ -318,6 +559,23 @@
|
|||
Returns [code]true[/code] if you are pressing the key in the physical location on the 101/102-key US QWERTY keyboard. You can pass a [enum Key] constant.
|
||||
[method is_physical_key_pressed] is recommended over [method is_key_pressed] for in-game actions, as it will make [kbd]W[/kbd]/[kbd]A[/kbd]/[kbd]S[/kbd]/[kbd]D[/kbd] layouts work regardless of the user's keyboard layout. [method is_physical_key_pressed] will also ensure that the top row number keys work on any keyboard layout. If in doubt, use [method is_physical_key_pressed].
|
||||
[b]Note:[/b] Due to keyboard ghosting, [method is_physical_key_pressed] may return [code]false[/code] even if one of the action's keys is pressed. See [url=$DOCS_URL/tutorials/inputs/input_examples.html#keyboard-events]Input examples[/url] in the documentation for more information.
|
||||
[b]Note:[/b] If you want to check if a key was just pressed by using its physical keycode, use Godot's input action system with [method is_action_just_pressed] or use the [method Node._input] method like this instead:
|
||||
[codeblocks]
|
||||
[gdscript]
|
||||
func _input(event):
|
||||
if event is InputEventKey and not event.is_echo() and event.is_pressed() and event.physical_keycode == KEY_SPACE:
|
||||
pass # Your code here.
|
||||
[/gdscript]
|
||||
[csharp]
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
if (@event is InputEventKey eventKey && !eventKey.IsEcho() && eventKey.Pressed && eventKey.PhysicalKeycode == Key.Space)
|
||||
{
|
||||
// Your code here.
|
||||
}
|
||||
}
|
||||
[/csharp]
|
||||
[/codeblocks]
|
||||
</description>
|
||||
</method>
|
||||
<method name="parse_input_event">
|
||||
|
|
@ -404,7 +662,28 @@
|
|||
<description>
|
||||
Sets the joypad's LED light, if available, to the specified color. See also [method has_joy_light].
|
||||
[b]Note:[/b] 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.
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, and macOS.
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_joy_motion_sensors_calibration" experimental="">
|
||||
<return type="void" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<param index="1" name="calibration_info" type="Dictionary" />
|
||||
<description>
|
||||
Sets the specified joypad's calibration information. See also [method get_joy_motion_sensors_calibration].
|
||||
See [method start_joy_motion_sensors_calibration] for an example on how to use joypad motion sensors and calibration in your games.
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_joy_motion_sensors_enabled" experimental="">
|
||||
<return type="void" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<param index="1" name="enable" type="bool" />
|
||||
<description>
|
||||
Enables or disables the motion sensors (gyroscope and/or accelerometer), if available, on the specified joypad.
|
||||
See [method start_joy_motion_sensors_calibration] for an example on how to use joypad motion sensors and calibration in your games.
|
||||
It's recommended to disable the motion sensors when they're no longer being used, because otherwise it might drain the controller battery faster.
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_magnetometer">
|
||||
|
|
@ -420,10 +699,118 @@
|
|||
<param index="0" name="vendor_id" type="int" />
|
||||
<param index="1" name="product_id" type="int" />
|
||||
<description>
|
||||
Queries whether an input device should be ignored or not. Devices can be ignored by setting the environment variable [code]SDL_GAMECONTROLLER_IGNORE_DEVICES[/code]. Read the [url=https://wiki.libsdl.org/SDL2]SDL documentation[/url] for more information.
|
||||
Queries whether an input device should be ignored or not. Devices can be ignored by setting the environment variable [code]SDL_GAMECONTROLLER_IGNORE_DEVICES[/code]. See [url=https://wiki.libsdl.org/SDL3/SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES]SDL documentation[/url] for more information.
|
||||
[b]Note:[/b] Some 3rd party tools can contribute to the list of ignored devices. For example, [i]SteamInput[/i] 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.
|
||||
</description>
|
||||
</method>
|
||||
<method name="start_joy_motion_sensors_calibration" experimental="">
|
||||
<return type="void" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Starts the process of 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), [method get_joy_gyroscope] will return values close or equal to [constant Vector3.ZERO] when the joypad is not being rotated.
|
||||
Here's an example of how to use joypad gyroscope and gyroscope calibration in your games:
|
||||
[codeblocks]
|
||||
[gdscript]
|
||||
const GYRO_SENSITIVITY = 10.0
|
||||
|
||||
func _ready():
|
||||
# In this example we only use the first connected joypad (id 0).
|
||||
if 0 not in Input.get_connected_joypads():
|
||||
return
|
||||
|
||||
if not Input.has_joy_motion_sensors(0):
|
||||
return
|
||||
|
||||
# We must enable the motion sensors before using them.
|
||||
Input.set_joy_motion_sensors_enabled(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.
|
||||
calibrate_motion()
|
||||
|
||||
func _process(delta):
|
||||
# Only move the object if the joypad motion sensors are calibrated.
|
||||
if Input.is_joy_motion_sensors_calibrated(0):
|
||||
move_object(delta)
|
||||
|
||||
func calibrate_motion():
|
||||
Input.start_joy_motion_sensors_calibration(0)
|
||||
|
||||
# Wait for some time.
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
|
||||
Input.stop_joy_motion_sensors_calibration(0)
|
||||
# The joypad is now calibrated.
|
||||
|
||||
func move_object(delta):
|
||||
var node: Node3D = ... # Put your node here.
|
||||
|
||||
var gyro := Input.get_joy_gyroscope(0)
|
||||
node.rotation.x -= -gyro.y * GYRO_SENSITIVITY * delta # Use rotation around the Y axis (yaw) here.
|
||||
node.rotation.y += -gyro.x * GYRO_SENSITIVITY * delta # Use rotation around the X axis (pitch) here.
|
||||
[/gdscript]
|
||||
[csharp]
|
||||
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), SceneTreeTimer.SignalName.Timeout);
|
||||
|
||||
Input.StopJoyMotionSensorsCalibration(0);
|
||||
// The joypad is now calibrated.
|
||||
}
|
||||
|
||||
private void MoveObject(double delta)
|
||||
{
|
||||
Node3D 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;
|
||||
}
|
||||
[/csharp]
|
||||
[/codeblocks]
|
||||
[b]Note:[/b] Accelerometer sensor doesn't usually require calibration.
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="start_joy_vibration">
|
||||
<return type="void" />
|
||||
<param index="0" name="device" type="int" />
|
||||
|
|
@ -431,9 +818,23 @@
|
|||
<param index="2" name="strong_magnitude" type="float" />
|
||||
<param index="3" name="duration" type="float" default="0" />
|
||||
<description>
|
||||
Starts to vibrate the joypad. Joypads usually come with two rumble motors, a strong and a weak one. [param weak_magnitude] is the strength of the weak motor (between 0 and 1) and [param strong_magnitude] is the strength of the strong motor (between 0 and 1). [param 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 [method stop_joy_vibration].
|
||||
[b]Note:[/b] 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.
|
||||
[b]Note:[/b] For macOS, vibration is only supported in macOS 11 and later.
|
||||
Starts vibrating the joypad. See also [method has_joy_vibration] and [method is_joy_vibrating].
|
||||
Joypads usually come with two rumble motors, a strong and a weak one.
|
||||
[param weak_magnitude] is the strength of the weak motor (between [code]0.0[/code] and [code]1.0[/code]).
|
||||
[param strong_magnitude] is the strength of the strong motor (between [code]0.0[/code] and [code]1.0[/code]).
|
||||
[param duration] is the duration of the effect in seconds (a duration of [code]0.0[/code] will try to play the vibration as long as possible, which is about 65 seconds).
|
||||
The vibration can be stopped early by calling [method stop_joy_vibration].
|
||||
See also [method get_joy_vibration_strength] and [method get_joy_vibration_duration].
|
||||
[b]Note:[/b] For macOS, vibration is only supported in macOS 11 and later. When connected via USB, vibration is only supported for major brand controllers (except Xbox One and Xbox Series X/S controllers) due to macOS limitations.
|
||||
</description>
|
||||
</method>
|
||||
<method name="stop_joy_motion_sensors_calibration" experimental="">
|
||||
<return type="void" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<description>
|
||||
Stops the calibration process of the specified joypad's motion sensors.
|
||||
See [method start_joy_motion_sensors_calibration] for an example on how to use joypad motion sensors and calibration in your games.
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, macOS, and iOS.
|
||||
</description>
|
||||
</method>
|
||||
<method name="stop_joy_vibration">
|
||||
|
|
@ -448,13 +849,14 @@
|
|||
<param index="0" name="duration_ms" type="int" default="500" />
|
||||
<param index="1" name="amplitude" type="float" default="-1.0" />
|
||||
<description>
|
||||
Vibrate the handheld device for the specified duration in milliseconds.
|
||||
Starts vibrating the handheld device for the specified duration in milliseconds.
|
||||
[param amplitude] is the strength of the vibration, as a value between [code]0.0[/code] and [code]1.0[/code]. If set to [code]-1.0[/code], the default vibration strength of the device is used.
|
||||
[b]Note:[/b] This method is implemented on Android, iOS, and Web. It has no effect on other platforms.
|
||||
[b]Note:[/b] For Android, [method vibrate_handheld] requires enabling the [code]VIBRATE[/code] permission in the export preset. Otherwise, [method vibrate_handheld] will have no effect.
|
||||
[b]Note:[/b] For iOS, specifying the duration is only supported in iOS 13 and later.
|
||||
[b]Note:[/b] For Web, the amplitude cannot be changed.
|
||||
[b]Note:[/b] Some web browsers such as Safari and Firefox for Android do not support [method vibrate_handheld].
|
||||
[b]Note:[/b] Device settings such as vibration on/off, "do not disturb" mode or specific haptic feedback on/off may prevent [method vibrate_handheld] effects.
|
||||
</description>
|
||||
</method>
|
||||
<method name="warp_mouse">
|
||||
|
|
@ -474,6 +876,9 @@
|
|||
<member name="emulate_touch_from_mouse" type="bool" setter="set_emulate_touch_from_mouse" getter="is_emulating_touch_from_mouse">
|
||||
If [code]true[/code], sends touch input events when clicking or dragging the mouse. See also [member ProjectSettings.input_devices/pointing/emulate_touch_from_mouse].
|
||||
</member>
|
||||
<member name="ignore_joypad_on_unfocused_application" type="bool" setter="set_ignore_joypad_on_unfocused_application" getter="is_ignoring_joypad_on_unfocused_application">
|
||||
If [code]true[/code], joypad input (including motion sensors) and LED light changes will be ignored and joypad vibration will be stopped when the application is not focused.
|
||||
</member>
|
||||
<member name="mouse_mode" type="int" setter="set_mouse_mode" getter="get_mouse_mode" enum="Input.MouseMode">
|
||||
Controls the mouse mode.
|
||||
</member>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue