.. 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 ---------------- +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_key_pressed` **(** :ref:`int` scancode **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_mouse_button_pressed` **(** :ref:`int` button **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_joy_button_pressed` **(** :ref:`int` device, :ref:`int` button **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_action_pressed` **(** :ref:`String` action **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_joy_mapping` **(** :ref:`String` mapping, :ref:`bool` update_existing=false **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`remove_joy_mapping` **(** :ref:`String` guid **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_joy_known` **(** :ref:`int` device **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_joy_axis` **(** :ref:`int` device, :ref:`int` axis **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_joy_name` **(** :ref:`int` device **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_joy_guid` **(** :ref:`int` device **)** const | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector3` | :ref:`get_accelerometer` **(** **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_mouse_speed` **(** **)** const | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_mouse_button_mask` **(** **)** const | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_mouse_mode` **(** :ref:`int` mode **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_mouse_mode` **(** **)** const | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`warp_mouse_pos` **(** :ref:`Vector2` to **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`action_press` **(** :ref:`String` action **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`action_release` **(** :ref:`String` action **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_custom_mouse_cursor` **(** :ref:`Texture` image, :ref:`Vector2` hotspot=Vector2(0,0) **)** | +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Signals ------- - **joy_connection_changed** **(** :ref:`int` index, :ref:`bool` connected **)** 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. Description ----------- A Singleton that deals with inputs. This includes key presses, mouse buttons and movement, joysticks, and input actions. Member Function Description --------------------------- .. _class_Input_is_key_pressed: - :ref:`bool` **is_key_pressed** **(** :ref:`int` scancode **)** 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 **)** 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_is_joy_button_pressed: - :ref:`bool` **is_joy_button_pressed** **(** :ref:`int` device, :ref:`int` button **)** Returns if the joystick button at the given index is currently pressed. (see JOY\_\* constants in :ref:`@Global Scope`) .. _class_Input_is_action_pressed: - :ref:`bool` **is_action_pressed** **(** :ref:`String` action **)** 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_add_joy_mapping: - void **add_joy_mapping** **(** :ref:`String` mapping, :ref:`bool` update_existing=false **)** Add a new mapping entry (in SDL2 format) to the mapping database. Optionally update already connected devices. .. _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_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 joysticks are not expected to match these constants, but you can still retrieve events from them. .. _class_Input_get_joy_axis: - :ref:`float` **get_joy_axis** **(** :ref:`int` device, :ref:`int` axis **)** Returns the current value of the joystick axis at given index (see JOY\_\* constants in :ref:`@Global Scope`) .. _class_Input_get_joy_name: - :ref:`String` **get_joy_name** **(** :ref:`int` device **)** Returns the name of the joystick at the specified device 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_accelerometer: - :ref:`Vector3` **get_accelerometer** **(** **)** If the device has an accelerometer, this will return the movement. .. _class_Input_get_mouse_speed: - :ref:`Vector2` **get_mouse_speed** **(** **)** const Returns the mouse speed. .. _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_set_mouse_mode: - void **set_mouse_mode** **(** :ref:`int` mode **)** Set the mouse mode. See the constants for more information. .. _class_Input_get_mouse_mode: - :ref:`int` **get_mouse_mode** **(** **)** const Return the mouse mode. See the constants for more information. .. _class_Input_warp_mouse_pos: - void **warp_mouse_pos** **(** :ref:`Vector2` to **)** Sets the mouse position to the specified vector. .. _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_set_custom_mouse_cursor: - void **set_custom_mouse_cursor** **(** :ref:`Texture` image, :ref:`Vector2` hotspot=Vector2(0,0) **)** Set a custom mouse cursor image, which is only visible inside the game window. The hotspot can also be specified.