2016-06-18 14:46:12 +02:00
|
|
|
/**************************************************************************/
|
2020-04-28 15:19:37 +02:00
|
|
|
/* input.h */
|
2016-06-18 14:46:12 +02:00
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/**************************************************************************/
|
2018-01-05 00:50:27 +01:00
|
|
|
|
2020-03-01 23:14:37 +01:00
|
|
|
#ifndef INPUT_H
|
|
|
|
#define INPUT_H
|
2015-09-24 23:06:15 +02:00
|
|
|
|
2020-03-04 17:36:09 +01:00
|
|
|
#include "core/input/input_event.h"
|
2020-11-07 23:33:38 +01:00
|
|
|
#include "core/object/object.h"
|
2021-06-20 19:12:33 +02:00
|
|
|
#include "core/os/keyboard.h"
|
2020-03-01 23:14:37 +01:00
|
|
|
#include "core/os/thread_safe.h"
|
2022-05-19 17:00:06 +02:00
|
|
|
#include "core/templates/rb_set.h"
|
2022-06-03 18:29:10 +02:00
|
|
|
#include "core/variant/typed_array.h"
|
2015-09-24 23:06:15 +02:00
|
|
|
|
2020-04-28 15:19:37 +02:00
|
|
|
class Input : public Object {
|
|
|
|
GDCLASS(Input, Object);
|
2015-09-24 23:06:15 +02:00
|
|
|
_THREAD_SAFE_CLASS_
|
|
|
|
|
2020-04-28 15:19:37 +02:00
|
|
|
static Input *singleton;
|
2020-03-01 23:14:37 +01:00
|
|
|
|
2023-11-15 17:42:56 +01:00
|
|
|
static constexpr uint64_t MAX_EVENT = 32;
|
2023-11-09 23:54:09 +01:00
|
|
|
|
2020-03-01 23:14:37 +01:00
|
|
|
public:
|
|
|
|
enum MouseMode {
|
|
|
|
MOUSE_MODE_VISIBLE,
|
|
|
|
MOUSE_MODE_HIDDEN,
|
|
|
|
MOUSE_MODE_CAPTURED,
|
2021-03-31 00:35:08 +02:00
|
|
|
MOUSE_MODE_CONFINED,
|
|
|
|
MOUSE_MODE_CONFINED_HIDDEN,
|
2020-03-01 23:14:37 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#undef CursorShape
|
|
|
|
enum CursorShape {
|
|
|
|
CURSOR_ARROW,
|
|
|
|
CURSOR_IBEAM,
|
|
|
|
CURSOR_POINTING_HAND,
|
|
|
|
CURSOR_CROSS,
|
|
|
|
CURSOR_WAIT,
|
|
|
|
CURSOR_BUSY,
|
|
|
|
CURSOR_DRAG,
|
|
|
|
CURSOR_CAN_DROP,
|
|
|
|
CURSOR_FORBIDDEN,
|
|
|
|
CURSOR_VSIZE,
|
|
|
|
CURSOR_HSIZE,
|
|
|
|
CURSOR_BDIAGSIZE,
|
|
|
|
CURSOR_FDIAGSIZE,
|
|
|
|
CURSOR_MOVE,
|
|
|
|
CURSOR_VSPLIT,
|
|
|
|
CURSOR_HSPLIT,
|
|
|
|
CURSOR_HELP,
|
|
|
|
CURSOR_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
JOYPADS_MAX = 16,
|
|
|
|
};
|
|
|
|
|
2020-03-04 17:36:09 +01:00
|
|
|
typedef void (*EventDispatchFunc)(const Ref<InputEvent> &p_event);
|
|
|
|
|
2020-03-01 23:14:37 +01:00
|
|
|
private:
|
2023-01-08 00:55:54 +01:00
|
|
|
BitField<MouseButtonMask> mouse_button_mask;
|
2016-09-01 23:58:52 +02:00
|
|
|
|
2022-12-11 00:21:22 +01:00
|
|
|
RBSet<Key> key_label_pressed;
|
2022-05-13 15:04:37 +02:00
|
|
|
RBSet<Key> physical_keys_pressed;
|
|
|
|
RBSet<Key> keys_pressed;
|
|
|
|
RBSet<JoyButton> joy_buttons_pressed;
|
|
|
|
RBMap<JoyAxis, float> _joy_axis;
|
|
|
|
//RBMap<StringName,int> custom_action_press;
|
2016-11-23 13:32:44 +01:00
|
|
|
Vector3 gravity;
|
2015-09-24 23:06:15 +02:00
|
|
|
Vector3 accelerometer;
|
2016-05-27 19:29:37 +02:00
|
|
|
Vector3 magnetometer;
|
2016-07-15 09:31:34 +02:00
|
|
|
Vector3 gyroscope;
|
2015-09-24 23:06:15 +02:00
|
|
|
Vector2 mouse_pos;
|
2020-05-12 17:01:17 +02:00
|
|
|
int64_t mouse_window = 0;
|
2023-05-14 09:53:36 +02:00
|
|
|
bool legacy_just_pressed_behavior = false;
|
2015-09-24 23:06:15 +02:00
|
|
|
|
2023-11-15 17:42:56 +01:00
|
|
|
struct ActionState {
|
2023-05-14 09:53:36 +02:00
|
|
|
uint64_t pressed_physics_frame = UINT64_MAX;
|
|
|
|
uint64_t pressed_process_frame = UINT64_MAX;
|
|
|
|
uint64_t released_physics_frame = UINT64_MAX;
|
|
|
|
uint64_t released_process_frame = UINT64_MAX;
|
|
|
|
bool exact = true;
|
2023-11-15 17:42:56 +01:00
|
|
|
|
|
|
|
struct DeviceState {
|
|
|
|
bool pressed[MAX_EVENT] = { false };
|
|
|
|
float strength[MAX_EVENT] = { 0.0 };
|
|
|
|
float raw_strength[MAX_EVENT] = { 0.0 };
|
|
|
|
};
|
|
|
|
bool api_pressed = false;
|
|
|
|
float api_strength = 0.0;
|
|
|
|
HashMap<int, DeviceState> device_states;
|
|
|
|
|
|
|
|
// Cache.
|
|
|
|
struct ActionStateCache {
|
|
|
|
bool pressed = false;
|
|
|
|
float strength = false;
|
|
|
|
float raw_strength = false;
|
|
|
|
} cache;
|
2016-09-01 23:58:52 +02:00
|
|
|
};
|
|
|
|
|
2023-11-15 17:42:56 +01:00
|
|
|
HashMap<StringName, ActionState> action_states;
|
2016-09-01 23:58:52 +02:00
|
|
|
|
2020-05-12 17:01:17 +02:00
|
|
|
bool emulate_touch_from_mouse = false;
|
|
|
|
bool emulate_mouse_from_touch = false;
|
2024-07-07 23:16:29 +02:00
|
|
|
bool agile_input_event_flushing = false;
|
2022-07-03 12:16:16 +02:00
|
|
|
bool use_accumulated_input = true;
|
2018-02-24 03:04:30 +01:00
|
|
|
|
2020-05-12 17:01:17 +02:00
|
|
|
int mouse_from_touch_index = -1;
|
2016-06-15 07:25:35 +02:00
|
|
|
|
2022-08-22 14:37:25 +02:00
|
|
|
struct VibrationInfo {
|
|
|
|
float weak_magnitude;
|
|
|
|
float strong_magnitude;
|
|
|
|
float duration; // Duration in seconds
|
|
|
|
uint64_t timestamp;
|
|
|
|
};
|
|
|
|
|
|
|
|
HashMap<int, VibrationInfo> joy_vibration;
|
|
|
|
|
2021-12-29 14:22:22 +01:00
|
|
|
struct VelocityTrack {
|
2022-05-02 16:28:25 +02:00
|
|
|
uint64_t last_tick = 0;
|
2021-12-29 14:22:22 +01:00
|
|
|
Vector2 velocity;
|
2023-10-04 19:20:01 +02:00
|
|
|
Vector2 screen_velocity;
|
2015-09-24 23:06:15 +02:00
|
|
|
Vector2 accum;
|
2023-10-04 19:20:01 +02:00
|
|
|
Vector2 screen_accum;
|
2022-05-02 16:28:25 +02:00
|
|
|
float accum_t = 0.0f;
|
2015-09-24 23:06:15 +02:00
|
|
|
float min_ref_frame;
|
|
|
|
float max_ref_frame;
|
|
|
|
|
2023-10-04 19:20:01 +02:00
|
|
|
void update(const Vector2 &p_delta_p, const Vector2 &p_screen_delta_p);
|
2015-09-24 23:06:15 +02:00
|
|
|
void reset();
|
2021-12-29 14:22:22 +01:00
|
|
|
VelocityTrack();
|
2015-09-24 23:06:15 +02:00
|
|
|
};
|
|
|
|
|
2017-01-08 21:05:51 +01:00
|
|
|
struct Joypad {
|
2015-12-18 19:15:32 +01:00
|
|
|
StringName name;
|
|
|
|
StringName uid;
|
2020-05-12 17:01:17 +02:00
|
|
|
bool connected = false;
|
2021-08-13 23:31:57 +02:00
|
|
|
bool last_buttons[(size_t)JoyButton::MAX] = { false };
|
|
|
|
float last_axis[(size_t)JoyAxis::MAX] = { 0.0f };
|
|
|
|
HatMask last_hat = HatMask::CENTER;
|
2020-05-12 17:01:17 +02:00
|
|
|
int mapping = -1;
|
|
|
|
int hat_current = 0;
|
2023-06-21 22:57:15 +02:00
|
|
|
Dictionary info;
|
2015-12-18 19:15:32 +01:00
|
|
|
};
|
2015-12-18 06:12:53 +01:00
|
|
|
|
2021-12-29 14:22:22 +01:00
|
|
|
VelocityTrack mouse_velocity_track;
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<int, VelocityTrack> touch_velocity_track;
|
|
|
|
HashMap<int, Joypad> joy_names;
|
2023-04-14 07:18:04 +02:00
|
|
|
|
|
|
|
HashSet<uint32_t> ignored_device_ids;
|
|
|
|
|
2020-05-12 17:01:17 +02:00
|
|
|
int fallback_mapping = -1;
|
2018-09-26 11:22:59 +02:00
|
|
|
|
2020-05-12 17:01:17 +02:00
|
|
|
CursorShape default_shape = CURSOR_ARROW;
|
2017-03-05 16:44:50 +01:00
|
|
|
|
2015-12-18 06:12:53 +01:00
|
|
|
enum JoyType {
|
|
|
|
TYPE_BUTTON,
|
|
|
|
TYPE_AXIS,
|
|
|
|
TYPE_HAT,
|
|
|
|
TYPE_MAX,
|
|
|
|
};
|
|
|
|
|
2020-04-23 11:16:09 +02:00
|
|
|
enum JoyAxisRange {
|
|
|
|
NEGATIVE_HALF_AXIS = -1,
|
|
|
|
FULL_AXIS = 0,
|
|
|
|
POSITIVE_HALF_AXIS = 1
|
|
|
|
};
|
|
|
|
|
2015-12-18 06:12:53 +01:00
|
|
|
struct JoyEvent {
|
2022-04-05 12:40:26 +02:00
|
|
|
int type = TYPE_MAX;
|
|
|
|
int index = -1; // Can be either JoyAxis or JoyButton.
|
|
|
|
float value = 0.f;
|
2015-12-18 06:12:53 +01:00
|
|
|
};
|
|
|
|
|
2020-04-23 14:01:36 +02:00
|
|
|
struct JoyBinding {
|
2020-04-23 11:16:09 +02:00
|
|
|
JoyType inputType;
|
|
|
|
union {
|
2021-03-25 21:56:12 +01:00
|
|
|
JoyButton button;
|
2020-04-23 11:16:09 +02:00
|
|
|
|
|
|
|
struct {
|
2021-03-25 21:56:12 +01:00
|
|
|
JoyAxis axis;
|
2020-04-23 11:16:09 +02:00
|
|
|
JoyAxisRange range;
|
2020-05-04 16:42:38 +02:00
|
|
|
bool invert;
|
2020-04-23 11:16:09 +02:00
|
|
|
} axis;
|
2015-12-18 06:12:53 +01:00
|
|
|
|
2020-04-23 11:16:09 +02:00
|
|
|
struct {
|
2021-03-25 21:56:12 +01:00
|
|
|
HatDir hat;
|
2020-04-23 11:16:09 +02:00
|
|
|
HatMask hat_mask;
|
|
|
|
} hat;
|
|
|
|
|
|
|
|
} input;
|
|
|
|
|
|
|
|
JoyType outputType;
|
|
|
|
union {
|
2020-05-14 00:27:34 +02:00
|
|
|
JoyButton button;
|
2020-04-23 11:16:09 +02:00
|
|
|
|
|
|
|
struct {
|
2020-05-14 00:27:34 +02:00
|
|
|
JoyAxis axis;
|
2020-04-23 11:16:09 +02:00
|
|
|
JoyAxisRange range;
|
|
|
|
} axis;
|
|
|
|
|
|
|
|
} output;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct JoyDeviceMapping {
|
2015-12-18 19:15:32 +01:00
|
|
|
String uid;
|
2016-02-29 16:48:19 +01:00
|
|
|
String name;
|
2020-04-23 14:01:36 +02:00
|
|
|
Vector<JoyBinding> bindings;
|
2015-12-18 19:15:32 +01:00
|
|
|
};
|
2015-12-18 06:12:53 +01:00
|
|
|
|
2015-12-18 19:15:32 +01:00
|
|
|
Vector<JoyDeviceMapping> map_db;
|
2015-12-18 06:12:53 +01:00
|
|
|
|
2021-03-25 21:56:12 +01:00
|
|
|
JoyEvent _get_mapped_button_event(const JoyDeviceMapping &mapping, JoyButton p_button);
|
2023-09-05 03:02:43 +02:00
|
|
|
JoyEvent _get_mapped_axis_event(const JoyDeviceMapping &mapping, JoyAxis p_axis, float p_value, JoyAxisRange &r_range);
|
2021-08-13 23:31:57 +02:00
|
|
|
void _get_mapped_hat_events(const JoyDeviceMapping &mapping, HatDir p_hat, JoyEvent r_events[(size_t)HatDir::MAX]);
|
2024-01-09 02:36:19 +01:00
|
|
|
JoyButton _get_output_button(const String &output);
|
|
|
|
JoyAxis _get_output_axis(const String &output);
|
2021-03-25 21:56:12 +01:00
|
|
|
void _button_event(int p_device, JoyButton p_index, bool p_pressed);
|
|
|
|
void _axis_event(int p_device, JoyAxis p_axis, float p_value);
|
2023-11-15 17:42:56 +01:00
|
|
|
void _update_action_cache(const StringName &p_action_name, ActionState &r_action_state);
|
2015-09-24 23:06:15 +02:00
|
|
|
|
2018-02-24 03:04:30 +01:00
|
|
|
void _parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_emulated);
|
|
|
|
|
2021-08-13 00:38:41 +02:00
|
|
|
List<Ref<InputEvent>> buffered_events;
|
2023-01-19 13:18:34 +01:00
|
|
|
#ifdef DEBUG_ENABLED
|
|
|
|
HashSet<Ref<InputEvent>> frame_parsed_events;
|
|
|
|
uint64_t last_parsed_frame = UINT64_MAX;
|
|
|
|
#endif
|
2020-05-12 17:01:17 +02:00
|
|
|
|
2020-03-03 14:36:29 +01:00
|
|
|
friend class DisplayServer;
|
|
|
|
|
|
|
|
static void (*set_mouse_mode_func)(MouseMode);
|
|
|
|
static MouseMode (*get_mouse_mode_func)();
|
2022-03-27 11:17:36 +02:00
|
|
|
static void (*warp_mouse_func)(const Vector2 &p_position);
|
2020-03-03 14:36:29 +01:00
|
|
|
|
|
|
|
static CursorShape (*get_current_cursor_shape_func)();
|
2022-05-03 01:43:50 +02:00
|
|
|
static void (*set_custom_mouse_cursor_func)(const Ref<Resource> &, CursorShape, const Vector2 &);
|
2019-03-03 23:52:18 +01:00
|
|
|
|
2020-05-12 17:01:17 +02:00
|
|
|
EventDispatchFunc event_dispatch_function = nullptr;
|
2020-03-04 17:36:09 +01:00
|
|
|
|
2024-05-02 15:15:42 +02:00
|
|
|
#ifndef DISABLE_DEPRECATED
|
|
|
|
void _vibrate_handheld_bind_compat_91143(int p_duration_ms = 500);
|
|
|
|
static void _bind_compatibility_methods();
|
|
|
|
#endif // DISABLE_DEPRECATED
|
|
|
|
|
2020-03-01 23:14:37 +01:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2015-09-24 23:06:15 +02:00
|
|
|
public:
|
2020-03-01 23:14:37 +01:00
|
|
|
void set_mouse_mode(MouseMode p_mode);
|
|
|
|
MouseMode get_mouse_mode() const;
|
2024-01-03 12:10:11 +01:00
|
|
|
|
|
|
|
#ifdef TOOLS_ENABLED
|
2020-07-10 12:34:39 +02:00
|
|
|
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
|
2024-01-03 12:10:11 +01:00
|
|
|
#endif
|
2020-03-01 23:14:37 +01:00
|
|
|
|
2020-04-28 15:19:37 +02:00
|
|
|
static Input *get_singleton();
|
2020-03-01 23:14:37 +01:00
|
|
|
|
2020-03-27 01:56:29 +01:00
|
|
|
bool is_anything_pressed() const;
|
2021-06-20 19:12:33 +02:00
|
|
|
bool is_key_pressed(Key p_keycode) const;
|
2021-11-23 10:14:19 +01:00
|
|
|
bool is_physical_key_pressed(Key p_keycode) const;
|
2022-12-11 00:21:22 +01:00
|
|
|
bool is_key_label_pressed(Key p_keycode) const;
|
2021-03-25 21:56:12 +01:00
|
|
|
bool is_mouse_button_pressed(MouseButton p_button) const;
|
|
|
|
bool is_joy_button_pressed(int p_device, JoyButton p_button) const;
|
Allow checking for exact matches with Action events.
Added additional param to action related methods to test for exactness.
If "p_exact_match" is true, then the action will only be "matched" if the provided input event *exactly* matches with the action event.
Before:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* Is Action Pressed = True
Now:
You can still do the above, however you can optionally check that the input is exactly what the action event is:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* p_exact_match = True
* Is Action Pressed = False
* If the Input Event was only KEY_S, then the result would be true.
Usage:
```gdscript
Input.is_action_pressed(action_name: String, exact_match: bool)
Input.is_action_pressed("my_action", true)
InputMap.event_is_action(p_event, "my_action", true)
func _input(event: InputEvent):
event.is_action_pressed("my_action", false, true) # false = "allow_echo", true = "exact_match"
event.is_action("my_action", true)
```
2020-12-13 15:22:42 +01:00
|
|
|
bool is_action_pressed(const StringName &p_action, bool p_exact = false) const;
|
|
|
|
bool is_action_just_pressed(const StringName &p_action, bool p_exact = false) const;
|
|
|
|
bool is_action_just_released(const StringName &p_action, bool p_exact = false) const;
|
|
|
|
float get_action_strength(const StringName &p_action, bool p_exact = false) const;
|
|
|
|
float get_action_raw_strength(const StringName &p_action, bool p_exact = false) const;
|
2020-03-01 23:14:37 +01:00
|
|
|
|
2020-11-10 07:21:13 +01:00
|
|
|
float get_axis(const StringName &p_negative_action, const StringName &p_positive_action) const;
|
|
|
|
Vector2 get_vector(const StringName &p_negative_x, const StringName &p_positive_x, const StringName &p_negative_y, const StringName &p_positive_y, float p_deadzone = -1.0f) const;
|
|
|
|
|
2021-03-25 21:56:12 +01:00
|
|
|
float get_joy_axis(int p_device, JoyAxis p_axis) const;
|
2015-09-24 23:06:15 +02:00
|
|
|
String get_joy_name(int p_idx);
|
2022-06-03 18:29:10 +02:00
|
|
|
TypedArray<int> get_connected_joypads();
|
2020-03-01 23:14:37 +01:00
|
|
|
Vector2 get_joy_vibration_strength(int p_device);
|
|
|
|
float get_joy_vibration_duration(int p_device);
|
|
|
|
uint64_t get_joy_vibration_timestamp(int p_device);
|
2024-01-09 02:36:19 +01:00
|
|
|
void joy_connection_changed(int p_idx, bool p_connected, const String &p_name, const String &p_guid = "", const Dictionary &p_joypad_info = Dictionary());
|
2015-09-24 23:06:15 +02:00
|
|
|
|
2020-03-01 23:14:37 +01:00
|
|
|
Vector3 get_gravity() const;
|
|
|
|
Vector3 get_accelerometer() const;
|
|
|
|
Vector3 get_magnetometer() const;
|
|
|
|
Vector3 get_gyroscope() const;
|
2015-09-24 23:06:15 +02:00
|
|
|
|
2020-03-01 23:14:37 +01:00
|
|
|
Point2 get_mouse_position() const;
|
2022-01-13 19:13:50 +01:00
|
|
|
Vector2 get_last_mouse_velocity();
|
2023-10-04 19:20:01 +02:00
|
|
|
Vector2 get_last_mouse_screen_velocity();
|
2023-01-08 00:55:54 +01:00
|
|
|
BitField<MouseButtonMask> get_mouse_button_mask() const;
|
2015-09-24 23:06:15 +02:00
|
|
|
|
2022-03-27 11:17:36 +02:00
|
|
|
void warp_mouse(const Vector2 &p_position);
|
2024-02-14 22:37:51 +01:00
|
|
|
Point2 warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect);
|
2015-09-24 23:06:15 +02:00
|
|
|
|
2020-03-01 23:14:37 +01:00
|
|
|
void parse_input_event(const Ref<InputEvent> &p_event);
|
2017-03-19 09:20:20 +01:00
|
|
|
|
2016-11-23 13:32:44 +01:00
|
|
|
void set_gravity(const Vector3 &p_gravity);
|
2015-09-24 23:06:15 +02:00
|
|
|
void set_accelerometer(const Vector3 &p_accel);
|
2016-05-27 19:29:37 +02:00
|
|
|
void set_magnetometer(const Vector3 &p_magnetometer);
|
2016-07-15 09:31:34 +02:00
|
|
|
void set_gyroscope(const Vector3 &p_gyroscope);
|
2021-03-25 21:56:12 +01:00
|
|
|
void set_joy_axis(int p_device, JoyAxis p_axis, float p_value);
|
2015-09-24 23:06:15 +02:00
|
|
|
|
2020-03-01 23:14:37 +01:00
|
|
|
void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration = 0);
|
|
|
|
void stop_joy_vibration(int p_device);
|
2024-05-02 15:15:42 +02:00
|
|
|
void vibrate_handheld(int p_duration_ms = 500, float p_amplitude = -1.0);
|
2016-06-15 07:25:35 +02:00
|
|
|
|
2017-03-29 17:29:38 +02:00
|
|
|
void set_mouse_position(const Point2 &p_posf);
|
2015-09-24 23:06:15 +02:00
|
|
|
|
2018-11-09 22:32:32 +01:00
|
|
|
void action_press(const StringName &p_action, float p_strength = 1.f);
|
2015-09-24 23:06:15 +02:00
|
|
|
void action_release(const StringName &p_action);
|
|
|
|
|
2018-02-24 03:04:30 +01:00
|
|
|
void set_emulate_touch_from_mouse(bool p_emulate);
|
2020-03-01 23:14:37 +01:00
|
|
|
bool is_emulating_touch_from_mouse() const;
|
2018-02-24 03:04:30 +01:00
|
|
|
void ensure_touch_mouse_raised();
|
|
|
|
|
|
|
|
void set_emulate_mouse_from_touch(bool p_emulate);
|
2020-03-01 23:14:37 +01:00
|
|
|
bool is_emulating_mouse_from_touch() const;
|
2015-09-24 23:06:15 +02:00
|
|
|
|
2020-03-01 23:14:37 +01:00
|
|
|
CursorShape get_default_cursor_shape() const;
|
|
|
|
void set_default_cursor_shape(CursorShape p_shape);
|
|
|
|
CursorShape get_current_cursor_shape() const;
|
2022-05-03 01:43:50 +02:00
|
|
|
void set_custom_mouse_cursor(const Ref<Resource> &p_cursor, CursorShape p_shape = Input::CURSOR_ARROW, const Vector2 &p_hotspot = Vector2());
|
2015-09-24 23:06:15 +02:00
|
|
|
|
2024-01-09 02:36:19 +01:00
|
|
|
void parse_mapping(const String &p_mapping);
|
2021-03-25 21:56:12 +01:00
|
|
|
void joy_button(int p_device, JoyButton p_button, bool p_pressed);
|
2021-12-25 10:29:08 +01:00
|
|
|
void joy_axis(int p_device, JoyAxis p_axis, float p_value);
|
2023-01-08 00:55:54 +01:00
|
|
|
void joy_hat(int p_device, BitField<HatMask> p_val);
|
2015-09-24 23:06:15 +02:00
|
|
|
|
2024-01-09 02:36:19 +01:00
|
|
|
void add_joy_mapping(const String &p_mapping, bool p_update_existing = false);
|
|
|
|
void remove_joy_mapping(const String &p_guid);
|
2016-01-08 00:40:41 +01:00
|
|
|
|
2017-02-21 17:02:49 +01:00
|
|
|
int get_unused_joy_id();
|
|
|
|
|
2020-03-03 14:36:29 +01:00
|
|
|
bool is_joy_known(int p_device);
|
|
|
|
String get_joy_guid(int p_device) const;
|
2023-04-14 07:18:04 +02:00
|
|
|
bool should_ignore_device(int p_vendor_id, int p_product_id) const;
|
2023-06-21 22:57:15 +02:00
|
|
|
Dictionary get_joy_info(int p_device) const;
|
2024-01-09 02:36:19 +01:00
|
|
|
void set_fallback_mapping(const String &p_guid);
|
2019-03-03 23:52:18 +01:00
|
|
|
|
2024-05-20 10:20:00 +02:00
|
|
|
#ifdef DEBUG_ENABLED
|
|
|
|
void flush_frame_parsed_events();
|
|
|
|
#endif
|
2021-08-13 00:38:41 +02:00
|
|
|
void flush_buffered_events();
|
2024-07-07 23:16:29 +02:00
|
|
|
bool is_agile_input_event_flushing();
|
|
|
|
void set_agile_input_event_flushing(bool p_enable);
|
2020-03-01 23:14:37 +01:00
|
|
|
void set_use_accumulated_input(bool p_enable);
|
2022-06-03 05:21:25 +02:00
|
|
|
bool is_using_accumulated_input();
|
2019-03-03 23:52:18 +01:00
|
|
|
|
2020-03-01 23:14:37 +01:00
|
|
|
void release_pressed_events();
|
|
|
|
|
2020-03-04 17:36:09 +01:00
|
|
|
void set_event_dispatch_function(EventDispatchFunc p_function);
|
|
|
|
|
2020-04-28 15:19:37 +02:00
|
|
|
Input();
|
2022-04-22 18:39:12 +02:00
|
|
|
~Input();
|
2015-09-24 23:06:15 +02:00
|
|
|
};
|
|
|
|
|
2020-04-28 15:19:37 +02:00
|
|
|
VARIANT_ENUM_CAST(Input::MouseMode);
|
|
|
|
VARIANT_ENUM_CAST(Input::CursorShape);
|
2020-03-01 23:14:37 +01:00
|
|
|
|
|
|
|
#endif // INPUT_H
|