summaryrefslogtreecommitdiff
path: root/core/os
diff options
context:
space:
mode:
Diffstat (limited to 'core/os')
-rw-r--r--core/os/input.cpp157
-rw-r--r--core/os/input.h146
-rw-r--r--core/os/input_event.cpp1374
-rw-r--r--core/os/input_event.h625
-rw-r--r--core/os/main_loop.h2
-rw-r--r--core/os/midi_driver.cpp4
-rw-r--r--core/os/os.cpp2
7 files changed, 4 insertions, 2306 deletions
diff --git a/core/os/input.cpp b/core/os/input.cpp
deleted file mode 100644
index 1768b851df..0000000000
--- a/core/os/input.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/*************************************************************************/
-/* input.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* 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. */
-/*************************************************************************/
-
-#include "input.h"
-
-#include "core/input_map.h"
-#include "core/os/os.h"
-#include "core/project_settings.h"
-
-#ifdef TOOLS_ENABLED
-#include "editor/editor_settings.h"
-#endif
-
-Input *Input::singleton = NULL;
-
-Input *Input::get_singleton() {
-
- return singleton;
-}
-
-void Input::set_mouse_mode(MouseMode p_mode) {
- ERR_FAIL_INDEX((int)p_mode, 4);
- OS::get_singleton()->set_mouse_mode((OS::MouseMode)p_mode);
-}
-
-Input::MouseMode Input::get_mouse_mode() const {
-
- return (MouseMode)OS::get_singleton()->get_mouse_mode();
-}
-
-void Input::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("is_key_pressed", "keycode"), &Input::is_key_pressed);
- ClassDB::bind_method(D_METHOD("is_mouse_button_pressed", "button"), &Input::is_mouse_button_pressed);
- ClassDB::bind_method(D_METHOD("is_joy_button_pressed", "device", "button"), &Input::is_joy_button_pressed);
- ClassDB::bind_method(D_METHOD("is_action_pressed", "action"), &Input::is_action_pressed);
- ClassDB::bind_method(D_METHOD("is_action_just_pressed", "action"), &Input::is_action_just_pressed);
- ClassDB::bind_method(D_METHOD("is_action_just_released", "action"), &Input::is_action_just_released);
- ClassDB::bind_method(D_METHOD("get_action_strength", "action"), &Input::get_action_strength);
- ClassDB::bind_method(D_METHOD("add_joy_mapping", "mapping", "update_existing"), &Input::add_joy_mapping, DEFVAL(false));
- ClassDB::bind_method(D_METHOD("remove_joy_mapping", "guid"), &Input::remove_joy_mapping);
- ClassDB::bind_method(D_METHOD("joy_connection_changed", "device", "connected", "name", "guid"), &Input::joy_connection_changed);
- ClassDB::bind_method(D_METHOD("is_joy_known", "device"), &Input::is_joy_known);
- ClassDB::bind_method(D_METHOD("get_joy_axis", "device", "axis"), &Input::get_joy_axis);
- ClassDB::bind_method(D_METHOD("get_joy_name", "device"), &Input::get_joy_name);
- ClassDB::bind_method(D_METHOD("get_joy_guid", "device"), &Input::get_joy_guid);
- ClassDB::bind_method(D_METHOD("get_connected_joypads"), &Input::get_connected_joypads);
- ClassDB::bind_method(D_METHOD("get_joy_vibration_strength", "device"), &Input::get_joy_vibration_strength);
- ClassDB::bind_method(D_METHOD("get_joy_vibration_duration", "device"), &Input::get_joy_vibration_duration);
- ClassDB::bind_method(D_METHOD("get_joy_button_string", "button_index"), &Input::get_joy_button_string);
- ClassDB::bind_method(D_METHOD("get_joy_button_index_from_string", "button"), &Input::get_joy_button_index_from_string);
- ClassDB::bind_method(D_METHOD("get_joy_axis_string", "axis_index"), &Input::get_joy_axis_string);
- ClassDB::bind_method(D_METHOD("get_joy_axis_index_from_string", "axis"), &Input::get_joy_axis_index_from_string);
- ClassDB::bind_method(D_METHOD("start_joy_vibration", "device", "weak_magnitude", "strong_magnitude", "duration"), &Input::start_joy_vibration, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("stop_joy_vibration", "device"), &Input::stop_joy_vibration);
- ClassDB::bind_method(D_METHOD("vibrate_handheld", "duration_ms"), &Input::vibrate_handheld, DEFVAL(500));
- ClassDB::bind_method(D_METHOD("get_gravity"), &Input::get_gravity);
- ClassDB::bind_method(D_METHOD("get_accelerometer"), &Input::get_accelerometer);
- ClassDB::bind_method(D_METHOD("get_magnetometer"), &Input::get_magnetometer);
- ClassDB::bind_method(D_METHOD("get_gyroscope"), &Input::get_gyroscope);
- //ClassDB::bind_method(D_METHOD("get_mouse_position"),&Input::get_mouse_position); - this is not the function you want
- ClassDB::bind_method(D_METHOD("get_last_mouse_speed"), &Input::get_last_mouse_speed);
- ClassDB::bind_method(D_METHOD("get_mouse_button_mask"), &Input::get_mouse_button_mask);
- ClassDB::bind_method(D_METHOD("set_mouse_mode", "mode"), &Input::set_mouse_mode);
- ClassDB::bind_method(D_METHOD("get_mouse_mode"), &Input::get_mouse_mode);
- ClassDB::bind_method(D_METHOD("warp_mouse_position", "to"), &Input::warp_mouse_position);
- ClassDB::bind_method(D_METHOD("action_press", "action", "strength"), &Input::action_press, DEFVAL(1.f));
- ClassDB::bind_method(D_METHOD("action_release", "action"), &Input::action_release);
- ClassDB::bind_method(D_METHOD("set_default_cursor_shape", "shape"), &Input::set_default_cursor_shape, DEFVAL(CURSOR_ARROW));
- ClassDB::bind_method(D_METHOD("get_current_cursor_shape"), &Input::get_current_cursor_shape);
- ClassDB::bind_method(D_METHOD("set_custom_mouse_cursor", "image", "shape", "hotspot"), &Input::set_custom_mouse_cursor, DEFVAL(CURSOR_ARROW), DEFVAL(Vector2()));
- ClassDB::bind_method(D_METHOD("parse_input_event", "event"), &Input::parse_input_event);
- ClassDB::bind_method(D_METHOD("set_use_accumulated_input", "enable"), &Input::set_use_accumulated_input);
-
- BIND_ENUM_CONSTANT(MOUSE_MODE_VISIBLE);
- BIND_ENUM_CONSTANT(MOUSE_MODE_HIDDEN);
- BIND_ENUM_CONSTANT(MOUSE_MODE_CAPTURED);
- BIND_ENUM_CONSTANT(MOUSE_MODE_CONFINED);
-
- BIND_ENUM_CONSTANT(CURSOR_ARROW);
- BIND_ENUM_CONSTANT(CURSOR_IBEAM);
- BIND_ENUM_CONSTANT(CURSOR_POINTING_HAND);
- BIND_ENUM_CONSTANT(CURSOR_CROSS);
- BIND_ENUM_CONSTANT(CURSOR_WAIT);
- BIND_ENUM_CONSTANT(CURSOR_BUSY);
- BIND_ENUM_CONSTANT(CURSOR_DRAG);
- BIND_ENUM_CONSTANT(CURSOR_CAN_DROP);
- BIND_ENUM_CONSTANT(CURSOR_FORBIDDEN);
- BIND_ENUM_CONSTANT(CURSOR_VSIZE);
- BIND_ENUM_CONSTANT(CURSOR_HSIZE);
- BIND_ENUM_CONSTANT(CURSOR_BDIAGSIZE);
- BIND_ENUM_CONSTANT(CURSOR_FDIAGSIZE);
- BIND_ENUM_CONSTANT(CURSOR_MOVE);
- BIND_ENUM_CONSTANT(CURSOR_VSPLIT);
- BIND_ENUM_CONSTANT(CURSOR_HSPLIT);
- BIND_ENUM_CONSTANT(CURSOR_HELP);
-
- ADD_SIGNAL(MethodInfo("joy_connection_changed", PropertyInfo(Variant::INT, "device"), PropertyInfo(Variant::BOOL, "connected")));
-}
-
-void Input::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
-#ifdef TOOLS_ENABLED
-
- const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
-
- String pf = p_function;
- if (p_idx == 0 && (pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" || pf == "is_action_just_pressed" || pf == "is_action_just_released" || pf == "get_action_strength")) {
-
- List<PropertyInfo> pinfo;
- ProjectSettings::get_singleton()->get_property_list(&pinfo);
-
- for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- const PropertyInfo &pi = E->get();
-
- if (!pi.name.begins_with("input/"))
- continue;
-
- String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
- r_options->push_back(quote_style + name + quote_style);
- }
- }
-#endif
-}
-
-Input::Input() {
-
- singleton = this;
-}
-
-//////////////////////////////////////////////////////////
diff --git a/core/os/input.h b/core/os/input.h
deleted file mode 100644
index 55e0511080..0000000000
--- a/core/os/input.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*************************************************************************/
-/* input.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* 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. */
-/*************************************************************************/
-
-#ifndef INPUT_H
-#define INPUT_H
-
-#include "core/object.h"
-#include "core/os/main_loop.h"
-#include "core/os/thread_safe.h"
-
-class Input : public Object {
-
- GDCLASS(Input, Object);
-
- static Input *singleton;
-
-protected:
- static void _bind_methods();
-
-public:
- enum MouseMode {
- MOUSE_MODE_VISIBLE,
- MOUSE_MODE_HIDDEN,
- MOUSE_MODE_CAPTURED,
- MOUSE_MODE_CONFINED
- };
-
-#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
- };
-
- void set_mouse_mode(MouseMode p_mode);
- MouseMode get_mouse_mode() const;
-
- static Input *get_singleton();
-
- virtual bool is_key_pressed(int p_keycode) const = 0;
- virtual bool is_mouse_button_pressed(int p_button) const = 0;
- virtual bool is_joy_button_pressed(int p_device, int p_button) const = 0;
- virtual bool is_action_pressed(const StringName &p_action) const = 0;
- virtual bool is_action_just_pressed(const StringName &p_action) const = 0;
- virtual bool is_action_just_released(const StringName &p_action) const = 0;
- virtual float get_action_strength(const StringName &p_action) const = 0;
-
- virtual float get_joy_axis(int p_device, int p_axis) const = 0;
- virtual String get_joy_name(int p_idx) = 0;
- virtual Array get_connected_joypads() = 0;
- virtual void joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid) = 0;
- virtual void add_joy_mapping(String p_mapping, bool p_update_existing = false) = 0;
- virtual void remove_joy_mapping(String p_guid) = 0;
- virtual bool is_joy_known(int p_device) = 0;
- virtual String get_joy_guid(int p_device) const = 0;
- virtual Vector2 get_joy_vibration_strength(int p_device) = 0;
- virtual float get_joy_vibration_duration(int p_device) = 0;
- virtual uint64_t get_joy_vibration_timestamp(int p_device) = 0;
- virtual void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration = 0) = 0;
- virtual void stop_joy_vibration(int p_device) = 0;
- virtual void vibrate_handheld(int p_duration_ms = 500) = 0;
-
- virtual Point2 get_mouse_position() const = 0;
- virtual Point2 get_last_mouse_speed() const = 0;
- virtual int get_mouse_button_mask() const = 0;
-
- virtual void warp_mouse_position(const Vector2 &p_to) = 0;
- virtual Point2i warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect) = 0;
-
- virtual Vector3 get_gravity() const = 0;
- virtual Vector3 get_accelerometer() const = 0;
- virtual Vector3 get_magnetometer() const = 0;
- virtual Vector3 get_gyroscope() const = 0;
-
- virtual void action_press(const StringName &p_action, float p_strength = 1.f) = 0;
- virtual void action_release(const StringName &p_action) = 0;
-
- void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
-
- virtual bool is_emulating_touch_from_mouse() const = 0;
- virtual bool is_emulating_mouse_from_touch() const = 0;
-
- virtual CursorShape get_default_cursor_shape() const = 0;
- virtual void set_default_cursor_shape(CursorShape p_shape) = 0;
- virtual CursorShape get_current_cursor_shape() const = 0;
- virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()) = 0;
-
- virtual String get_joy_button_string(int p_button) = 0;
- virtual String get_joy_axis_string(int p_axis) = 0;
- virtual int get_joy_button_index_from_string(String p_button) = 0;
- virtual int get_joy_axis_index_from_string(String p_axis) = 0;
-
- virtual void parse_input_event(const Ref<InputEvent> &p_event) = 0;
- virtual void accumulate_input_event(const Ref<InputEvent> &p_event) = 0;
- virtual void flush_accumulated_events() = 0;
- virtual void set_use_accumulated_input(bool p_enable) = 0;
-
- Input();
-};
-
-VARIANT_ENUM_CAST(Input::MouseMode);
-VARIANT_ENUM_CAST(Input::CursorShape);
-
-#endif // INPUT_H
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
deleted file mode 100644
index 204a36bf56..0000000000
--- a/core/os/input_event.cpp
+++ /dev/null
@@ -1,1374 +0,0 @@
-/*************************************************************************/
-/* input_event.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* 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. */
-/*************************************************************************/
-
-#include "input_event.h"
-
-#include "core/input_map.h"
-#include "core/os/keyboard.h"
-
-const int InputEvent::DEVICE_ID_TOUCH_MOUSE = -1;
-const int InputEvent::DEVICE_ID_INTERNAL = -2;
-
-void InputEvent::set_device(int p_device) {
- device = p_device;
-}
-
-int InputEvent::get_device() const {
- return device;
-}
-
-bool InputEvent::is_action(const StringName &p_action) const {
-
- return InputMap::get_singleton()->event_is_action(Ref<InputEvent>((InputEvent *)this), p_action);
-}
-
-bool InputEvent::is_action_pressed(const StringName &p_action, bool p_allow_echo) const {
-
- bool pressed;
- bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>((InputEvent *)this), p_action, &pressed);
- return valid && pressed && (p_allow_echo || !is_echo());
-}
-
-bool InputEvent::is_action_released(const StringName &p_action) const {
-
- bool pressed;
- bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>((InputEvent *)this), p_action, &pressed);
- return valid && !pressed;
-}
-
-float InputEvent::get_action_strength(const StringName &p_action) const {
-
- bool pressed;
- float strength;
- bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>((InputEvent *)this), p_action, &pressed, &strength);
- return valid ? strength : 0.0f;
-}
-
-bool InputEvent::is_pressed() const {
-
- return false;
-}
-
-bool InputEvent::is_echo() const {
-
- return false;
-}
-
-Ref<InputEvent> InputEvent::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
-
- return Ref<InputEvent>((InputEvent *)this);
-}
-
-String InputEvent::as_text() const {
-
- return String();
-}
-
-bool InputEvent::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
-
- return false;
-}
-
-bool InputEvent::shortcut_match(const Ref<InputEvent> &p_event) const {
-
- return false;
-}
-
-bool InputEvent::is_action_type() const {
-
- return false;
-}
-
-void InputEvent::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_device", "device"), &InputEvent::set_device);
- ClassDB::bind_method(D_METHOD("get_device"), &InputEvent::get_device);
-
- ClassDB::bind_method(D_METHOD("is_action", "action"), &InputEvent::is_action);
- ClassDB::bind_method(D_METHOD("is_action_pressed", "action", "allow_echo"), &InputEvent::is_action_pressed, DEFVAL(false));
- ClassDB::bind_method(D_METHOD("is_action_released", "action"), &InputEvent::is_action_released);
- ClassDB::bind_method(D_METHOD("get_action_strength", "action"), &InputEvent::get_action_strength);
-
- ClassDB::bind_method(D_METHOD("is_pressed"), &InputEvent::is_pressed);
- ClassDB::bind_method(D_METHOD("is_echo"), &InputEvent::is_echo);
-
- ClassDB::bind_method(D_METHOD("as_text"), &InputEvent::as_text);
-
- ClassDB::bind_method(D_METHOD("shortcut_match", "event"), &InputEvent::shortcut_match);
-
- ClassDB::bind_method(D_METHOD("is_action_type"), &InputEvent::is_action_type);
-
- ClassDB::bind_method(D_METHOD("accumulate", "with_event"), &InputEvent::accumulate);
-
- ClassDB::bind_method(D_METHOD("xformed_by", "xform", "local_ofs"), &InputEvent::xformed_by, DEFVAL(Vector2()));
-
- ADD_PROPERTY(PropertyInfo(Variant::INT, "device"), "set_device", "get_device");
-}
-
-InputEvent::InputEvent() {
-
- device = 0;
-}
-
-//////////////////
-
-void InputEventWithModifiers::set_shift(bool p_enabled) {
-
- shift = p_enabled;
-}
-
-bool InputEventWithModifiers::get_shift() const {
-
- return shift;
-}
-
-void InputEventWithModifiers::set_alt(bool p_enabled) {
-
- alt = p_enabled;
-}
-bool InputEventWithModifiers::get_alt() const {
-
- return alt;
-}
-
-void InputEventWithModifiers::set_control(bool p_enabled) {
-
- control = p_enabled;
-}
-bool InputEventWithModifiers::get_control() const {
-
- return control;
-}
-
-void InputEventWithModifiers::set_metakey(bool p_enabled) {
-
- meta = p_enabled;
-}
-bool InputEventWithModifiers::get_metakey() const {
-
- return meta;
-}
-
-void InputEventWithModifiers::set_command(bool p_enabled) {
-
- command = p_enabled;
-}
-bool InputEventWithModifiers::get_command() const {
-
- return command;
-}
-
-void InputEventWithModifiers::set_modifiers_from_event(const InputEventWithModifiers *event) {
-
- set_alt(event->get_alt());
- set_shift(event->get_shift());
- set_control(event->get_control());
- set_metakey(event->get_metakey());
-}
-
-void InputEventWithModifiers::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_alt", "enable"), &InputEventWithModifiers::set_alt);
- ClassDB::bind_method(D_METHOD("get_alt"), &InputEventWithModifiers::get_alt);
-
- ClassDB::bind_method(D_METHOD("set_shift", "enable"), &InputEventWithModifiers::set_shift);
- ClassDB::bind_method(D_METHOD("get_shift"), &InputEventWithModifiers::get_shift);
-
- ClassDB::bind_method(D_METHOD("set_control", "enable"), &InputEventWithModifiers::set_control);
- ClassDB::bind_method(D_METHOD("get_control"), &InputEventWithModifiers::get_control);
-
- ClassDB::bind_method(D_METHOD("set_metakey", "enable"), &InputEventWithModifiers::set_metakey);
- ClassDB::bind_method(D_METHOD("get_metakey"), &InputEventWithModifiers::get_metakey);
-
- ClassDB::bind_method(D_METHOD("set_command", "enable"), &InputEventWithModifiers::set_command);
- ClassDB::bind_method(D_METHOD("get_command"), &InputEventWithModifiers::get_command);
-
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "alt"), "set_alt", "get_alt");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shift"), "set_shift", "get_shift");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "control"), "set_control", "get_control");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "meta"), "set_metakey", "get_metakey");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "command"), "set_command", "get_command");
-}
-
-InputEventWithModifiers::InputEventWithModifiers() {
-
- alt = false;
- shift = false;
- control = false;
- meta = false;
-}
-
-//////////////////////////////////
-
-void InputEventKey::set_pressed(bool p_pressed) {
-
- pressed = p_pressed;
-}
-
-bool InputEventKey::is_pressed() const {
-
- return pressed;
-}
-
-void InputEventKey::set_keycode(uint32_t p_keycode) {
-
- keycode = p_keycode;
-}
-
-uint32_t InputEventKey::get_keycode() const {
-
- return keycode;
-}
-
-void InputEventKey::set_physical_keycode(uint32_t p_keycode) {
-
- physical_keycode = p_keycode;
-}
-
-uint32_t InputEventKey::get_physical_keycode() const {
-
- return physical_keycode;
-}
-
-void InputEventKey::set_unicode(uint32_t p_unicode) {
-
- unicode = p_unicode;
-}
-
-uint32_t InputEventKey::get_unicode() const {
-
- return unicode;
-}
-
-void InputEventKey::set_echo(bool p_enable) {
-
- echo = p_enable;
-}
-
-bool InputEventKey::is_echo() const {
-
- return echo;
-}
-
-uint32_t InputEventKey::get_keycode_with_modifiers() const {
-
- uint32_t sc = keycode;
- if (get_control())
- sc |= KEY_MASK_CTRL;
- if (get_alt())
- sc |= KEY_MASK_ALT;
- if (get_shift())
- sc |= KEY_MASK_SHIFT;
- if (get_metakey())
- sc |= KEY_MASK_META;
-
- return sc;
-}
-
-uint32_t InputEventKey::get_physical_keycode_with_modifiers() const {
-
- uint32_t sc = physical_keycode;
- if (get_control())
- sc |= KEY_MASK_CTRL;
- if (get_alt())
- sc |= KEY_MASK_ALT;
- if (get_shift())
- sc |= KEY_MASK_SHIFT;
- if (get_metakey())
- sc |= KEY_MASK_META;
-
- return sc;
-}
-
-String InputEventKey::as_text() const {
-
- String kc = keycode_get_string(keycode);
- if (kc == String())
- return kc;
-
- if (get_metakey()) {
- kc = find_keycode_name(KEY_META) + ("+" + kc);
- }
- if (get_alt()) {
- kc = find_keycode_name(KEY_ALT) + ("+" + kc);
- }
- if (get_shift()) {
- kc = find_keycode_name(KEY_SHIFT) + ("+" + kc);
- }
- if (get_control()) {
- kc = find_keycode_name(KEY_CONTROL) + ("+" + kc);
- }
- return kc;
-}
-
-bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
-
- Ref<InputEventKey> key = p_event;
- if (key.is_null())
- return false;
-
- bool match = false;
- if (get_keycode() == 0) {
- uint32_t code = get_physical_keycode_with_modifiers();
- uint32_t event_code = key->get_physical_keycode_with_modifiers();
-
- match = get_physical_keycode() == key->get_physical_keycode() && (!key->is_pressed() || (code & event_code) == code);
- } else {
- uint32_t code = get_keycode_with_modifiers();
- uint32_t event_code = key->get_keycode_with_modifiers();
-
- match = get_keycode() == key->get_keycode() && (!key->is_pressed() || (code & event_code) == code);
- }
- if (match) {
- if (p_pressed != NULL)
- *p_pressed = key->is_pressed();
- if (p_strength != NULL)
- *p_strength = (p_pressed != NULL && *p_pressed) ? 1.0f : 0.0f;
- }
- return match;
-}
-
-bool InputEventKey::shortcut_match(const Ref<InputEvent> &p_event) const {
-
- Ref<InputEventKey> key = p_event;
- if (key.is_null())
- return false;
-
- uint32_t code = get_keycode_with_modifiers();
- uint32_t event_code = key->get_keycode_with_modifiers();
-
- return code == event_code;
-}
-
-void InputEventKey::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventKey::set_pressed);
-
- ClassDB::bind_method(D_METHOD("set_keycode", "keycode"), &InputEventKey::set_keycode);
- ClassDB::bind_method(D_METHOD("get_keycode"), &InputEventKey::get_keycode);
-
- ClassDB::bind_method(D_METHOD("set_physical_keycode", "physical_keycode"), &InputEventKey::set_physical_keycode);
- ClassDB::bind_method(D_METHOD("get_physical_keycode"), &InputEventKey::get_physical_keycode);
-
- ClassDB::bind_method(D_METHOD("set_unicode", "unicode"), &InputEventKey::set_unicode);
- ClassDB::bind_method(D_METHOD("get_unicode"), &InputEventKey::get_unicode);
-
- ClassDB::bind_method(D_METHOD("set_echo", "echo"), &InputEventKey::set_echo);
-
- ClassDB::bind_method(D_METHOD("get_keycode_with_modifiers"), &InputEventKey::get_keycode_with_modifiers);
- ClassDB::bind_method(D_METHOD("get_physical_keycode_with_modifiers"), &InputEventKey::get_physical_keycode_with_modifiers);
-
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "keycode"), "set_keycode", "get_keycode");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "physical_keycode"), "set_physical_keycode", "get_physical_keycode");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "unicode"), "set_unicode", "get_unicode");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "echo"), "set_echo", "is_echo");
-}
-
-InputEventKey::InputEventKey() {
-
- pressed = false;
- keycode = 0;
- physical_keycode = 0;
- unicode = 0; ///unicode
- echo = false;
-}
-
-////////////////////////////////////////
-
-void InputEventMouse::set_button_mask(int p_mask) {
-
- button_mask = p_mask;
-}
-int InputEventMouse::get_button_mask() const {
-
- return button_mask;
-}
-
-void InputEventMouse::set_position(const Vector2 &p_pos) {
-
- pos = p_pos;
-}
-Vector2 InputEventMouse::get_position() const {
-
- return pos;
-}
-
-void InputEventMouse::set_global_position(const Vector2 &p_global_pos) {
-
- global_pos = p_global_pos;
-}
-Vector2 InputEventMouse::get_global_position() const {
-
- return global_pos;
-}
-
-void InputEventMouse::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_button_mask", "button_mask"), &InputEventMouse::set_button_mask);
- ClassDB::bind_method(D_METHOD("get_button_mask"), &InputEventMouse::get_button_mask);
-
- ClassDB::bind_method(D_METHOD("set_position", "position"), &InputEventMouse::set_position);
- ClassDB::bind_method(D_METHOD("get_position"), &InputEventMouse::get_position);
-
- ClassDB::bind_method(D_METHOD("set_global_position", "global_position"), &InputEventMouse::set_global_position);
- ClassDB::bind_method(D_METHOD("get_global_position"), &InputEventMouse::get_global_position);
-
- ADD_PROPERTY(PropertyInfo(Variant::INT, "button_mask"), "set_button_mask", "get_button_mask");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_position"), "set_global_position", "get_global_position");
-}
-
-InputEventMouse::InputEventMouse() {
-
- button_mask = 0;
-}
-
-///////////////////////////////////////
-
-void InputEventMouseButton::set_factor(float p_factor) {
-
- factor = p_factor;
-}
-
-float InputEventMouseButton::get_factor() {
-
- return factor;
-}
-
-void InputEventMouseButton::set_button_index(int p_index) {
-
- button_index = p_index;
-}
-int InputEventMouseButton::get_button_index() const {
-
- return button_index;
-}
-
-void InputEventMouseButton::set_pressed(bool p_pressed) {
-
- pressed = p_pressed;
-}
-bool InputEventMouseButton::is_pressed() const {
-
- return pressed;
-}
-
-void InputEventMouseButton::set_doubleclick(bool p_doubleclick) {
-
- doubleclick = p_doubleclick;
-}
-bool InputEventMouseButton::is_doubleclick() const {
-
- return doubleclick;
-}
-
-Ref<InputEvent> InputEventMouseButton::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
-
- Vector2 g = get_global_position();
- Vector2 l = p_xform.xform(get_position() + p_local_ofs);
-
- Ref<InputEventMouseButton> mb;
- mb.instance();
-
- mb->set_device(get_device());
-
- mb->set_modifiers_from_event(this);
-
- mb->set_position(l);
- mb->set_global_position(g);
-
- mb->set_button_mask(get_button_mask());
- mb->set_pressed(pressed);
- mb->set_doubleclick(doubleclick);
- mb->set_factor(factor);
- mb->set_button_index(button_index);
-
- return mb;
-}
-
-bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
-
- Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_null())
- return false;
-
- bool match = mb->button_index == button_index;
- if (match) {
- if (p_pressed != NULL)
- *p_pressed = mb->is_pressed();
- if (p_strength != NULL)
- *p_strength = (p_pressed != NULL && *p_pressed) ? 1.0f : 0.0f;
- }
-
- return match;
-}
-
-String InputEventMouseButton::as_text() const {
-
- String button_index_string = "";
- switch (get_button_index()) {
- case BUTTON_LEFT:
- button_index_string = "BUTTON_LEFT";
- break;
- case BUTTON_RIGHT:
- button_index_string = "BUTTON_RIGHT";
- break;
- case BUTTON_MIDDLE:
- button_index_string = "BUTTON_MIDDLE";
- break;
- case BUTTON_WHEEL_UP:
- button_index_string = "BUTTON_WHEEL_UP";
- break;
- case BUTTON_WHEEL_DOWN:
- button_index_string = "BUTTON_WHEEL_DOWN";
- break;
- case BUTTON_WHEEL_LEFT:
- button_index_string = "BUTTON_WHEEL_LEFT";
- break;
- case BUTTON_WHEEL_RIGHT:
- button_index_string = "BUTTON_WHEEL_RIGHT";
- break;
- case BUTTON_XBUTTON1:
- button_index_string = "BUTTON_XBUTTON1";
- break;
- case BUTTON_XBUTTON2:
- button_index_string = "BUTTON_XBUTTON2";
- break;
- default:
- button_index_string = itos(get_button_index());
- break;
- }
- return "InputEventMouseButton : button_index=" + button_index_string + ", pressed=" + (pressed ? "true" : "false") + ", position=(" + String(get_position()) + "), button_mask=" + itos(get_button_mask()) + ", doubleclick=" + (doubleclick ? "true" : "false");
-}
-
-void InputEventMouseButton::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_factor", "factor"), &InputEventMouseButton::set_factor);
- ClassDB::bind_method(D_METHOD("get_factor"), &InputEventMouseButton::get_factor);
-
- ClassDB::bind_method(D_METHOD("set_button_index", "button_index"), &InputEventMouseButton::set_button_index);
- ClassDB::bind_method(D_METHOD("get_button_index"), &InputEventMouseButton::get_button_index);
-
- ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventMouseButton::set_pressed);
- // ClassDB::bind_method(D_METHOD("is_pressed"), &InputEventMouseButton::is_pressed);
-
- ClassDB::bind_method(D_METHOD("set_doubleclick", "doubleclick"), &InputEventMouseButton::set_doubleclick);
- ClassDB::bind_method(D_METHOD("is_doubleclick"), &InputEventMouseButton::is_doubleclick);
-
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "factor"), "set_factor", "get_factor");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "button_index"), "set_button_index", "get_button_index");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "doubleclick"), "set_doubleclick", "is_doubleclick");
-}
-
-InputEventMouseButton::InputEventMouseButton() {
-
- factor = 1;
- button_index = 0;
- pressed = false;
- doubleclick = false;
-}
-
-////////////////////////////////////////////
-
-void InputEventMouseMotion::set_tilt(const Vector2 &p_tilt) {
-
- tilt = p_tilt;
-}
-
-Vector2 InputEventMouseMotion::get_tilt() const {
-
- return tilt;
-}
-
-void InputEventMouseMotion::set_pressure(float p_pressure) {
-
- pressure = p_pressure;
-}
-
-float InputEventMouseMotion::get_pressure() const {
-
- return pressure;
-}
-
-void InputEventMouseMotion::set_relative(const Vector2 &p_relative) {
-
- relative = p_relative;
-}
-
-Vector2 InputEventMouseMotion::get_relative() const {
-
- return relative;
-}
-
-void InputEventMouseMotion::set_speed(const Vector2 &p_speed) {
-
- speed = p_speed;
-}
-
-Vector2 InputEventMouseMotion::get_speed() const {
-
- return speed;
-}
-
-Ref<InputEvent> InputEventMouseMotion::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
-
- Vector2 g = get_global_position();
- Vector2 l = p_xform.xform(get_position() + p_local_ofs);
- Vector2 r = p_xform.basis_xform(get_relative());
- Vector2 s = p_xform.basis_xform(get_speed());
-
- Ref<InputEventMouseMotion> mm;
- mm.instance();
-
- mm->set_device(get_device());
-
- mm->set_modifiers_from_event(this);
-
- mm->set_position(l);
- mm->set_pressure(get_pressure());
- mm->set_tilt(get_tilt());
- mm->set_global_position(g);
-
- mm->set_button_mask(get_button_mask());
- mm->set_relative(r);
- mm->set_speed(s);
-
- return mm;
-}
-
-String InputEventMouseMotion::as_text() const {
-
- String button_mask_string = "";
- switch (get_button_mask()) {
- case BUTTON_MASK_LEFT:
- button_mask_string = "BUTTON_MASK_LEFT";
- break;
- case BUTTON_MASK_MIDDLE:
- button_mask_string = "BUTTON_MASK_MIDDLE";
- break;
- case BUTTON_MASK_RIGHT:
- button_mask_string = "BUTTON_MASK_RIGHT";
- break;
- case BUTTON_MASK_XBUTTON1:
- button_mask_string = "BUTTON_MASK_XBUTTON1";
- break;
- case BUTTON_MASK_XBUTTON2:
- button_mask_string = "BUTTON_MASK_XBUTTON2";
- break;
- default:
- button_mask_string = itos(get_button_mask());
- break;
- }
- return "InputEventMouseMotion : button_mask=" + button_mask_string + ", position=(" + String(get_position()) + "), relative=(" + String(get_relative()) + "), speed=(" + String(get_speed()) + ")";
-}
-
-bool InputEventMouseMotion::accumulate(const Ref<InputEvent> &p_event) {
-
- Ref<InputEventMouseMotion> motion = p_event;
- if (motion.is_null())
- return false;
-
- if (is_pressed() != motion->is_pressed()) {
- return false;
- }
-
- if (get_button_mask() != motion->get_button_mask()) {
- return false;
- }
-
- if (get_shift() != motion->get_shift()) {
- return false;
- }
-
- if (get_control() != motion->get_control()) {
- return false;
- }
-
- if (get_alt() != motion->get_alt()) {
- return false;
- }
-
- if (get_metakey() != motion->get_metakey()) {
- return false;
- }
-
- set_position(motion->get_position());
- set_global_position(motion->get_global_position());
- set_speed(motion->get_speed());
- relative += motion->get_relative();
-
- return true;
-}
-
-void InputEventMouseMotion::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_tilt", "tilt"), &InputEventMouseMotion::set_tilt);
- ClassDB::bind_method(D_METHOD("get_tilt"), &InputEventMouseMotion::get_tilt);
-
- ClassDB::bind_method(D_METHOD("set_pressure", "pressure"), &InputEventMouseMotion::set_pressure);
- ClassDB::bind_method(D_METHOD("get_pressure"), &InputEventMouseMotion::get_pressure);
-
- ClassDB::bind_method(D_METHOD("set_relative", "relative"), &InputEventMouseMotion::set_relative);
- ClassDB::bind_method(D_METHOD("get_relative"), &InputEventMouseMotion::get_relative);
-
- ClassDB::bind_method(D_METHOD("set_speed", "speed"), &InputEventMouseMotion::set_speed);
- ClassDB::bind_method(D_METHOD("get_speed"), &InputEventMouseMotion::get_speed);
-
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "tilt"), "set_tilt", "get_tilt");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "pressure"), "set_pressure", "get_pressure");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "relative"), "set_relative", "get_relative");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "speed"), "set_speed", "get_speed");
-}
-
-InputEventMouseMotion::InputEventMouseMotion() {
-
- pressure = 0;
-}
-
-////////////////////////////////////////
-
-void InputEventJoypadMotion::set_axis(int p_axis) {
-
- axis = p_axis;
-}
-
-int InputEventJoypadMotion::get_axis() const {
-
- return axis;
-}
-
-void InputEventJoypadMotion::set_axis_value(float p_value) {
-
- axis_value = p_value;
-}
-
-float InputEventJoypadMotion::get_axis_value() const {
-
- return axis_value;
-}
-
-bool InputEventJoypadMotion::is_pressed() const {
-
- return Math::abs(axis_value) >= 0.5f;
-}
-
-bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
-
- Ref<InputEventJoypadMotion> jm = p_event;
- if (jm.is_null())
- return false;
-
- bool match = (axis == jm->axis); // Matches even if not in the same direction, but returns a "not pressed" event.
- if (match) {
- bool same_direction = (((axis_value < 0) == (jm->axis_value < 0)) || jm->axis_value == 0);
- bool pressed = same_direction ? Math::abs(jm->get_axis_value()) >= p_deadzone : false;
- if (p_pressed != NULL)
- *p_pressed = pressed;
- if (p_strength != NULL) {
- if (pressed) {
- if (p_deadzone == 1.0f) {
- *p_strength = 1.0f;
- } else {
- *p_strength = CLAMP(Math::inverse_lerp(p_deadzone, 1.0f, Math::abs(jm->get_axis_value())), 0.0f, 1.0f);
- }
- } else {
- *p_strength = 0.0f;
- }
- }
- }
- return match;
-}
-
-String InputEventJoypadMotion::as_text() const {
-
- return "InputEventJoypadMotion : axis=" + itos(axis) + ", axis_value=" + String(Variant(axis_value));
-}
-
-void InputEventJoypadMotion::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_axis", "axis"), &InputEventJoypadMotion::set_axis);
- ClassDB::bind_method(D_METHOD("get_axis"), &InputEventJoypadMotion::get_axis);
-
- ClassDB::bind_method(D_METHOD("set_axis_value", "axis_value"), &InputEventJoypadMotion::set_axis_value);
- ClassDB::bind_method(D_METHOD("get_axis_value"), &InputEventJoypadMotion::get_axis_value);
-
- ADD_PROPERTY(PropertyInfo(Variant::INT, "axis"), "set_axis", "get_axis");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "axis_value"), "set_axis_value", "get_axis_value");
-}
-
-InputEventJoypadMotion::InputEventJoypadMotion() {
-
- axis = 0;
- axis_value = 0;
-}
-/////////////////////////////////
-
-void InputEventJoypadButton::set_button_index(int p_index) {
-
- button_index = p_index;
-}
-
-int InputEventJoypadButton::get_button_index() const {
-
- return button_index;
-}
-
-void InputEventJoypadButton::set_pressed(bool p_pressed) {
-
- pressed = p_pressed;
-}
-bool InputEventJoypadButton::is_pressed() const {
-
- return pressed;
-}
-
-void InputEventJoypadButton::set_pressure(float p_pressure) {
-
- pressure = p_pressure;
-}
-float InputEventJoypadButton::get_pressure() const {
-
- return pressure;
-}
-
-bool InputEventJoypadButton::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
-
- Ref<InputEventJoypadButton> jb = p_event;
- if (jb.is_null())
- return false;
-
- bool match = button_index == jb->button_index;
- if (match) {
- if (p_pressed != NULL)
- *p_pressed = jb->is_pressed();
- if (p_strength != NULL)
- *p_strength = (p_pressed != NULL && *p_pressed) ? 1.0f : 0.0f;
- }
-
- return match;
-}
-
-bool InputEventJoypadButton::shortcut_match(const Ref<InputEvent> &p_event) const {
-
- Ref<InputEventJoypadButton> button = p_event;
- if (button.is_null())
- return false;
-
- return button_index == button->button_index;
-}
-
-String InputEventJoypadButton::as_text() const {
-
- return "InputEventJoypadButton : button_index=" + itos(button_index) + ", pressed=" + (pressed ? "true" : "false") + ", pressure=" + String(Variant(pressure));
-}
-
-void InputEventJoypadButton::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_button_index", "button_index"), &InputEventJoypadButton::set_button_index);
- ClassDB::bind_method(D_METHOD("get_button_index"), &InputEventJoypadButton::get_button_index);
-
- ClassDB::bind_method(D_METHOD("set_pressure", "pressure"), &InputEventJoypadButton::set_pressure);
- ClassDB::bind_method(D_METHOD("get_pressure"), &InputEventJoypadButton::get_pressure);
-
- ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventJoypadButton::set_pressed);
- // ClassDB::bind_method(D_METHOD("is_pressed"), &InputEventJoypadButton::is_pressed);
-
- ADD_PROPERTY(PropertyInfo(Variant::INT, "button_index"), "set_button_index", "get_button_index");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "pressure"), "set_pressure", "get_pressure");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
-}
-
-InputEventJoypadButton::InputEventJoypadButton() {
-
- button_index = 0;
- pressure = 0;
- pressed = false;
-}
-
-//////////////////////////////////////////////
-
-void InputEventScreenTouch::set_index(int p_index) {
-
- index = p_index;
-}
-int InputEventScreenTouch::get_index() const {
-
- return index;
-}
-
-void InputEventScreenTouch::set_position(const Vector2 &p_pos) {
-
- pos = p_pos;
-}
-Vector2 InputEventScreenTouch::get_position() const {
-
- return pos;
-}
-
-void InputEventScreenTouch::set_pressed(bool p_pressed) {
-
- pressed = p_pressed;
-}
-bool InputEventScreenTouch::is_pressed() const {
-
- return pressed;
-}
-
-Ref<InputEvent> InputEventScreenTouch::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
-
- Ref<InputEventScreenTouch> st;
- st.instance();
- st->set_device(get_device());
- st->set_index(index);
- st->set_position(p_xform.xform(pos + p_local_ofs));
- st->set_pressed(pressed);
-
- return st;
-}
-
-String InputEventScreenTouch::as_text() const {
-
- return "InputEventScreenTouch : index=" + itos(index) + ", pressed=" + (pressed ? "true" : "false") + ", position=(" + String(get_position()) + ")";
-}
-
-void InputEventScreenTouch::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_index", "index"), &InputEventScreenTouch::set_index);
- ClassDB::bind_method(D_METHOD("get_index"), &InputEventScreenTouch::get_index);
-
- ClassDB::bind_method(D_METHOD("set_position", "position"), &InputEventScreenTouch::set_position);
- ClassDB::bind_method(D_METHOD("get_position"), &InputEventScreenTouch::get_position);
-
- ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventScreenTouch::set_pressed);
- //ClassDB::bind_method(D_METHOD("is_pressed"),&InputEventScreenTouch::is_pressed);
-
- ADD_PROPERTY(PropertyInfo(Variant::INT, "index"), "set_index", "get_index");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
-}
-
-InputEventScreenTouch::InputEventScreenTouch() {
-
- index = 0;
- pressed = false;
-}
-
-/////////////////////////////
-
-void InputEventScreenDrag::set_index(int p_index) {
-
- index = p_index;
-}
-
-int InputEventScreenDrag::get_index() const {
-
- return index;
-}
-
-void InputEventScreenDrag::set_position(const Vector2 &p_pos) {
-
- pos = p_pos;
-}
-Vector2 InputEventScreenDrag::get_position() const {
-
- return pos;
-}
-
-void InputEventScreenDrag::set_relative(const Vector2 &p_relative) {
-
- relative = p_relative;
-}
-Vector2 InputEventScreenDrag::get_relative() const {
-
- return relative;
-}
-
-void InputEventScreenDrag::set_speed(const Vector2 &p_speed) {
-
- speed = p_speed;
-}
-Vector2 InputEventScreenDrag::get_speed() const {
-
- return speed;
-}
-
-Ref<InputEvent> InputEventScreenDrag::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
-
- Ref<InputEventScreenDrag> sd;
-
- sd.instance();
-
- sd->set_device(get_device());
-
- sd->set_index(index);
- sd->set_position(p_xform.xform(pos + p_local_ofs));
- sd->set_relative(p_xform.basis_xform(relative));
- sd->set_speed(p_xform.basis_xform(speed));
-
- return sd;
-}
-
-String InputEventScreenDrag::as_text() const {
-
- return "InputEventScreenDrag : index=" + itos(index) + ", position=(" + String(get_position()) + "), relative=(" + String(get_relative()) + "), speed=(" + String(get_speed()) + ")";
-}
-
-void InputEventScreenDrag::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_index", "index"), &InputEventScreenDrag::set_index);
- ClassDB::bind_method(D_METHOD("get_index"), &InputEventScreenDrag::get_index);
-
- ClassDB::bind_method(D_METHOD("set_position", "position"), &InputEventScreenDrag::set_position);
- ClassDB::bind_method(D_METHOD("get_position"), &InputEventScreenDrag::get_position);
-
- ClassDB::bind_method(D_METHOD("set_relative", "relative"), &InputEventScreenDrag::set_relative);
- ClassDB::bind_method(D_METHOD("get_relative"), &InputEventScreenDrag::get_relative);
-
- ClassDB::bind_method(D_METHOD("set_speed", "speed"), &InputEventScreenDrag::set_speed);
- ClassDB::bind_method(D_METHOD("get_speed"), &InputEventScreenDrag::get_speed);
-
- ADD_PROPERTY(PropertyInfo(Variant::INT, "index"), "set_index", "get_index");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "relative"), "set_relative", "get_relative");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "speed"), "set_speed", "get_speed");
-}
-
-InputEventScreenDrag::InputEventScreenDrag() {
-
- index = 0;
-}
-/////////////////////////////
-
-void InputEventAction::set_action(const StringName &p_action) {
-
- action = p_action;
-}
-StringName InputEventAction::get_action() const {
-
- return action;
-}
-
-void InputEventAction::set_pressed(bool p_pressed) {
-
- pressed = p_pressed;
-}
-bool InputEventAction::is_pressed() const {
-
- return pressed;
-}
-
-void InputEventAction::set_strength(float p_strength) {
- strength = CLAMP(p_strength, 0.0f, 1.0f);
-}
-
-float InputEventAction::get_strength() const {
- return strength;
-}
-
-bool InputEventAction::shortcut_match(const Ref<InputEvent> &p_event) const {
- if (p_event.is_null())
- return false;
-
- return p_event->is_action(action);
-}
-
-bool InputEventAction::is_action(const StringName &p_action) const {
-
- return action == p_action;
-}
-
-bool InputEventAction::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
-
- Ref<InputEventAction> act = p_event;
- if (act.is_null())
- return false;
-
- bool match = action == act->action;
- if (match) {
- if (p_pressed != NULL)
- *p_pressed = act->pressed;
- if (p_strength != NULL)
- *p_strength = (p_pressed != NULL && *p_pressed) ? 1.0f : 0.0f;
- }
- return match;
-}
-
-String InputEventAction::as_text() const {
-
- return "InputEventAction : action=" + action + ", pressed=(" + (pressed ? "true" : "false");
-}
-
-void InputEventAction::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_action", "action"), &InputEventAction::set_action);
- ClassDB::bind_method(D_METHOD("get_action"), &InputEventAction::get_action);
-
- ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventAction::set_pressed);
- //ClassDB::bind_method(D_METHOD("is_pressed"), &InputEventAction::is_pressed);
-
- ClassDB::bind_method(D_METHOD("set_strength", "strength"), &InputEventAction::set_strength);
- ClassDB::bind_method(D_METHOD("get_strength"), &InputEventAction::get_strength);
-
- // ClassDB::bind_method(D_METHOD("is_action", "name"), &InputEventAction::is_action);
-
- ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "action"), "set_action", "get_action");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_strength", "get_strength");
-}
-
-InputEventAction::InputEventAction() {
- pressed = false;
- strength = 1.0f;
-}
-/////////////////////////////
-
-void InputEventGesture::set_position(const Vector2 &p_pos) {
-
- pos = p_pos;
-}
-
-void InputEventGesture::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_position", "position"), &InputEventGesture::set_position);
- ClassDB::bind_method(D_METHOD("get_position"), &InputEventGesture::get_position);
-
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position");
-}
-
-Vector2 InputEventGesture::get_position() const {
-
- return pos;
-}
-/////////////////////////////
-
-void InputEventMagnifyGesture::set_factor(real_t p_factor) {
-
- factor = p_factor;
-}
-
-real_t InputEventMagnifyGesture::get_factor() const {
-
- return factor;
-}
-
-Ref<InputEvent> InputEventMagnifyGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
-
- Ref<InputEventMagnifyGesture> ev;
- ev.instance();
-
- ev->set_device(get_device());
- ev->set_modifiers_from_event(this);
-
- ev->set_position(p_xform.xform(get_position() + p_local_ofs));
- ev->set_factor(get_factor());
-
- return ev;
-}
-
-String InputEventMagnifyGesture::as_text() const {
-
- return "InputEventMagnifyGesture : factor=" + rtos(get_factor()) + ", position=(" + String(get_position()) + ")";
-}
-
-void InputEventMagnifyGesture::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_factor", "factor"), &InputEventMagnifyGesture::set_factor);
- ClassDB::bind_method(D_METHOD("get_factor"), &InputEventMagnifyGesture::get_factor);
-
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "factor"), "set_factor", "get_factor");
-}
-
-InputEventMagnifyGesture::InputEventMagnifyGesture() {
-
- factor = 1.0;
-}
-/////////////////////////////
-
-void InputEventPanGesture::set_delta(const Vector2 &p_delta) {
-
- delta = p_delta;
-}
-
-Vector2 InputEventPanGesture::get_delta() const {
- return delta;
-}
-
-Ref<InputEvent> InputEventPanGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
-
- Ref<InputEventPanGesture> ev;
- ev.instance();
-
- ev->set_device(get_device());
- ev->set_modifiers_from_event(this);
-
- ev->set_position(p_xform.xform(get_position() + p_local_ofs));
- ev->set_delta(get_delta());
-
- return ev;
-}
-
-String InputEventPanGesture::as_text() const {
-
- return "InputEventPanGesture : delta=(" + String(get_delta()) + "), position=(" + String(get_position()) + ")";
-}
-
-void InputEventPanGesture::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_delta", "delta"), &InputEventPanGesture::set_delta);
- ClassDB::bind_method(D_METHOD("get_delta"), &InputEventPanGesture::get_delta);
-
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "delta"), "set_delta", "get_delta");
-}
-
-InputEventPanGesture::InputEventPanGesture() {
-
- delta = Vector2(0, 0);
-}
-/////////////////////////////
-
-void InputEventMIDI::set_channel(const int p_channel) {
-
- channel = p_channel;
-}
-
-int InputEventMIDI::get_channel() const {
- return channel;
-}
-
-void InputEventMIDI::set_message(const int p_message) {
-
- message = p_message;
-}
-
-int InputEventMIDI::get_message() const {
- return message;
-}
-
-void InputEventMIDI::set_pitch(const int p_pitch) {
-
- pitch = p_pitch;
-}
-
-int InputEventMIDI::get_pitch() const {
- return pitch;
-}
-
-void InputEventMIDI::set_velocity(const int p_velocity) {
-
- velocity = p_velocity;
-}
-
-int InputEventMIDI::get_velocity() const {
- return velocity;
-}
-
-void InputEventMIDI::set_instrument(const int p_instrument) {
-
- instrument = p_instrument;
-}
-
-int InputEventMIDI::get_instrument() const {
- return instrument;
-}
-
-void InputEventMIDI::set_pressure(const int p_pressure) {
-
- pressure = p_pressure;
-}
-
-int InputEventMIDI::get_pressure() const {
- return pressure;
-}
-
-void InputEventMIDI::set_controller_number(const int p_controller_number) {
-
- controller_number = p_controller_number;
-}
-
-int InputEventMIDI::get_controller_number() const {
- return controller_number;
-}
-
-void InputEventMIDI::set_controller_value(const int p_controller_value) {
-
- controller_value = p_controller_value;
-}
-
-int InputEventMIDI::get_controller_value() const {
- return controller_value;
-}
-
-String InputEventMIDI::as_text() const {
-
- return "InputEventMIDI : channel=(" + itos(get_channel()) + "), message=(" + itos(get_message()) + ")";
-}
-
-void InputEventMIDI::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_channel", "channel"), &InputEventMIDI::set_channel);
- ClassDB::bind_method(D_METHOD("get_channel"), &InputEventMIDI::get_channel);
- ClassDB::bind_method(D_METHOD("set_message", "message"), &InputEventMIDI::set_message);
- ClassDB::bind_method(D_METHOD("get_message"), &InputEventMIDI::get_message);
- ClassDB::bind_method(D_METHOD("set_pitch", "pitch"), &InputEventMIDI::set_pitch);
- ClassDB::bind_method(D_METHOD("get_pitch"), &InputEventMIDI::get_pitch);
- ClassDB::bind_method(D_METHOD("set_velocity", "velocity"), &InputEventMIDI::set_velocity);
- ClassDB::bind_method(D_METHOD("get_velocity"), &InputEventMIDI::get_velocity);
- ClassDB::bind_method(D_METHOD("set_instrument", "instrument"), &InputEventMIDI::set_instrument);
- ClassDB::bind_method(D_METHOD("get_instrument"), &InputEventMIDI::get_instrument);
- ClassDB::bind_method(D_METHOD("set_pressure", "pressure"), &InputEventMIDI::set_pressure);
- ClassDB::bind_method(D_METHOD("get_pressure"), &InputEventMIDI::get_pressure);
- ClassDB::bind_method(D_METHOD("set_controller_number", "controller_number"), &InputEventMIDI::set_controller_number);
- ClassDB::bind_method(D_METHOD("get_controller_number"), &InputEventMIDI::get_controller_number);
- ClassDB::bind_method(D_METHOD("set_controller_value", "controller_value"), &InputEventMIDI::set_controller_value);
- ClassDB::bind_method(D_METHOD("get_controller_value"), &InputEventMIDI::get_controller_value);
-
- ADD_PROPERTY(PropertyInfo(Variant::INT, "channel"), "set_channel", "get_channel");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "message"), "set_message", "get_message");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "pitch"), "set_pitch", "get_pitch");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "velocity"), "set_velocity", "get_velocity");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "instrument"), "set_instrument", "get_instrument");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "pressure"), "set_pressure", "get_pressure");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_number"), "set_controller_number", "get_controller_number");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_value"), "set_controller_value", "get_controller_value");
-}
-
-InputEventMIDI::InputEventMIDI() {
-
- channel = 0;
- message = 0;
- pitch = 0;
- velocity = 0;
- instrument = 0;
- pressure = 0;
- controller_number = 0;
- controller_value = 0;
-}
diff --git a/core/os/input_event.h b/core/os/input_event.h
deleted file mode 100644
index 21549d811f..0000000000
--- a/core/os/input_event.h
+++ /dev/null
@@ -1,625 +0,0 @@
-/*************************************************************************/
-/* input_event.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* 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. */
-/*************************************************************************/
-
-#ifndef INPUT_EVENT_H
-#define INPUT_EVENT_H
-
-#include "core/math/transform_2d.h"
-#include "core/os/copymem.h"
-#include "core/resource.h"
-#include "core/typedefs.h"
-#include "core/ustring.h"
-
-/**
- * Input Event classes. These are used in the main loop.
- * The events are pretty obvious.
- */
-
-enum ButtonList {
- BUTTON_LEFT = 1,
- BUTTON_RIGHT = 2,
- BUTTON_MIDDLE = 3,
- BUTTON_WHEEL_UP = 4,
- BUTTON_WHEEL_DOWN = 5,
- BUTTON_WHEEL_LEFT = 6,
- BUTTON_WHEEL_RIGHT = 7,
- BUTTON_XBUTTON1 = 8,
- BUTTON_XBUTTON2 = 9,
- BUTTON_MASK_LEFT = (1 << (BUTTON_LEFT - 1)),
- BUTTON_MASK_RIGHT = (1 << (BUTTON_RIGHT - 1)),
- BUTTON_MASK_MIDDLE = (1 << (BUTTON_MIDDLE - 1)),
- BUTTON_MASK_XBUTTON1 = (1 << (BUTTON_XBUTTON1 - 1)),
- BUTTON_MASK_XBUTTON2 = (1 << (BUTTON_XBUTTON2 - 1))
-};
-
-enum JoystickList {
-
- JOY_BUTTON_0 = 0,
- JOY_BUTTON_1 = 1,
- JOY_BUTTON_2 = 2,
- JOY_BUTTON_3 = 3,
- JOY_BUTTON_4 = 4,
- JOY_BUTTON_5 = 5,
- JOY_BUTTON_6 = 6,
- JOY_BUTTON_7 = 7,
- JOY_BUTTON_8 = 8,
- JOY_BUTTON_9 = 9,
- JOY_BUTTON_10 = 10,
- JOY_BUTTON_11 = 11,
- JOY_BUTTON_12 = 12,
- JOY_BUTTON_13 = 13,
- JOY_BUTTON_14 = 14,
- JOY_BUTTON_15 = 15,
- JOY_BUTTON_MAX = 16,
-
- JOY_L = JOY_BUTTON_4,
- JOY_R = JOY_BUTTON_5,
- JOY_L2 = JOY_BUTTON_6,
- JOY_R2 = JOY_BUTTON_7,
- JOY_L3 = JOY_BUTTON_8,
- JOY_R3 = JOY_BUTTON_9,
- JOY_SELECT = JOY_BUTTON_10,
- JOY_START = JOY_BUTTON_11,
- JOY_DPAD_UP = JOY_BUTTON_12,
- JOY_DPAD_DOWN = JOY_BUTTON_13,
- JOY_DPAD_LEFT = JOY_BUTTON_14,
- JOY_DPAD_RIGHT = JOY_BUTTON_15,
-
- JOY_SONY_CIRCLE = JOY_BUTTON_1,
- JOY_SONY_X = JOY_BUTTON_0,
- JOY_SONY_SQUARE = JOY_BUTTON_2,
- JOY_SONY_TRIANGLE = JOY_BUTTON_3,
-
- JOY_XBOX_A = JOY_BUTTON_0,
- JOY_XBOX_B = JOY_BUTTON_1,
- JOY_XBOX_X = JOY_BUTTON_2,
- JOY_XBOX_Y = JOY_BUTTON_3,
-
- JOY_DS_A = JOY_BUTTON_1,
- JOY_DS_B = JOY_BUTTON_0,
- JOY_DS_X = JOY_BUTTON_3,
- JOY_DS_Y = JOY_BUTTON_2,
-
- JOY_WII_C = JOY_BUTTON_5,
- JOY_WII_Z = JOY_BUTTON_6,
-
- JOY_WII_MINUS = JOY_BUTTON_10,
- JOY_WII_PLUS = JOY_BUTTON_11,
-
- JOY_VR_GRIP = JOY_BUTTON_2,
- JOY_VR_PAD = JOY_BUTTON_14,
- JOY_VR_TRIGGER = JOY_BUTTON_15,
-
- JOY_OCULUS_AX = JOY_BUTTON_7,
- JOY_OCULUS_BY = JOY_BUTTON_1,
- JOY_OCULUS_MENU = JOY_BUTTON_3,
-
- JOY_OPENVR_MENU = JOY_BUTTON_1,
-
- // end of history
-
- JOY_AXIS_0 = 0,
- JOY_AXIS_1 = 1,
- JOY_AXIS_2 = 2,
- JOY_AXIS_3 = 3,
- JOY_AXIS_4 = 4,
- JOY_AXIS_5 = 5,
- JOY_AXIS_6 = 6,
- JOY_AXIS_7 = 7,
- JOY_AXIS_8 = 8,
- JOY_AXIS_9 = 9,
- JOY_AXIS_MAX = 10,
-
- JOY_ANALOG_LX = JOY_AXIS_0,
- JOY_ANALOG_LY = JOY_AXIS_1,
-
- JOY_ANALOG_RX = JOY_AXIS_2,
- JOY_ANALOG_RY = JOY_AXIS_3,
-
- JOY_ANALOG_L2 = JOY_AXIS_6,
- JOY_ANALOG_R2 = JOY_AXIS_7,
-
- JOY_VR_ANALOG_TRIGGER = JOY_AXIS_2,
- JOY_VR_ANALOG_GRIP = JOY_AXIS_4,
-
- JOY_OPENVR_TOUCHPADX = JOY_AXIS_0,
- JOY_OPENVR_TOUCHPADY = JOY_AXIS_1,
-};
-
-enum MidiMessageList {
- MIDI_MESSAGE_NOTE_OFF = 0x8,
- MIDI_MESSAGE_NOTE_ON = 0x9,
- MIDI_MESSAGE_AFTERTOUCH = 0xA,
- MIDI_MESSAGE_CONTROL_CHANGE = 0xB,
- MIDI_MESSAGE_PROGRAM_CHANGE = 0xC,
- MIDI_MESSAGE_CHANNEL_PRESSURE = 0xD,
- MIDI_MESSAGE_PITCH_BEND = 0xE,
-};
-
-/**
- * Input Modifier Status
- * for keyboard/mouse events.
- */
-
-class InputEvent : public Resource {
- GDCLASS(InputEvent, Resource);
-
- int device;
-
-protected:
- static void _bind_methods();
-
-public:
- static const int DEVICE_ID_TOUCH_MOUSE;
- static const int DEVICE_ID_INTERNAL;
-
- void set_device(int p_device);
- int get_device() const;
-
- bool is_action(const StringName &p_action) const;
- bool is_action_pressed(const StringName &p_action, bool p_allow_echo = false) const;
- bool is_action_released(const StringName &p_action) const;
- float get_action_strength(const StringName &p_action) const;
-
- // To be removed someday, since they do not make sense for all events
- virtual bool is_pressed() const;
- virtual bool is_echo() const;
- // ...-.
-
- virtual String as_text() const;
-
- virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
-
- virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const;
- virtual bool shortcut_match(const Ref<InputEvent> &p_event) const;
- virtual bool is_action_type() const;
-
- virtual bool accumulate(const Ref<InputEvent> &p_event) { return false; }
- InputEvent();
-};
-
-class InputEventWithModifiers : public InputEvent {
- GDCLASS(InputEventWithModifiers, InputEvent);
-
- bool shift;
- bool alt;
-#ifdef APPLE_STYLE_KEYS
- union {
- bool command;
- bool meta; //< windows/mac key
- };
-
- bool control;
-#else
- union {
- bool command; //< windows/mac key
- bool control;
- };
- bool meta; //< windows/mac key
-
-#endif
-
-protected:
- static void _bind_methods();
-
-public:
- void set_shift(bool p_enabled);
- bool get_shift() const;
-
- void set_alt(bool p_enabled);
- bool get_alt() const;
-
- void set_control(bool p_enabled);
- bool get_control() const;
-
- void set_metakey(bool p_enabled);
- bool get_metakey() const;
-
- void set_command(bool p_enabled);
- bool get_command() const;
-
- void set_modifiers_from_event(const InputEventWithModifiers *event);
-
- InputEventWithModifiers();
-};
-
-class InputEventKey : public InputEventWithModifiers {
-
- GDCLASS(InputEventKey, InputEventWithModifiers);
-
- bool pressed; /// otherwise release
-
- uint32_t keycode; ///< check keyboard.h , KeyCode enum, without modifier masks
- uint32_t physical_keycode;
- uint32_t unicode; ///unicode
-
- bool echo; /// true if this is an echo key
-
-protected:
- static void _bind_methods();
-
-public:
- void set_pressed(bool p_pressed);
- virtual bool is_pressed() const;
-
- void set_keycode(uint32_t p_keycode);
- uint32_t get_keycode() const;
-
- void set_physical_keycode(uint32_t p_keycode);
- uint32_t get_physical_keycode() const;
-
- void set_unicode(uint32_t p_unicode);
- uint32_t get_unicode() const;
-
- void set_echo(bool p_enable);
- virtual bool is_echo() const;
-
- uint32_t get_keycode_with_modifiers() const;
- uint32_t get_physical_keycode_with_modifiers() const;
-
- virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const;
- virtual bool shortcut_match(const Ref<InputEvent> &p_event) const;
-
- virtual bool is_action_type() const { return true; }
-
- virtual String as_text() const;
-
- InputEventKey();
-};
-
-class InputEventMouse : public InputEventWithModifiers {
-
- GDCLASS(InputEventMouse, InputEventWithModifiers);
-
- int button_mask;
-
- Vector2 pos;
- Vector2 global_pos;
-
-protected:
- static void _bind_methods();
-
-public:
- void set_button_mask(int p_mask);
- int get_button_mask() const;
-
- void set_position(const Vector2 &p_pos);
- Vector2 get_position() const;
-
- void set_global_position(const Vector2 &p_global_pos);
- Vector2 get_global_position() const;
-
- InputEventMouse();
-};
-
-class InputEventMouseButton : public InputEventMouse {
-
- GDCLASS(InputEventMouseButton, InputEventMouse);
-
- float factor;
- int button_index;
- bool pressed; //otherwise released
- bool doubleclick; //last even less than doubleclick time
-
-protected:
- static void _bind_methods();
-
-public:
- void set_factor(float p_factor);
- float get_factor();
-
- void set_button_index(int p_index);
- int get_button_index() const;
-
- void set_pressed(bool p_pressed);
- virtual bool is_pressed() const;
-
- void set_doubleclick(bool p_doubleclick);
- bool is_doubleclick() const;
-
- virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
- virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const;
-
- virtual bool is_action_type() const { return true; }
- virtual String as_text() const;
-
- InputEventMouseButton();
-};
-
-class InputEventMouseMotion : public InputEventMouse {
-
- GDCLASS(InputEventMouseMotion, InputEventMouse);
-
- Vector2 tilt;
- float pressure;
- Vector2 relative;
- Vector2 speed;
-
-protected:
- static void _bind_methods();
-
-public:
- void set_tilt(const Vector2 &p_tilt);
- Vector2 get_tilt() const;
-
- void set_pressure(float p_pressure);
- float get_pressure() const;
-
- void set_relative(const Vector2 &p_relative);
- Vector2 get_relative() const;
-
- void set_speed(const Vector2 &p_speed);
- Vector2 get_speed() const;
-
- virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
- virtual String as_text() const;
-
- virtual bool accumulate(const Ref<InputEvent> &p_event);
-
- InputEventMouseMotion();
-};
-
-class InputEventJoypadMotion : public InputEvent {
-
- GDCLASS(InputEventJoypadMotion, InputEvent);
- int axis; ///< Joypad axis
- float axis_value; ///< -1 to 1
-
-protected:
- static void _bind_methods();
-
-public:
- void set_axis(int p_axis);
- int get_axis() const;
-
- void set_axis_value(float p_value);
- float get_axis_value() const;
-
- virtual bool is_pressed() const;
-
- virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const;
-
- virtual bool is_action_type() const { return true; }
- virtual String as_text() const;
-
- InputEventJoypadMotion();
-};
-
-class InputEventJoypadButton : public InputEvent {
- GDCLASS(InputEventJoypadButton, InputEvent);
-
- int button_index;
- bool pressed;
- float pressure; //0 to 1
-protected:
- static void _bind_methods();
-
-public:
- void set_button_index(int p_index);
- int get_button_index() const;
-
- void set_pressed(bool p_pressed);
- virtual bool is_pressed() const;
-
- void set_pressure(float p_pressure);
- float get_pressure() const;
-
- virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const;
- virtual bool shortcut_match(const Ref<InputEvent> &p_event) const;
-
- virtual bool is_action_type() const { return true; }
- virtual String as_text() const;
-
- InputEventJoypadButton();
-};
-
-class InputEventScreenTouch : public InputEvent {
- GDCLASS(InputEventScreenTouch, InputEvent);
- int index;
- Vector2 pos;
- bool pressed;
-
-protected:
- static void _bind_methods();
-
-public:
- void set_index(int p_index);
- int get_index() const;
-
- void set_position(const Vector2 &p_pos);
- Vector2 get_position() const;
-
- void set_pressed(bool p_pressed);
- virtual bool is_pressed() const;
-
- virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
- virtual String as_text() const;
-
- InputEventScreenTouch();
-};
-
-class InputEventScreenDrag : public InputEvent {
-
- GDCLASS(InputEventScreenDrag, InputEvent);
- int index;
- Vector2 pos;
- Vector2 relative;
- Vector2 speed;
-
-protected:
- static void _bind_methods();
-
-public:
- void set_index(int p_index);
- int get_index() const;
-
- void set_position(const Vector2 &p_pos);
- Vector2 get_position() const;
-
- void set_relative(const Vector2 &p_relative);
- Vector2 get_relative() const;
-
- void set_speed(const Vector2 &p_speed);
- Vector2 get_speed() const;
-
- virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
- virtual String as_text() const;
-
- InputEventScreenDrag();
-};
-
-class InputEventAction : public InputEvent {
-
- GDCLASS(InputEventAction, InputEvent);
-
- StringName action;
- bool pressed;
- float strength;
-
-protected:
- static void _bind_methods();
-
-public:
- void set_action(const StringName &p_action);
- StringName get_action() const;
-
- void set_pressed(bool p_pressed);
- virtual bool is_pressed() const;
-
- void set_strength(float p_strength);
- float get_strength() const;
-
- virtual bool is_action(const StringName &p_action) const;
-
- virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const;
-
- virtual bool shortcut_match(const Ref<InputEvent> &p_event) const;
- virtual bool is_action_type() const { return true; }
- virtual String as_text() const;
-
- InputEventAction();
-};
-
-class InputEventGesture : public InputEventWithModifiers {
-
- GDCLASS(InputEventGesture, InputEventWithModifiers);
-
- Vector2 pos;
-
-protected:
- static void _bind_methods();
-
-public:
- void set_position(const Vector2 &p_pos);
- Vector2 get_position() const;
-};
-
-class InputEventMagnifyGesture : public InputEventGesture {
-
- GDCLASS(InputEventMagnifyGesture, InputEventGesture);
- real_t factor;
-
-protected:
- static void _bind_methods();
-
-public:
- void set_factor(real_t p_factor);
- real_t get_factor() const;
-
- virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
- virtual String as_text() const;
-
- InputEventMagnifyGesture();
-};
-
-class InputEventPanGesture : public InputEventGesture {
-
- GDCLASS(InputEventPanGesture, InputEventGesture);
- Vector2 delta;
-
-protected:
- static void _bind_methods();
-
-public:
- void set_delta(const Vector2 &p_delta);
- Vector2 get_delta() const;
-
- virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
- virtual String as_text() const;
-
- InputEventPanGesture();
-};
-
-class InputEventMIDI : public InputEvent {
- GDCLASS(InputEventMIDI, InputEvent);
-
- int channel;
- int message;
- int pitch;
- int velocity;
- int instrument;
- int pressure;
- int controller_number;
- int controller_value;
-
-protected:
- static void _bind_methods();
-
-public:
- void set_channel(const int p_channel);
- int get_channel() const;
-
- void set_message(const int p_message);
- int get_message() const;
-
- void set_pitch(const int p_pitch);
- int get_pitch() const;
-
- void set_velocity(const int p_velocity);
- int get_velocity() const;
-
- void set_instrument(const int p_instrument);
- int get_instrument() const;
-
- void set_pressure(const int p_pressure);
- int get_pressure() const;
-
- void set_controller_number(const int p_controller_number);
- int get_controller_number() const;
-
- void set_controller_value(const int p_controller_value);
- int get_controller_value() const;
-
- virtual String as_text() const;
-
- InputEventMIDI();
-};
-
-#endif // INPUT_EVENT_H
diff --git a/core/os/main_loop.h b/core/os/main_loop.h
index 3fdfb77af2..2b7ec8fc5d 100644
--- a/core/os/main_loop.h
+++ b/core/os/main_loop.h
@@ -31,7 +31,7 @@
#ifndef MAIN_LOOP_H
#define MAIN_LOOP_H
-#include "core/os/input_event.h"
+#include "core/input/input_event.h"
#include "core/reference.h"
#include "core/script_language.h"
diff --git a/core/os/midi_driver.cpp b/core/os/midi_driver.cpp
index 6ebec50ff0..68c3bf3912 100644
--- a/core/os/midi_driver.cpp
+++ b/core/os/midi_driver.cpp
@@ -30,8 +30,8 @@
#include "midi_driver.h"
+#include "core/input/input.h"
#include "core/os/os.h"
-#include "main/input_default.h"
uint8_t MIDIDriver::last_received_message = 0x00;
MIDIDriver *MIDIDriver::singleton = NULL;
@@ -117,7 +117,7 @@ void MIDIDriver::receive_input_packet(uint64_t timestamp, uint8_t *data, uint32_
break;
}
- InputDefault *id = Object::cast_to<InputDefault>(Input::get_singleton());
+ Input *id = Input::get_singleton();
id->parse_input_event(event);
}
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 9a65d537ac..b9c0040627 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -30,9 +30,9 @@
#include "os.h"
+#include "core/input/input.h"
#include "core/os/dir_access.h"
#include "core/os/file_access.h"
-#include "core/os/input.h"
#include "core/os/midi_driver.h"
#include "core/project_settings.h"
#include "core/version_generated.gen.h"