.. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead. .. _class_Input: Input ===== **Inherits:** :ref:`Object` **Inherited By:** :ref:`InputDefault` **Category:** Core Brief Description ----------------- A Singleton that deals with inputs. Member Functions ---------------- +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`action_press` **(** :ref:`String` action **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`action_release` **(** :ref:`String` action **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_joy_mapping` **(** :ref:`String` mapping, :ref:`bool` update_existing=false **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector3` | :ref:`get_accelerometer` **(** **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`get_connected_joysticks` **(** **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector3` | :ref:`get_gravity` **(** **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector3` | :ref:`get_gyroscope` **(** **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_joy_axis` **(** :ref:`int` device, :ref:`int` axis **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_joy_axis_index_from_string` **(** :ref:`String` axis **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_joy_axis_string` **(** :ref:`int` axis_index **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_joy_button_index_from_string` **(** :ref:`String` button **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_joy_button_string` **(** :ref:`int` button_index **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_joy_guid` **(** :ref:`int` device **)** const | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_joy_name` **(** :ref:`int` device **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_joy_vibration_duration` **(** :ref:`int` device **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_joy_vibration_strength` **(** :ref:`int` device **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector3` | :ref:`get_magnetometer` **(** **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_mouse_button_mask` **(** **)** const | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_mouse_mode` **(** **)** const | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_mouse_speed` **(** **)** const | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_action_pressed` **(** :ref:`String` action **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_joy_button_pressed` **(** :ref:`int` device, :ref:`int` button **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_joy_known` **(** :ref:`int` device **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_key_pressed` **(** :ref:`int` scancode **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_mouse_button_pressed` **(** :ref:`int` button **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`parse_input_event` **(** :ref:`InputEvent` event **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`remove_joy_mapping` **(** :ref:`String` guid **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_custom_mouse_cursor` **(** :ref:`Texture` image, :ref:`Vector2` hotspot=Vector2(0, 0) **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_mouse_mode` **(** :ref:`int` mode **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`start_joy_vibration` **(** :ref:`int` device, :ref:`float` weak_magnitude, :ref:`float` strong_magnitude, :ref:`float` duration=0 **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`stop_joy_vibration` **(** :ref:`int` device **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`warp_mouse_pos` **(** :ref:`Vector2` to **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Signals ------- - **joy_connection_changed** **(** :ref:`int` index, :ref:`bool` connected **)** Emitted when a joystick device has been connected or disconnected Numeric Constants ----------------- - **MOUSE_MODE_VISIBLE** = **0** --- Makes the mouse cursor visible if it is hidden. - **MOUSE_MODE_HIDDEN** = **1** --- Makes the mouse cursor hidden if it is visible. - **MOUSE_MODE_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. - **MOUSE_MODE_CONFINED** = **3** Description ----------- A Singleton that deals with inputs. This includes key presses, mouse buttons and movement, joypads, and input actions. Member Function Description --------------------------- .. _class_Input_action_press: - void **action_press** **(** :ref:`String` action **)** This will simulate pressing the specificed action. .. _class_Input_action_release: - void **action_release** **(** :ref:`String` action **)** If the specified action is already pressed, this will release it. .. _class_Input_add_joy_mapping: - void **add_joy_mapping** **(** :ref:`String` mapping, :ref:`bool` update_existing=null **)** Add a new mapping entry (in SDL2 format) to the mapping database. Optionally update already connected devices. .. _class_Input_get_accelerometer: - :ref:`Vector3` **get_accelerometer** **(** **)** const If the device has an accelerometer, this will return the movement. .. _class_Input_get_connected_joypads: - :ref:`Array` **get_connected_joypads** **(** **)** Returns an :ref:`Array` containing the device IDs of all currently connected joypads. .. _class_Input_get_gravity: - :ref:`Vector3` **get_gravity** **(** **)** const .. _class_Input_get_gravity: - :ref:`Vector3` **get_gravity** **(** **)** .. _class_Input_get_gyroscope: - :ref:`Vector3` **get_gyroscope** **(** **)** const 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. .. _class_Input_get_joy_axis: - :ref:`float` **get_joy_axis** **(** :ref:`int` device, :ref:`int` axis **)** const Returns the current value of the joypad axis at given index (see JOY\_\* constants in :ref:`@Global Scope`) .. _class_Input_get_joy_axis_index_from_string: - :ref:`int` **get_joy_axis_index_from_string** **(** :ref:`String` axis **)** .. _class_Input_get_joy_axis_string: - :ref:`String` **get_joy_axis_string** **(** :ref:`int` axis_index **)** .. _class_Input_get_joy_button_index_from_string: - :ref:`int` **get_joy_button_index_from_string** **(** :ref:`String` button **)** .. _class_Input_get_joy_button_string: - :ref:`String` **get_joy_button_string** **(** :ref:`int` button_index **)** .. _class_Input_get_joy_axis_index_from_string: - :ref:`int` **get_joy_axis_index_from_string** **(** :ref:`String` axis **)** .. _class_Input_get_joy_axis_string: - :ref:`String` **get_joy_axis_string** **(** :ref:`int` axis_index **)** .. _class_Input_get_joy_button_index_from_string: - :ref:`int` **get_joy_button_index_from_string** **(** :ref:`String` button **)** .. _class_Input_get_joy_button_string: - :ref:`String` **get_joy_button_string** **(** :ref:`int` button_index **)** .. _class_Input_get_joy_guid: - :ref:`String` **get_joy_guid** **(** :ref:`int` device **)** const Returns a SDL2 compatible device guid on platforms that use gamepad remapping. Returns "Default Gamepad" otherwise. .. _class_Input_get_joy_name: - :ref:`String` **get_joy_name** **(** :ref:`int` device **)** Returns the name of the joypad at the specified device index .. _class_Input_get_joy_vibration_duration: - :ref:`float` **get_joy_vibration_duration** **(** :ref:`int` device **)** Returns the duration of the current vibration effect in seconds. .. _class_Input_get_joy_vibration_strength: - :ref:`Vector2` **get_joy_vibration_strength** **(** :ref:`int` device **)** Returns the strength of the joypad vibration: x is the strength of the weak motor, and y is the strength of the strong motor. .. _class_Input_get_last_mouse_speed: - :ref:`Vector2` **get_last_mouse_speed** **(** **)** const 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. .. _class_Input_get_magnetometer: - :ref:`Vector3` **get_magnetometer** **(** **)** const If the device has a magnetometer, this will return the magnetic field strength in micro-Tesla for all axes. .. _class_Input_get_mouse_button_mask: - :ref:`int` **get_mouse_button_mask** **(** **)** const Returns mouse buttons as a bitmask. If multiple mouse buttons are pressed at the same time the bits are added together. .. _class_Input_get_mouse_mode: - :ref:`int` **get_mouse_mode** **(** **)** const Return the mouse mode. See the constants for more information. .. _class_Input_is_action_just_pressed: - :ref:`bool` **is_action_just_pressed** **(** :ref:`String` action **)** const .. _class_Input_is_action_just_released: - :ref:`bool` **is_action_just_released** **(** :ref:`String` action **)** const .. _class_Input_is_action_pressed: - :ref:`bool` **is_action_pressed** **(** :ref:`String` action **)** const Returns true or false depending on whether the action event is pressed. Actions and their events can be set in the Project Settings / Input Map tab. Or be set with :ref:`InputMap`. .. _class_Input_is_joy_button_pressed: - :ref:`bool` **is_joy_button_pressed** **(** :ref:`int` device, :ref:`int` button **)** const Returns if the joypad button at the given index is currently pressed. (see JOY\_\* constants in :ref:`@Global Scope`) .. _class_Input_is_joy_known: - :ref:`bool` **is_joy_known** **(** :ref:`int` device **)** Returns if the specified device is known by the system. This means that it sets all button and axis indices exactly as defined in the JOY\_\* constants (see :ref:`@Global Scope`). Unknown joypads are not expected to match these constants, but you can still retrieve events from them. .. _class_Input_is_key_pressed: - :ref:`bool` **is_key_pressed** **(** :ref:`int` scancode **)** const Returns true or false depending on whether the key is pressed or not. You can pass KEY\_\*, which are pre-defined constants listed in :ref:`@Global Scope`. .. _class_Input_is_mouse_button_pressed: - :ref:`bool` **is_mouse_button_pressed** **(** :ref:`int` button **)** const Returns true or false depending on whether mouse button is pressed or not. You can pass BUTTON\_\*, which are pre-defined constants listed in :ref:`@Global Scope`. .. _class_Input_parse_input_event: - void **parse_input_event** **(** :ref:`InputEvent` event **)** .. _class_Input_remove_joy_mapping: - void **remove_joy_mapping** **(** :ref:`String` guid **)** Removes all mappings from the internal db that match the given uid. .. _class_Input_set_custom_mouse_cursor: - void **set_custom_mouse_cursor** **(** :ref:`Resource` image, :ref:`Vector2` hotspot=null **)** .. _class_Input_set_mouse_mode: - void **set_mouse_mode** **(** :ref:`int` mode **)** Set the mouse mode. See the constants for more information. .. _class_Input_start_joy_vibration: - void **start_joy_vibration** **(** :ref:`int` device, :ref:`float` weak_magnitude, :ref:`float` strong_magnitude, :ref:`float` duration=null **)** 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). Starts to vibrate the joystick. Joysticks 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 that not every hardware is compatible with long effect durations, it is recommended to restart an effect if in need to play it for more than a few seconds. .. _class_Input_stop_joy_vibration: - void **stop_joy_vibration** **(** :ref:`int` device **)** Stops the vibration of the joypad. .. _class_Input_warp_mouse_pos: - void **warp_mouse_pos** **(** :ref:`Vector2` to **)** Sets the mouse position to the specified vector.