summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-05-20 12:38:03 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-05-20 17:05:38 -0300
commit5b3709d3096df737b8bb2344446be818b0389bfe (patch)
tree649a0989b1494f3c4687d59e503310f4e6bbeb40 /core
parent93f9a83062dbe74474a4a7928758c5cf5588238e (diff)
Removal of InputEvent as built-in Variant type..
this might cause bugs I haven't found yet..
Diffstat (limited to 'core')
-rw-r--r--core/global_config.cpp69
-rw-r--r--core/global_constants.cpp6
-rw-r--r--core/input_map.cpp138
-rw-r--r--core/input_map.h18
-rw-r--r--core/io/marshalls.cpp137
-rw-r--r--core/io/resource_format_binary.cpp14
-rw-r--r--core/method_bind.h1
-rw-r--r--core/method_ptrcall.h1
-rw-r--r--core/os/input.h4
-rw-r--r--core/os/input_event.cpp981
-rw-r--r--core/os/input_event.h315
-rw-r--r--core/os/main_loop.cpp4
-rw-r--r--core/os/main_loop.h2
-rw-r--r--core/packed_data_container.cpp1
-rw-r--r--core/register_core_types.cpp12
-rw-r--r--core/variant.cpp41
-rw-r--r--core/variant.h6
-rw-r--r--core/variant_call.cpp26
-rw-r--r--core/variant_op.cpp714
-rw-r--r--core/variant_parser.cpp181
20 files changed, 1149 insertions, 1522 deletions
diff --git a/core/global_config.cpp b/core/global_config.cpp
index 81b923f01e..896384d9c8 100644
--- a/core/global_config.cpp
+++ b/core/global_config.cpp
@@ -846,10 +846,8 @@ GlobalConfig::GlobalConfig() {
registering_order = true;
Array va;
- InputEvent key;
- key.type = InputEvent::KEY;
- InputEvent joyb;
- joyb.type = InputEvent::JOYPAD_BUTTON;
+ Ref<InputEventKey> key;
+ Ref<InputEventJoypadButton> joyb;
GLOBAL_DEF("application/name", "");
GLOBAL_DEF("application/main_scene", "");
@@ -858,87 +856,106 @@ GlobalConfig::GlobalConfig() {
GLOBAL_DEF("application/disable_stderr", false);
GLOBAL_DEF("application/use_shared_user_dir", true);
- key.key.scancode = KEY_RETURN;
+ key.instance();
+ key->set_scancode(KEY_RETURN);
va.push_back(key);
- key.key.scancode = KEY_ENTER;
+ key.instance();
+ key->set_scancode(KEY_ENTER);
va.push_back(key);
- key.key.scancode = KEY_SPACE;
+ key.instance();
+ key->set_scancode(KEY_SPACE);
va.push_back(key);
- joyb.joy_button.button_index = JOY_BUTTON_0;
+ joyb.instance();
+ joyb->set_button_index(JOY_BUTTON_0);
va.push_back(joyb);
GLOBAL_DEF("input/ui_accept", va);
input_presets.push_back("input/ui_accept");
va = Array();
- key.key.scancode = KEY_SPACE;
+ key.instance();
+ key->set_scancode(KEY_SPACE);
va.push_back(key);
- joyb.joy_button.button_index = JOY_BUTTON_3;
+ joyb.instance();
+ joyb->set_button_index(JOY_BUTTON_3);
va.push_back(joyb);
GLOBAL_DEF("input/ui_select", va);
input_presets.push_back("input/ui_select");
va = Array();
- key.key.scancode = KEY_ESCAPE;
+ key.instance();
+ key->set_scancode(KEY_ESCAPE);
va.push_back(key);
- joyb.joy_button.button_index = JOY_BUTTON_1;
+ joyb.instance();
+ joyb->set_button_index(JOY_BUTTON_1);
va.push_back(joyb);
GLOBAL_DEF("input/ui_cancel", va);
input_presets.push_back("input/ui_cancel");
va = Array();
- key.key.scancode = KEY_TAB;
+ key.instance();
+ key->set_scancode(KEY_TAB);
va.push_back(key);
GLOBAL_DEF("input/ui_focus_next", va);
input_presets.push_back("input/ui_focus_next");
va = Array();
- key.key.scancode = KEY_TAB;
- key.key.mod.shift = true;
+ key.instance();
+ key->set_scancode(KEY_TAB);
+ key->set_shift(true);
va.push_back(key);
GLOBAL_DEF("input/ui_focus_prev", va);
input_presets.push_back("input/ui_focus_prev");
- key.key.mod.shift = false;
va = Array();
- key.key.scancode = KEY_LEFT;
+ key.instance();
+ key->set_scancode(KEY_LEFT);
va.push_back(key);
- joyb.joy_button.button_index = JOY_DPAD_LEFT;
+ joyb.instance();
+ joyb->set_button_index(JOY_DPAD_LEFT);
va.push_back(joyb);
GLOBAL_DEF("input/ui_left", va);
input_presets.push_back("input/ui_left");
va = Array();
- key.key.scancode = KEY_RIGHT;
+ key.instance();
+ key->set_scancode(KEY_RIGHT);
va.push_back(key);
- joyb.joy_button.button_index = JOY_DPAD_RIGHT;
+ joyb.instance();
+ joyb->set_button_index(JOY_DPAD_RIGHT);
va.push_back(joyb);
GLOBAL_DEF("input/ui_right", va);
input_presets.push_back("input/ui_right");
va = Array();
- key.key.scancode = KEY_UP;
+ key.instance();
+ key->set_scancode(KEY_UP);
va.push_back(key);
- joyb.joy_button.button_index = JOY_DPAD_UP;
+ joyb.instance();
+ joyb->set_button_index(JOY_DPAD_UP);
va.push_back(joyb);
GLOBAL_DEF("input/ui_up", va);
input_presets.push_back("input/ui_up");
va = Array();
- key.key.scancode = KEY_DOWN;
+ key.instance();
+ key->set_scancode(KEY_DOWN);
va.push_back(key);
- joyb.joy_button.button_index = JOY_DPAD_DOWN;
+ joyb.instance();
+ joyb->set_button_index(JOY_DPAD_DOWN);
va.push_back(joyb);
GLOBAL_DEF("input/ui_down", va);
input_presets.push_back("input/ui_down");
va = Array();
- key.key.scancode = KEY_PAGEUP;
+ key.instance();
+ key->set_scancode(KEY_PAGEUP);
va.push_back(key);
GLOBAL_DEF("input/ui_page_up", va);
input_presets.push_back("input/ui_page_up");
va = Array();
- key.key.scancode = KEY_PAGEDOWN;
+ key.instance();
+ key->set_scancode(KEY_PAGEDOWN);
va.push_back(key);
GLOBAL_DEF("input/ui_page_down", va);
input_presets.push_back("input/ui_page_down");
diff --git a/core/global_constants.cpp b/core/global_constants.cpp
index 18f34b5d37..4f535fb05e 100644
--- a/core/global_constants.cpp
+++ b/core/global_constants.cpp
@@ -30,6 +30,7 @@
#include "global_constants.h"
#include "object.h"
+#include "os/input_event.h"
#include "os/keyboard.h"
#include "variant.h"
@@ -513,9 +514,8 @@ static _GlobalConstant _global_constants[] = {
{ "TYPE_NODE_PATH", Variant::NODE_PATH }, // 15
{ "TYPE_RID", Variant::_RID },
{ "TYPE_OBJECT", Variant::OBJECT },
- { "TYPE_INPUT_EVENT", Variant::INPUT_EVENT },
- { "TYPE_DICTIONARY", Variant::DICTIONARY },
- { "TYPE_ARRAY", Variant::ARRAY }, // 20
+ { "TYPE_DICTIONARY", Variant::DICTIONARY }, // 20
+ { "TYPE_ARRAY", Variant::ARRAY },
{ "TYPE_RAW_ARRAY", Variant::POOL_BYTE_ARRAY },
{ "TYPE_INT_ARRAY", Variant::POOL_INT_ARRAY },
{ "TYPE_REAL_ARRAY", Variant::POOL_REAL_ARRAY },
diff --git a/core/input_map.cpp b/core/input_map.cpp
index 9f9eba01c7..1307c467e6 100644
--- a/core/input_map.cpp
+++ b/core/input_map.cpp
@@ -37,8 +37,6 @@ InputMap *InputMap::singleton = NULL;
void InputMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_action", "action"), &InputMap::has_action);
- ClassDB::bind_method(D_METHOD("get_action_id", "action"), &InputMap::get_action_id);
- ClassDB::bind_method(D_METHOD("get_action_from_id", "id"), &InputMap::get_action_from_id);
ClassDB::bind_method(D_METHOD("get_actions"), &InputMap::_get_actions);
ClassDB::bind_method(D_METHOD("add_action", "action"), &InputMap::add_action);
ClassDB::bind_method(D_METHOD("erase_action", "action"), &InputMap::erase_action);
@@ -57,23 +55,15 @@ void InputMap::add_action(const StringName &p_action) {
input_map[p_action] = Action();
static int last_id = 1;
input_map[p_action].id = last_id;
- input_id_map[last_id] = p_action;
last_id++;
}
void InputMap::erase_action(const StringName &p_action) {
ERR_FAIL_COND(!input_map.has(p_action));
- input_id_map.erase(input_map[p_action].id);
input_map.erase(p_action);
}
-StringName InputMap::get_action_from_id(int p_id) const {
-
- ERR_FAIL_COND_V(!input_id_map.has(p_id), StringName());
- return input_id_map[p_id];
-}
-
Array InputMap::_get_actions() {
Array ret;
@@ -103,49 +93,18 @@ List<StringName> InputMap::get_actions() const {
return actions;
}
-List<InputEvent>::Element *InputMap::_find_event(List<InputEvent> &p_list, const InputEvent &p_event, bool p_action_test) const {
-
- for (List<InputEvent>::Element *E = p_list.front(); E; E = E->next()) {
-
- const InputEvent &e = E->get();
- if (e.type != p_event.type)
- continue;
- if (e.type != InputEvent::KEY && e.device != p_event.device)
- continue;
-
- bool same = false;
-
- switch (p_event.type) {
-
- case InputEvent::KEY: {
-
- if (p_action_test) {
- uint32_t code = e.key.get_scancode_with_modifiers();
- uint32_t event_code = p_event.key.get_scancode_with_modifiers();
- same = (e.key.scancode == p_event.key.scancode && (!p_event.key.pressed || ((code & event_code) == code)));
- } else {
- same = (e.key.scancode == p_event.key.scancode && e.key.mod == p_event.key.mod);
- }
-
- } break;
- case InputEvent::JOYPAD_BUTTON: {
+List<Ref<InputEvent> >::Element *InputMap::_find_event(List<Ref<InputEvent> > &p_list, const Ref<InputEvent> &p_event, bool p_action_test) const {
- same = (e.joy_button.button_index == p_event.joy_button.button_index);
+ for (List<Ref<InputEvent> >::Element *E = p_list.front(); E; E = E->next()) {
- } break;
- case InputEvent::MOUSE_BUTTON: {
+ const Ref<InputEvent> e = E->get();
- same = (e.mouse_button.button_index == p_event.mouse_button.button_index);
+ //if (e.type != Ref<InputEvent>::KEY && e.device != p_event.device) -- unsure about the KEY comparison, why is this here?
+ // continue;
- } break;
- case InputEvent::JOYPAD_MOTION: {
-
- same = (e.joy_motion.axis == p_event.joy_motion.axis && (e.joy_motion.axis_value < 0) == (p_event.joy_motion.axis_value < 0));
-
- } break;
- }
-
- if (same)
+ if (e->get_device() != p_event->get_device())
+ continue;
+ if (e->action_match(p_event))
return E;
}
@@ -157,9 +116,9 @@ bool InputMap::has_action(const StringName &p_action) const {
return input_map.has(p_action);
}
-void InputMap::action_add_event(const StringName &p_action, const InputEvent &p_event) {
+void InputMap::action_add_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
- ERR_FAIL_COND(p_event.type == InputEvent::ACTION);
+ ERR_FAIL_COND(p_event.is_null());
ERR_FAIL_COND(!input_map.has(p_action));
if (_find_event(input_map[p_action].inputs, p_event))
return; //already gots
@@ -167,23 +126,17 @@ void InputMap::action_add_event(const StringName &p_action, const InputEvent &p_
input_map[p_action].inputs.push_back(p_event);
}
-int InputMap::get_action_id(const StringName &p_action) const {
-
- ERR_FAIL_COND_V(!input_map.has(p_action), -1);
- return input_map[p_action].id;
-}
-
-bool InputMap::action_has_event(const StringName &p_action, const InputEvent &p_event) {
+bool InputMap::action_has_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
ERR_FAIL_COND_V(!input_map.has(p_action), false);
return (_find_event(input_map[p_action].inputs, p_event) != NULL);
}
-void InputMap::action_erase_event(const StringName &p_action, const InputEvent &p_event) {
+void InputMap::action_erase_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(!input_map.has(p_action));
- List<InputEvent>::Element *E = _find_event(input_map[p_action].inputs, p_event);
+ List<Ref<InputEvent> >::Element *E = _find_event(input_map[p_action].inputs, p_event);
if (E)
input_map[p_action].inputs.erase(E);
}
@@ -191,9 +144,9 @@ void InputMap::action_erase_event(const StringName &p_action, const InputEvent &
Array InputMap::_get_action_list(const StringName &p_action) {
Array ret;
- const List<InputEvent> *al = get_action_list(p_action);
+ const List<Ref<InputEvent> > *al = get_action_list(p_action);
if (al) {
- for (const List<InputEvent>::Element *E = al->front(); E; E = E->next()) {
+ for (const List<Ref<InputEvent> >::Element *E = al->front(); E; E = E->next()) {
ret.push_back(E->get());
}
@@ -202,7 +155,7 @@ Array InputMap::_get_action_list(const StringName &p_action) {
return ret;
}
-const List<InputEvent> *InputMap::get_action_list(const StringName &p_action) {
+const List<Ref<InputEvent> > *InputMap::get_action_list(const StringName &p_action) {
const Map<StringName, Action>::Element *E = input_map.find(p_action);
if (!E)
@@ -211,7 +164,7 @@ const List<InputEvent> *InputMap::get_action_list(const StringName &p_action) {
return &E->get().inputs;
}
-bool InputMap::event_is_action(const InputEvent &p_event, const StringName &p_action) const {
+bool InputMap::event_is_action(const Ref<InputEvent> &p_event, const StringName &p_action) const {
Map<StringName, Action>::Element *E = input_map.find(p_action);
if (!E) {
@@ -219,9 +172,9 @@ bool InputMap::event_is_action(const InputEvent &p_event, const StringName &p_ac
ERR_FAIL_COND_V(!E, false);
}
- if (p_event.type == InputEvent::ACTION) {
-
- return p_event.action.action == E->get().id;
+ Ref<InputEventAction> iea = p_event;
+ if (iea.is_valid()) {
+ return iea->get_action() == p_action;
}
return _find_event(E->get().inputs, p_event, true) != NULL;
@@ -252,8 +205,8 @@ void InputMap::load_from_globals() {
for (int i = 0; i < va.size(); i++) {
- InputEvent ie = va[i];
- if (ie.type == InputEvent::NONE)
+ Ref<InputEvent> ie = va[i];
+ if (ie.is_null())
continue;
action_add_event(name, ie);
}
@@ -262,57 +215,70 @@ void InputMap::load_from_globals() {
void InputMap::load_default() {
- InputEvent key;
- key.type = InputEvent::KEY;
+ Ref<InputEventKey> key;
add_action("ui_accept");
- key.key.scancode = KEY_RETURN;
+ key.instance();
+ key->set_scancode(KEY_RETURN);
action_add_event("ui_accept", key);
- key.key.scancode = KEY_ENTER;
+
+ key.instance();
+ key->set_scancode(KEY_ENTER);
action_add_event("ui_accept", key);
- key.key.scancode = KEY_SPACE;
+
+ key.instance();
+ key->set_scancode(KEY_SPACE);
action_add_event("ui_accept", key);
add_action("ui_select");
- key.key.scancode = KEY_SPACE;
+ key.instance();
+ key->set_scancode(KEY_SPACE);
action_add_event("ui_select", key);
add_action("ui_cancel");
- key.key.scancode = KEY_ESCAPE;
+ key.instance();
+ key->set_scancode(KEY_ESCAPE);
action_add_event("ui_cancel", key);
add_action("ui_focus_next");
- key.key.scancode = KEY_TAB;
+ key.instance();
+ key->set_scancode(KEY_TAB);
action_add_event("ui_focus_next", key);
add_action("ui_focus_prev");
- key.key.scancode = KEY_TAB;
- key.key.mod.shift = true;
+ key.instance();
+ key->set_scancode(KEY_TAB);
+ key->set_shift(true);
action_add_event("ui_focus_prev", key);
- key.key.mod.shift = false;
add_action("ui_left");
- key.key.scancode = KEY_LEFT;
+ key.instance();
+ key->set_scancode(KEY_LEFT);
action_add_event("ui_left", key);
add_action("ui_right");
- key.key.scancode = KEY_RIGHT;
+ key.instance();
+ key->set_scancode(KEY_RIGHT);
action_add_event("ui_right", key);
add_action("ui_up");
- key.key.scancode = KEY_UP;
+ key.instance();
+ key->set_scancode(KEY_UP);
action_add_event("ui_up", key);
add_action("ui_down");
- key.key.scancode = KEY_DOWN;
+ key.instance();
+ key->set_scancode(KEY_DOWN);
action_add_event("ui_down", key);
add_action("ui_page_up");
- key.key.scancode = KEY_PAGEUP;
+ key.instance();
+ key->set_scancode(KEY_PAGEUP);
action_add_event("ui_page_up", key);
add_action("ui_page_down");
- key.key.scancode = KEY_PAGEDOWN;
+ key.instance();
+ key->set_scancode(KEY_PAGEDOWN);
action_add_event("ui_page_down", key);
//set("display/handheld/orientation", "landscape");
diff --git a/core/input_map.h b/core/input_map.h
index a25255da2d..ba93e61f5f 100644
--- a/core/input_map.h
+++ b/core/input_map.h
@@ -31,6 +31,7 @@
#define INPUT_MAP_H
#include "object.h"
+#include "os/input_event.h"
class InputMap : public Object {
@@ -39,16 +40,15 @@ class InputMap : public Object {
public:
struct Action {
int id;
- List<InputEvent> inputs;
+ List<Ref<InputEvent> > inputs;
};
private:
static InputMap *singleton;
mutable Map<StringName, Action> input_map;
- mutable Map<int, StringName> input_id_map;
- List<InputEvent>::Element *_find_event(List<InputEvent> &p_list, const InputEvent &p_event, bool p_action_test = false) const;
+ List<Ref<InputEvent> >::Element *_find_event(List<Ref<InputEvent> > &p_list, const Ref<InputEvent> &p_event, bool p_action_test = false) const;
Array _get_action_list(const StringName &p_action);
Array _get_actions();
@@ -60,18 +60,16 @@ public:
static _FORCE_INLINE_ InputMap *get_singleton() { return singleton; }
bool has_action(const StringName &p_action) const;
- int get_action_id(const StringName &p_action) const;
- StringName get_action_from_id(int p_id) const;
List<StringName> get_actions() const;
void add_action(const StringName &p_action);
void erase_action(const StringName &p_action);
- void action_add_event(const StringName &p_action, const InputEvent &p_event);
- bool action_has_event(const StringName &p_action, const InputEvent &p_event);
- void action_erase_event(const StringName &p_action, const InputEvent &p_event);
+ void action_add_event(const StringName &p_action, const Ref<InputEvent> &p_event);
+ bool action_has_event(const StringName &p_action, const Ref<InputEvent> &p_event);
+ void action_erase_event(const StringName &p_action, const Ref<InputEvent> &p_event);
- const List<InputEvent> *get_action_list(const StringName &p_action);
- bool event_is_action(const InputEvent &p_event, const StringName &p_action) const;
+ const List<Ref<InputEvent> > *get_action_list(const StringName &p_action);
+ bool event_is_action(const Ref<InputEvent> &p_event, const StringName &p_action) const;
const Map<StringName, Action> &get_action_map() const;
void load_from_globals();
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index fd14011a81..dccf70ad7a 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -365,66 +365,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
r_variant = (Object *)NULL;
} break;
- case Variant::INPUT_EVENT: {
-
- InputEvent ie;
-
- ie.type = decode_uint32(&buf[0]);
- ie.device = decode_uint32(&buf[4]);
-
- if (r_len)
- (*r_len) += 12;
-
- switch (ie.type) {
-
- case InputEvent::KEY: {
-
- uint32_t mods = decode_uint32(&buf[12]);
- if (mods & KEY_MASK_SHIFT)
- ie.key.mod.shift = true;
- if (mods & KEY_MASK_CTRL)
- ie.key.mod.control = true;
- if (mods & KEY_MASK_ALT)
- ie.key.mod.alt = true;
- if (mods & KEY_MASK_META)
- ie.key.mod.meta = true;
- ie.key.scancode = decode_uint32(&buf[16]);
-
- if (r_len)
- (*r_len) += 8;
-
- } break;
- case InputEvent::MOUSE_BUTTON: {
-
- ie.mouse_button.button_index = decode_uint32(&buf[12]);
- if (r_len)
- (*r_len) += 4;
-
- } break;
- case InputEvent::JOYPAD_BUTTON: {
-
- ie.joy_button.button_index = decode_uint32(&buf[12]);
- if (r_len)
- (*r_len) += 4;
- } break;
- case InputEvent::SCREEN_TOUCH: {
-
- ie.screen_touch.index = decode_uint32(&buf[12]);
- if (r_len)
- (*r_len) += 4;
- } break;
- case InputEvent::JOYPAD_MOTION: {
-
- ie.joy_motion.axis = decode_uint32(&buf[12]);
- ie.joy_motion.axis_value = decode_float(&buf[16]);
- if (r_len)
- (*r_len) += 8;
- } break;
- }
-
- r_variant = ie;
-
- } break;
case Variant::DICTIONARY: {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
@@ -1055,83 +995,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
case Variant::OBJECT: {
} break;
- case Variant::INPUT_EVENT: {
-
- InputEvent ie = p_variant;
-
- if (buf) {
-
- encode_uint32(ie.type, &buf[0]);
- encode_uint32(ie.device, &buf[4]);
- encode_uint32(0, &buf[8]);
- }
-
- int llen = 12;
-
- switch (ie.type) {
-
- case InputEvent::KEY: {
-
- if (buf) {
-
- uint32_t mods = 0;
- if (ie.key.mod.shift)
- mods |= KEY_MASK_SHIFT;
- if (ie.key.mod.control)
- mods |= KEY_MASK_CTRL;
- if (ie.key.mod.alt)
- mods |= KEY_MASK_ALT;
- if (ie.key.mod.meta)
- mods |= KEY_MASK_META;
-
- encode_uint32(mods, &buf[llen]);
- encode_uint32(ie.key.scancode, &buf[llen + 4]);
- }
- llen += 8;
-
- } break;
- case InputEvent::MOUSE_BUTTON: {
-
- if (buf) {
-
- encode_uint32(ie.mouse_button.button_index, &buf[llen]);
- }
- llen += 4;
- } break;
- case InputEvent::JOYPAD_BUTTON: {
-
- if (buf) {
-
- encode_uint32(ie.joy_button.button_index, &buf[llen]);
- }
- llen += 4;
- } break;
- case InputEvent::SCREEN_TOUCH: {
-
- if (buf) {
-
- encode_uint32(ie.screen_touch.index, &buf[llen]);
- }
- llen += 4;
- } break;
- case InputEvent::JOYPAD_MOTION: {
-
- if (buf) {
-
- int axis = ie.joy_motion.axis;
- encode_uint32(axis, &buf[llen]);
- encode_float(ie.joy_motion.axis_value, &buf[llen + 4]);
- }
- llen += 8;
- } break;
- }
-
- if (buf)
- encode_uint32(llen, &buf[8]);
- r_len += llen;
-
- // not supported
- } break;
case Variant::DICTIONARY: {
Dictionary d = p_variant;
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 4ad3d261b2..26b53c2a31 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -359,13 +359,6 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
}
} break;
- case VARIANT_INPUT_EVENT: {
-
- InputEvent ev;
- ev.type = f->get_32(); //will only work for null though.
- r_v = ev;
-
- } break;
case VARIANT_DICTIONARY: {
uint32_t len = f->get_32();
@@ -1446,13 +1439,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant &p_property,
}
} break;
- case Variant::INPUT_EVENT: {
-
- f->store_32(VARIANT_INPUT_EVENT);
- InputEvent event = p_property;
- f->store_32(0); //event type none, nothing else suported for now.
-
- } break;
case Variant::DICTIONARY: {
f->store_32(VARIANT_DICTIONARY);
diff --git a/core/method_bind.h b/core/method_bind.h
index 5b8a458736..8d72c8573a 100644
--- a/core/method_bind.h
+++ b/core/method_bind.h
@@ -154,7 +154,6 @@ VARIANT_ENUM_CAST(Orientation);
VARIANT_ENUM_CAST(HAlign);
VARIANT_ENUM_CAST(Variant::Type);
VARIANT_ENUM_CAST(Variant::Operator);
-VARIANT_ENUM_CAST(InputEvent::Type);
class MethodBind {
diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h
index d3f6143638..bcbf2e4531 100644
--- a/core/method_ptrcall.h
+++ b/core/method_ptrcall.h
@@ -105,7 +105,6 @@ MAKE_PTRARG(Transform);
MAKE_PTRARG(Color);
MAKE_PTRARG(NodePath);
MAKE_PTRARG(RID);
-MAKE_PTRARG(InputEvent);
MAKE_PTRARG(Dictionary);
MAKE_PTRARG(Array);
MAKE_PTRARG(PoolByteArray);
diff --git a/core/os/input.h b/core/os/input.h
index 4f26f097c2..6759c624e3 100644
--- a/core/os/input.h
+++ b/core/os/input.h
@@ -82,7 +82,7 @@ public:
virtual int get_mouse_button_mask() const = 0;
virtual void warp_mouse_pos(const Vector2 &p_to) = 0;
- virtual Point2i warp_mouse_motion(const InputEventMouseMotion &p_motion, const Rect2 &p_rect) = 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;
@@ -104,7 +104,7 @@ public:
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 InputEvent &p_event) = 0;
+ virtual void parse_input_event(const Ref<InputEvent> &p_event) = 0;
Input();
};
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index 474bc33b41..2538e8dad2 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -34,275 +34,794 @@
*
*/
-bool InputEvent::operator==(const InputEvent &p_event) const {
- if (type != p_event.type) {
- return false;
- }
+void InputEvent::set_id(uint32_t p_id) {
+ id = p_id;
+}
- switch (type) {
- /** Current clang-format style doesn't play well with the aligned return values of that switch. */
- /* clang-format off */
- case NONE:
- return true;
- case KEY:
- return key.unicode == p_event.key.unicode
- && key.scancode == p_event.key.scancode
- && key.echo == p_event.key.echo
- && key.pressed == p_event.key.pressed
- && key.mod == p_event.key.mod;
- case MOUSE_MOTION:
- return mouse_motion.x == p_event.mouse_motion.x
- && mouse_motion.y == p_event.mouse_motion.y
- && mouse_motion.relative_x == p_event.mouse_motion.relative_x
- && mouse_motion.relative_y == p_event.mouse_motion.relative_y
- && mouse_motion.button_mask == p_event.mouse_motion.button_mask
- && key.mod == p_event.key.mod;
- case MOUSE_BUTTON:
- return mouse_button.pressed == p_event.mouse_button.pressed
- && mouse_button.x == p_event.mouse_button.x
- && mouse_button.y == p_event.mouse_button.y
- && mouse_button.button_index == p_event.mouse_button.button_index
- && mouse_button.button_mask == p_event.mouse_button.button_mask
- && key.mod == p_event.key.mod;
- case JOYPAD_MOTION:
- return joy_motion.axis == p_event.joy_motion.axis
- && joy_motion.axis_value == p_event.joy_motion.axis_value;
- case JOYPAD_BUTTON:
- return joy_button.pressed == p_event.joy_button.pressed
- && joy_button.button_index == p_event.joy_button.button_index
- && joy_button.pressure == p_event.joy_button.pressure;
- case SCREEN_TOUCH:
- return screen_touch.pressed == p_event.screen_touch.pressed
- && screen_touch.index == p_event.screen_touch.index
- && screen_touch.x == p_event.screen_touch.x
- && screen_touch.y == p_event.screen_touch.y;
- case SCREEN_DRAG:
- return screen_drag.index == p_event.screen_drag.index
- && screen_drag.x == p_event.screen_drag.x
- && screen_drag.y == p_event.screen_drag.y;
- case ACTION:
- return action.action == p_event.action.action
- && action.pressed == p_event.action.pressed;
- /* clang-format on */
- default:
- ERR_PRINT("No logic to compare InputEvents of this type, this shouldn't happen.");
- }
+uint32_t InputEvent::get_id() const {
+ return id;
+}
- return false;
+void InputEvent::set_device(int p_device) {
+ device = p_device;
}
-InputEvent::operator String() const {
-
- String str = "Device " + itos(device) + " ID " + itos(ID) + " ";
-
- switch (type) {
-
- case NONE: {
-
- return "Event: None";
- } break;
- case KEY: {
-
- str += "Event: Key ";
- str = str + "Unicode: " + String::chr(key.unicode) + " Scan: " + itos(key.scancode) + " Echo: " + String(key.echo ? "True" : "False") + " Pressed" + String(key.pressed ? "True" : "False") + " Mod: ";
- if (key.mod.shift)
- str += "S";
- if (key.mod.control)
- str += "C";
- if (key.mod.alt)
- str += "A";
- if (key.mod.meta)
- str += "M";
-
- return str;
- } break;
- case MOUSE_MOTION: {
-
- str += "Event: Motion ";
- str = str + " Pos: " + itos(mouse_motion.x) + "," + itos(mouse_motion.y) + " Rel: " + itos(mouse_motion.relative_x) + "," + itos(mouse_motion.relative_y) + " Mask: ";
- for (int i = 0; i < 8; i++) {
-
- if ((1 << i) & mouse_motion.button_mask)
- str += itos(i + 1);
- }
- str += " Mod: ";
- if (key.mod.shift)
- str += "S";
- if (key.mod.control)
- str += "C";
- if (key.mod.alt)
- str += "A";
- if (key.mod.meta)
- str += "M";
-
- return str;
- } break;
- case MOUSE_BUTTON: {
- str += "Event: Button ";
- str = str + "Pressed: " + itos(mouse_button.pressed) + " Pos: " + itos(mouse_button.x) + "," + itos(mouse_button.y) + " Button: " + itos(mouse_button.button_index) + " Mask: ";
- for (int i = 0; i < 8; i++) {
-
- if ((1 << i) & mouse_button.button_mask)
- str += itos(i + 1);
- }
- str += " Mod: ";
- if (key.mod.shift)
- str += "S";
- if (key.mod.control)
- str += "C";
- if (key.mod.alt)
- str += "A";
- if (key.mod.meta)
- str += "M";
-
- str += String(" DoubleClick: ") + (mouse_button.doubleclick ? "Yes" : "No");
-
- return str;
-
- } break;
- case JOYPAD_MOTION: {
- str += "Event: JoypadMotion ";
- str = str + "Axis: " + itos(joy_motion.axis) + " Value: " + rtos(joy_motion.axis_value);
- return str;
-
- } break;
- case JOYPAD_BUTTON: {
- str += "Event: JoypadButton ";
- str = str + "Pressed: " + itos(joy_button.pressed) + " Index: " + itos(joy_button.button_index) + " pressure " + rtos(joy_button.pressure);
- return str;
-
- } break;
- case SCREEN_TOUCH: {
- str += "Event: ScreenTouch ";
- str = str + "Pressed: " + itos(screen_touch.pressed) + " Index: " + itos(screen_touch.index) + " pos " + rtos(screen_touch.x) + "," + rtos(screen_touch.y);
- return str;
-
- } break;
- case SCREEN_DRAG: {
- str += "Event: ScreenDrag ";
- str = str + " Index: " + itos(screen_drag.index) + " pos " + rtos(screen_drag.x) + "," + rtos(screen_drag.y);
- return str;
-
- } break;
- case ACTION: {
- str += "Event: Action: " + InputMap::get_singleton()->get_action_from_id(action.action) + " Pressed: " + itos(action.pressed);
- return str;
-
- } break;
- }
- return "";
+int InputEvent::get_device() const {
+ return device;
}
-void InputEvent::set_as_action(const String &p_action, bool p_pressed) {
+bool InputEvent::is_pressed() const {
- type = ACTION;
- action.action = InputMap::get_singleton()->get_action_id(p_action);
- action.pressed = p_pressed;
+ return false;
}
-bool InputEvent::is_pressed() const {
+bool InputEvent::is_action(const StringName &p_action) const {
- switch (type) {
+ return InputMap::get_singleton()->event_is_action(Ref<InputEvent>(this), p_action);
+}
- case KEY: return key.pressed;
- case MOUSE_BUTTON: return mouse_button.pressed;
- case JOYPAD_BUTTON: return joy_button.pressed;
- case SCREEN_TOUCH: return screen_touch.pressed;
- case JOYPAD_MOTION: return ABS(joy_motion.axis_value) > 0.5;
- case ACTION: return action.pressed;
- default: {}
- }
+bool InputEvent::is_action_pressed(const StringName &p_action) const {
+
+ return false; // InputMap::get_singleton()->event_is_action(Ref<InputEvent>(this),p_action);
+}
+bool InputEvent::is_action_released(const StringName &p_action) const {
return false;
}
bool InputEvent::is_echo() const {
- return (type == KEY && key.echo);
+ 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) const {
+
+ return false;
+}
+
+bool InputEvent::is_action_type() const {
+
+ return false;
+}
+
+#if 0
+if (String(p_method) == "is_action" && p_argidx == 0) {
+
+ List<PropertyInfo> pinfo;
+ GlobalConfig::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());
+ result.insert("\"" + name + "\"");
+ }
+
+} else
+#endif
+
+void InputEvent::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_id", "id"), &InputEvent::set_id);
+ ClassDB::bind_method(D_METHOD("get_id"), &InputEvent::get_id);
+
+ 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_pressed"), &InputEvent::is_pressed);
+ ClassDB::bind_method(D_METHOD("is_action", "action"), &InputEvent::is_action);
+ ClassDB::bind_method(D_METHOD("is_action_pressed", "action"), &InputEvent::is_action_pressed);
+ ClassDB::bind_method(D_METHOD("is_action_released", "action"), &InputEvent::is_action_released);
+ 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("action_match", "event:InputEvent"), &InputEvent::action_match);
+
+ ClassDB::bind_method(D_METHOD("is_action_type"), &InputEvent::is_action_type);
+
+ ClassDB::bind_method(D_METHOD("xformed_by:InputEvent", "xform", "local_ofs"), &InputEvent::xformed_by, DEFVAL(Vector2()));
+}
+
+InputEvent::InputEvent() {
+
+ id = 0;
+ 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::_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() {
+
+ return pressed;
}
-bool InputEvent::is_action(const String &p_action) const {
+void InputEventKey::set_scancode(uint32_t p_scancode) {
+
+ scancode = p_scancode;
+}
+uint32_t InputEventKey::get_scancode() const {
- return InputMap::get_singleton()->event_is_action(*this, p_action);
+ return scancode;
}
-bool InputEvent::is_action_pressed(const String &p_action) const {
+void InputEventKey::set_unicode(uint32_t p_unicode) {
- return is_action(p_action) && is_pressed() && !is_echo();
+ unicode = p_unicode;
}
+uint32_t InputEventKey::get_unicode() const {
-bool InputEvent::is_action_released(const String &p_action) const {
+ return unicode;
+}
+
+void InputEventKey::set_echo(bool p_enable) {
+
+ echo = p_enable;
+}
+bool InputEventKey::is_echo() const {
- return is_action(p_action) && !is_pressed();
+ return echo;
}
uint32_t InputEventKey::get_scancode_with_modifiers() const {
uint32_t sc = scancode;
- if (mod.control)
+ if (get_control())
sc |= KEY_MASK_CTRL;
- if (mod.alt)
+ if (get_alt())
sc |= KEY_MASK_ALT;
- if (mod.shift)
+ if (get_shift())
sc |= KEY_MASK_SHIFT;
- if (mod.meta)
+ if (get_metakey())
sc |= KEY_MASK_META;
return sc;
}
-InputEvent InputEvent::xform_by(const Transform2D &p_xform) const {
-
- InputEvent ev = *this;
-
- switch (ev.type) {
-
- case InputEvent::MOUSE_BUTTON: {
-
- Vector2 g = p_xform.xform(Vector2(ev.mouse_button.global_x, ev.mouse_button.global_y));
- Vector2 l = p_xform.xform(Vector2(ev.mouse_button.x, ev.mouse_button.y));
- ev.mouse_button.x = l.x;
- ev.mouse_button.y = l.y;
- ev.mouse_button.global_x = g.x;
- ev.mouse_button.global_y = g.y;
-
- } break;
- case InputEvent::MOUSE_MOTION: {
-
- Vector2 g = p_xform.xform(Vector2(ev.mouse_motion.global_x, ev.mouse_motion.global_y));
- Vector2 l = p_xform.xform(Vector2(ev.mouse_motion.x, ev.mouse_motion.y));
- Vector2 r = p_xform.basis_xform(Vector2(ev.mouse_motion.relative_x, ev.mouse_motion.relative_y));
- Vector2 s = p_xform.basis_xform(Vector2(ev.mouse_motion.speed_x, ev.mouse_motion.speed_y));
- ev.mouse_motion.x = l.x;
- ev.mouse_motion.y = l.y;
- ev.mouse_motion.global_x = g.x;
- ev.mouse_motion.global_y = g.y;
- ev.mouse_motion.relative_x = r.x;
- ev.mouse_motion.relative_y = r.y;
- ev.mouse_motion.speed_x = s.x;
- ev.mouse_motion.speed_y = s.y;
-
- } break;
- case InputEvent::SCREEN_TOUCH: {
-
- Vector2 t = p_xform.xform(Vector2(ev.screen_touch.x, ev.screen_touch.y));
- ev.screen_touch.x = t.x;
- ev.screen_touch.y = t.y;
-
- } break;
- case InputEvent::SCREEN_DRAG: {
-
- Vector2 t = p_xform.xform(Vector2(ev.screen_drag.x, ev.screen_drag.y));
- Vector2 r = p_xform.basis_xform(Vector2(ev.screen_drag.relative_x, ev.screen_drag.relative_y));
- Vector2 s = p_xform.basis_xform(Vector2(ev.screen_drag.speed_x, ev.screen_drag.speed_y));
- ev.screen_drag.x = t.x;
- ev.screen_drag.y = t.y;
- ev.screen_drag.relative_x = r.x;
- ev.screen_drag.relative_y = r.y;
- ev.screen_drag.speed_x = s.x;
- ev.screen_drag.speed_y = s.y;
- } break;
- }
+bool InputEventKey::action_match(const Ref<InputEvent> &p_event) const {
+
+ Ref<InputEventKey> key = p_event;
+ if (key.is_null())
+ return false;
+
+ return get_scancode_with_modifiers() == key->get_scancode_with_modifiers();
+}
+
+void InputEventKey::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventKey::set_pressed);
+
+ ClassDB::bind_method(D_METHOD("set_scancode", "scancode"), &InputEventKey::set_scancode);
+ ClassDB::bind_method(D_METHOD("get_scancode"), &InputEventKey::get_scancode);
+
+ 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_scancode_with_modifiers"), &InputEventKey::get_scancode_with_modifiers);
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "scancode"), "set_scancode", "get_scancode");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "unicode"), "set_unicode", "get_unicode");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "echo"), "set_echo", "is_echo");
+}
+
+InputEventKey::InputEventKey() {
+
+ pressed = false;
+ scancode = 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_pos(const Vector2 &p_pos) {
+
+ pos = p_pos;
+}
+Vector2 InputEventMouse::get_pos() const {
+
+ return pos;
+}
+
+void InputEventMouse::set_global_pos(const Vector2 &p_global_pos) {
+
+ global_pos = p_global_pos;
+}
+Vector2 InputEventMouse::get_global_pos() 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_pos", "pos"), &InputEventMouse::set_pos);
+ ClassDB::bind_method(D_METHOD("get_pos"), &InputEventMouse::get_pos);
+
+ ClassDB::bind_method(D_METHOD("set_global_pos", "global_pos"), &InputEventMouse::set_global_pos);
+ ClassDB::bind_method(D_METHOD("get_global_pos"), &InputEventMouse::get_global_pos);
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "button_mask"), "set_button_mask", "get_button_mask");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "pos"), "set_pos", "get_pos");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_pos"), "set_global_pos", "get_global_pos");
+}
+
+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 = p_xform.xform(get_global_pos());
+ Vector2 l = p_xform.xform(get_pos() + p_local_ofs);
+
+ Ref<InputEventMouseButton> mb;
+ mb.instance();
+
+ mb->set_id(get_id());
+ mb->set_device(get_device());
+
+ mb->set_alt(get_alt());
+ mb->set_shift(get_shift());
+ mb->set_control(get_control());
+ mb->set_metakey(get_metakey());
+
+ mb->set_pos(l);
+ mb->set_global_pos(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) const {
+
+ Ref<InputEventMouseButton> mb = p_event;
+ if (mb.is_null())
+ return false;
+
+ return mb->button_index == button_index;
+}
+
+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::REAL, "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 = 0;
+ button_index = 0;
+ pressed = false;
+ doubleclick = false;
+}
+
+////////////////////////////////////////////
+
+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 = p_xform.xform(get_global_pos());
+ Vector2 l = p_xform.xform(get_pos() + 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_id(get_id());
+ mm->set_device(get_device());
+
+ mm->set_alt(get_alt());
+ mm->set_shift(get_shift());
+ mm->set_control(get_control());
+ mm->set_metakey(get_metakey());
+
+ mm->set_pos(l);
+ mm->set_global_pos(g);
+
+ mm->set_button_mask(get_button_mask());
+ mm->set_relative(r);
+ mm->set_speed(s);
+
+ return mm;
+}
+
+void InputEventMouseMotion::_bind_methods() {
+
+ 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, "relative"), "set_relative", "get_relative");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "speed"), "set_speed", "get_speed");
+}
+
+InputEventMouseMotion::InputEventMouseMotion() {
+}
+
+////////////////////////////////////////
+
+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::action_match(const Ref<InputEvent> &p_event) const {
+
+ Ref<InputEventJoypadMotion> jm = p_event;
+ if (jm.is_null())
+ return false;
+
+ return (axis == jm->axis && (axis_value < 0) == (jm->axis_value < 0));
+}
+
+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::REAL, "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) const {
+
+ Ref<InputEventJoypadButton> jb = p_event;
+ if (jb.is_null())
+ return false;
+
+ return button_index == jb->button_index;
+}
+
+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::REAL, "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_pos(const Vector2 &p_pos) {
+
+ pos = p_pos;
+}
+Vector2 InputEventScreenTouch::get_pos() 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_id(get_id());
+ st->set_device(get_device());
+ st->set_index(index);
+ st->set_pos(p_xform.xform(pos + p_local_ofs));
+ st->set_pressed(pressed);
+
+ return st;
+}
+
+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_pos", "pos"), &InputEventScreenTouch::set_pos);
+ ClassDB::bind_method(D_METHOD("get_pos"), &InputEventScreenTouch::get_pos);
+
+ 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, "pos"), "set_pos", "get_pos");
+ 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_pos(const Vector2 &p_pos) {
+
+ pos = p_pos;
+}
+Vector2 InputEventScreenDrag::get_pos() 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_id(get_id());
+ sd->set_device(get_device());
+
+ sd->set_index(index);
+ sd->set_pos(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;
+}
+
+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_pos", "pos"), &InputEventScreenDrag::set_pos);
+ ClassDB::bind_method(D_METHOD("get_pos"), &InputEventScreenDrag::get_pos);
+
+ 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, "pos"), "set_pos", "get_pos");
+ 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;
+}
+
+bool InputEventAction::is_action(const StringName &p_action) const {
+
+ return action == p_action;
+}
+
+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("is_action", "name"), &InputEventAction::is_action);
+
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "action"), "set_action", "get_action");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
+}
- return ev;
+InputEventAction::InputEventAction() {
+ pressed = false;
}
diff --git a/core/os/input_event.h b/core/os/input_event.h
index 93cceac27c..b94f0ef46a 100644
--- a/core/os/input_event.h
+++ b/core/os/input_event.h
@@ -32,6 +32,7 @@
#include "math_2d.h"
#include "os/copymem.h"
+#include "resource.h"
#include "typedefs.h"
#include "ustring.h"
/**
@@ -137,7 +138,40 @@ enum {
* Input Modifier Status
* for keyboard/mouse events.
*/
-struct InputModifierState {
+
+class InputEvent : public Resource {
+ GDCLASS(InputEvent, Resource)
+
+ uint32_t id;
+ int device;
+
+protected:
+ static void _bind_methods();
+
+public:
+ void set_id(uint32_t p_id);
+ uint32_t get_id() const;
+
+ void set_device(int p_device);
+ int get_device() const;
+
+ virtual bool is_pressed() const;
+ virtual bool is_action(const StringName &p_action) const;
+ virtual bool is_action_pressed(const StringName &p_action) const;
+ virtual bool is_action_released(const StringName &p_action) 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) const;
+ virtual bool is_action_type() const;
+
+ InputEvent();
+};
+
+class InputEventWithModifiers : public InputEvent {
+ GDCLASS(InputEventWithModifiers, InputEvent)
bool shift;
bool alt;
@@ -157,126 +191,267 @@ struct InputModifierState {
#endif
- bool operator==(const InputModifierState &rvalue) const {
+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;
- return ((shift == rvalue.shift) && (alt == rvalue.alt) && (control == rvalue.control) && (meta == rvalue.meta));
- }
+ InputEventWithModifiers();
};
-struct InputEventKey {
+class InputEventKey : public InputEventWithModifiers {
- InputModifierState mod;
+ GDCLASS(InputEventKey, InputEventWithModifiers)
bool pressed; /// otherwise release
uint32_t scancode; ///< check keyboard.h , KeyCode enum, without modifier masks
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);
+ bool is_pressed();
+
+ void set_scancode(uint32_t p_scancode);
+ uint32_t get_scancode() const;
+
+ void set_unicode(uint32_t p_unicode);
+ uint32_t get_unicode() const;
+
+ void set_echo(bool p_enable);
+ bool is_echo() const;
+
uint32_t get_scancode_with_modifiers() const;
- bool echo; /// true if this is an echo key
+ virtual bool action_match(const Ref<InputEvent> &p_event) const;
+
+ virtual bool is_action_type() const { return true; }
+
+ InputEventKey();
};
-struct InputEventMouse {
+class InputEventMouse : public InputEventWithModifiers {
+
+ GDCLASS(InputEventMouse, InputEventWithModifiers)
- InputModifierState mod;
int button_mask;
- float x, y;
- float global_x, global_y;
- int pointer_index;
+
+ 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_pos(const Vector2 &p_pos);
+ Vector2 get_pos() const;
+
+ void set_global_pos(const Vector2 &p_global_pos);
+ Vector2 get_global_pos() const;
+
+ InputEventMouse();
};
-struct InputEventMouseButton : public InputEventMouse {
+class InputEventMouseButton : public InputEventMouse {
+
+ GDCLASS(InputEventMouseButton, InputEventMouse)
- double factor;
+ 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) const;
+
+ virtual bool is_action_type() const { return true; }
+
+ InputEventMouseButton();
};
-struct InputEventMouseMotion : public InputEventMouse {
+class InputEventMouseMotion : public InputEventMouse {
+
+ GDCLASS(InputEventMouseMotion, InputEventMouse)
+ Vector2 relative;
+ Vector2 speed;
+
+protected:
+ static void _bind_methods();
+
+public:
+ 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;
- float relative_x, relative_y;
- float speed_x, speed_y;
+ InputEventMouseMotion();
};
-struct InputEventJoypadMotion {
+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 action_match(const Ref<InputEvent> &p_event) const;
+
+ virtual bool is_action_type() const { return true; }
+
+ InputEventJoypadMotion();
};
-struct InputEventJoypadButton {
+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;
-struct InputEventScreenTouch {
+ virtual bool action_match(const Ref<InputEvent> &p_event) const;
+ virtual bool is_action_type() const { return true; }
+
+ InputEventJoypadButton();
+};
+
+struct InputEventScreenTouch : public InputEvent {
+ GDCLASS(InputEventScreenTouch, InputEvent)
int index;
- float x, y;
+ Vector2 pos;
bool pressed;
+
+protected:
+ static void _bind_methods();
+
+public:
+ void set_index(int p_index);
+ int get_index() const;
+
+ void set_pos(const Vector2 &p_pos);
+ Vector2 get_pos() 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;
+
+ InputEventScreenTouch();
};
-struct InputEventScreenDrag {
+class InputEventScreenDrag : public InputEvent {
+
+ GDCLASS(InputEventScreenDrag, InputEvent)
int index;
- float x, y;
- float relative_x, relative_y;
- float speed_x, speed_y;
+ Vector2 pos;
+ Vector2 relative;
+ Vector2 speed;
+
+protected:
+ static void _bind_methods();
+
+public:
+ void set_index(int p_index);
+ int get_index() const;
+
+ void set_pos(const Vector2 &p_pos);
+ Vector2 get_pos() 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;
+
+ InputEventScreenDrag();
};
-struct InputEventAction {
+class InputEventAction : public InputEvent {
+
+ GDCLASS(InputEventAction, InputEvent)
- int action;
+ StringName action;
bool pressed;
-};
-struct InputEvent {
-
- enum Type {
- NONE,
- KEY,
- MOUSE_MOTION,
- MOUSE_BUTTON,
- JOYPAD_MOTION,
- JOYPAD_BUTTON,
- SCREEN_TOUCH,
- SCREEN_DRAG,
- ACTION,
- TYPE_MAX
- };
+protected:
+ static void _bind_methods();
- uint32_t ID;
- int type;
- int device;
+public:
+ void set_action(const StringName &p_action);
+ StringName get_action() const;
- union {
- InputEventMouseMotion mouse_motion;
- InputEventMouseButton mouse_button;
- InputEventJoypadMotion joy_motion;
- InputEventJoypadButton joy_button;
- InputEventKey key;
- InputEventScreenTouch screen_touch;
- InputEventScreenDrag screen_drag;
- InputEventAction action;
- };
+ void set_pressed(bool p_pressed);
+ virtual bool is_pressed() const;
- bool is_pressed() const;
- bool is_action(const String &p_action) const;
- bool is_action_pressed(const String &p_action) const;
- bool is_action_released(const String &p_action) const;
- bool is_echo() const;
- void set_as_action(const String &p_action, bool p_pressed);
-
- InputEvent xform_by(const Transform2D &p_xform) const;
- bool operator==(const InputEvent &p_event) const;
- operator String() const;
- InputEvent() {
- zeromem(this, sizeof(InputEvent));
- mouse_button.factor = 1;
- }
+ virtual bool is_action(const StringName &p_action) const;
+
+ virtual bool is_action_type() const { return true; }
+
+ InputEventAction();
};
#endif
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index 9f8fcccd82..248f5537c6 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -39,7 +39,7 @@ void MainLoop::_bind_methods() {
ClassDB::bind_method(D_METHOD("idle", "delta"), &MainLoop::idle);
ClassDB::bind_method(D_METHOD("finish"), &MainLoop::finish);
- BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::INPUT_EVENT, "ev")));
+ BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "ev", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
BIND_VMETHOD(MethodInfo("_input_text", PropertyInfo(Variant::STRING, "text")));
BIND_VMETHOD(MethodInfo("_initialize"));
BIND_VMETHOD(MethodInfo("_iteration", PropertyInfo(Variant::REAL, "delta")));
@@ -73,7 +73,7 @@ void MainLoop::input_text(const String &p_text) {
get_script_instance()->call("_input_text", p_text);
}
-void MainLoop::input_event(const InputEvent &p_event) {
+void MainLoop::input_event(const Ref<InputEvent> &p_event) {
if (get_script_instance())
get_script_instance()->call("_input_event", p_event);
diff --git a/core/os/main_loop.h b/core/os/main_loop.h
index a53137afa4..23b352468e 100644
--- a/core/os/main_loop.h
+++ b/core/os/main_loop.h
@@ -59,7 +59,7 @@ public:
NOTIFICATION_TRANSLATION_CHANGED = 10,
};
- virtual void input_event(const InputEvent &p_event);
+ virtual void input_event(const Ref<InputEvent> &p_event);
virtual void input_text(const String &p_text);
virtual void init();
diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp
index 836bcb7287..0565d0d3f5 100644
--- a/core/packed_data_container.cpp
+++ b/core/packed_data_container.cpp
@@ -237,7 +237,6 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
case Variant::RECT3:
case Variant::BASIS:
case Variant::TRANSFORM:
- case Variant::INPUT_EVENT:
case Variant::POOL_BYTE_ARRAY:
case Variant::POOL_INT_ARRAY:
case Variant::POOL_REAL_ARRAY:
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 634751b0bb..b089ba9129 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -110,6 +110,18 @@ void register_core_types() {
ClassDB::register_class<Resource>();
ClassDB::register_class<Image>();
+ ClassDB::register_virtual_class<InputEvent>();
+ ClassDB::register_virtual_class<InputEventWithModifiers>();
+ ClassDB::register_class<InputEventKey>();
+ ClassDB::register_virtual_class<InputEventMouse>();
+ ClassDB::register_class<InputEventMouseButton>();
+ ClassDB::register_class<InputEventMouseMotion>();
+ ClassDB::register_class<InputEventJoypadButton>();
+ ClassDB::register_class<InputEventJoypadMotion>();
+ ClassDB::register_class<InputEventScreenDrag>();
+ ClassDB::register_class<InputEventScreenTouch>();
+ ClassDB::register_class<InputEventAction>();
+
ClassDB::register_class<FuncRef>();
ClassDB::register_virtual_class<StreamPeer>();
ClassDB::register_class<StreamPeerBuffer>();
diff --git a/core/variant.cpp b/core/variant.cpp
index 9c05dbaca0..ae5141b8bf 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -133,11 +133,6 @@ String Variant::get_type_name(Variant::Type p_type) {
return "NodePath";
} break;
- case INPUT_EVENT: {
-
- return "InputEvent";
-
- } break;
case DICTIONARY: {
return "Dictionary";
@@ -798,11 +793,6 @@ bool Variant::is_zero() const {
return reinterpret_cast<const NodePath *>(_data._mem)->is_empty();
} break;
- case INPUT_EVENT: {
-
- return _data._input_event->type == InputEvent::NONE;
-
- } break;
case DICTIONARY: {
return reinterpret_cast<const Dictionary *>(_data._mem)->empty();
@@ -1018,11 +1008,6 @@ void Variant::reference(const Variant &p_variant) {
memnew_placement(_data._mem, NodePath(*reinterpret_cast<const NodePath *>(p_variant._data._mem)));
} break;
- case INPUT_EVENT: {
-
- _data._input_event = memnew(InputEvent(*p_variant._data._input_event));
-
- } break;
case DICTIONARY: {
memnew_placement(_data._mem, Dictionary(*reinterpret_cast<const Dictionary *>(p_variant._data._mem)));
@@ -1149,12 +1134,6 @@ void Variant::clear() {
reinterpret_cast<Array *>(_data._mem)->~Array();
} break;
- case INPUT_EVENT: {
-
- memdelete(_data._input_event);
-
- } break;
-
// arrays
case POOL_BYTE_ARRAY: {
@@ -1503,7 +1482,6 @@ Variant::operator String() const {
} break;
case TRANSFORM: return operator Transform();
case NODE_PATH: return operator NodePath();
- case INPUT_EVENT: return operator InputEvent();
case COLOR: return String::num(operator Color().r) + "," + String::num(operator Color().g) + "," + String::num(operator Color().b) + "," + String::num(operator Color().a);
case DICTIONARY: {
@@ -1798,14 +1776,6 @@ Variant::operator Control *() const {
return NULL;
}
-Variant::operator InputEvent() const {
-
- if (type == INPUT_EVENT)
- return *reinterpret_cast<const InputEvent *>(_data._input_event);
- else
- return InputEvent();
-}
-
Variant::operator Dictionary() const {
if (type == DICTIONARY)
@@ -2285,12 +2255,6 @@ Variant::Variant(const NodePath &p_node_path) {
memnew_placement(_data._mem, NodePath(p_node_path));
}
-Variant::Variant(const InputEvent &p_input_event) {
-
- type = INPUT_EVENT;
- _data._input_event = memnew(InputEvent(p_input_event));
-}
-
Variant::Variant(const RefPtr &p_resource) {
type = OBJECT;
@@ -2690,11 +2654,6 @@ uint32_t Variant::hash() const {
return reinterpret_cast<const NodePath *>(_data._mem)->hash();
} break;
- case INPUT_EVENT: {
-
- return hash_djb2_buffer((uint8_t *)_data._input_event, sizeof(InputEvent));
-
- } break;
case DICTIONARY: {
return reinterpret_cast<const Dictionary *>(_data._mem)->hash();
diff --git a/core/variant.h b/core/variant.h
index 76097dfbdd..661d31cf16 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -42,7 +42,6 @@
#include "io/ip_address.h"
#include "math_2d.h"
#include "matrix3.h"
-#include "os/input_event.h"
#include "os/power.h"
#include "path_db.h"
#include "plane.h"
@@ -100,7 +99,6 @@ public:
NODE_PATH, // 15
_RID,
OBJECT,
- INPUT_EVENT,
DICTIONARY,
ARRAY, // 20
@@ -143,7 +141,6 @@ private:
Basis *_basis;
Transform *_transform;
RefPtr *_resource;
- InputEvent *_input_event;
void *_ptr; //generic pointer
uint8_t _mem[sizeof(ObjData) > (sizeof(real_t) * 4) ? sizeof(ObjData) : (sizeof(real_t) * 4)];
} _data;
@@ -207,7 +204,7 @@ public:
operator NodePath() const;
operator RefPtr() const;
operator RID() const;
- operator InputEvent() const;
+
operator Object *() const;
operator Node *() const;
operator Control *() const;
@@ -276,7 +273,6 @@ public:
Variant(const RefPtr &p_resource);
Variant(const RID &p_rid);
Variant(const Object *p_object);
- Variant(const InputEvent &p_input_event);
Variant(const Dictionary &p_dictionary);
Variant(const Array &p_array);
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index df81d2111e..6568dc877e 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -737,13 +737,6 @@ struct _VariantCall {
VCALL_PTR1( Transform, translate );
VCALL_PTR0( Transform, orthonormalize ); */
- VCALL_PTR0R(InputEvent, is_pressed);
- VCALL_PTR1R(InputEvent, is_action);
- VCALL_PTR1R(InputEvent, is_action_pressed);
- VCALL_PTR1R(InputEvent, is_action_released);
- VCALL_PTR0R(InputEvent, is_echo);
- VCALL_PTR2(InputEvent, set_as_action);
-
struct ConstructData {
int arg_count;
@@ -1036,7 +1029,6 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
return NodePath(); // 15
case _RID: return RID();
case OBJECT: return (Object *)NULL;
- case INPUT_EVENT: return InputEvent();
case DICTIONARY: return Dictionary();
case ARRAY:
return Array(); // 20
@@ -1117,7 +1109,6 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
return (NodePath(p_args[0]->operator NodePath())); // 15
case _RID: return (RID(*p_args[0]));
case OBJECT: return ((Object *)(p_args[0]->operator Object *()));
- case INPUT_EVENT: return (InputEvent(*p_args[0]));
case DICTIONARY: return p_args[0]->operator Dictionary();
case ARRAY:
return p_args[0]->operator Array(); // 20
@@ -1690,13 +1681,6 @@ void register_variant_methods() {
_VariantCall::type_funcs[Variant::TRANSFORM].functions["xform_inv"].returns = true;
#endif
- ADDFUNC0(INPUT_EVENT, BOOL, InputEvent, is_pressed, varray());
- ADDFUNC1(INPUT_EVENT, BOOL, InputEvent, is_action, STRING, "action", varray());
- ADDFUNC1(INPUT_EVENT, BOOL, InputEvent, is_action_pressed, STRING, "action", varray());
- ADDFUNC1(INPUT_EVENT, BOOL, InputEvent, is_action_released, STRING, "action", varray());
- ADDFUNC0(INPUT_EVENT, BOOL, InputEvent, is_echo, varray());
- ADDFUNC2(INPUT_EVENT, NIL, InputEvent, set_as_action, STRING, "action", BOOL, "pressed", varray());
-
/* REGISTER CONSTRUCTORS */
_VariantCall::add_constructor(_VariantCall::Vector2_init1, Variant::VECTOR2, "x", Variant::REAL, "y", Variant::REAL);
@@ -1733,16 +1717,6 @@ void register_variant_methods() {
_VariantCall::add_constant(Variant::VECTOR3, "AXIS_X", Vector3::AXIS_X);
_VariantCall::add_constant(Variant::VECTOR3, "AXIS_Y", Vector3::AXIS_Y);
_VariantCall::add_constant(Variant::VECTOR3, "AXIS_Z", Vector3::AXIS_Z);
-
- _VariantCall::add_constant(Variant::INPUT_EVENT, "NONE", InputEvent::NONE);
- _VariantCall::add_constant(Variant::INPUT_EVENT, "KEY", InputEvent::KEY);
- _VariantCall::add_constant(Variant::INPUT_EVENT, "MOUSE_MOTION", InputEvent::MOUSE_MOTION);
- _VariantCall::add_constant(Variant::INPUT_EVENT, "MOUSE_BUTTON", InputEvent::MOUSE_BUTTON);
- _VariantCall::add_constant(Variant::INPUT_EVENT, "JOYPAD_MOTION", InputEvent::JOYPAD_MOTION);
- _VariantCall::add_constant(Variant::INPUT_EVENT, "JOYPAD_BUTTON", InputEvent::JOYPAD_BUTTON);
- _VariantCall::add_constant(Variant::INPUT_EVENT, "SCREEN_TOUCH", InputEvent::SCREEN_TOUCH);
- _VariantCall::add_constant(Variant::INPUT_EVENT, "SCREEN_DRAG", InputEvent::SCREEN_DRAG);
- _VariantCall::add_constant(Variant::INPUT_EVENT, "ACTION", InputEvent::ACTION);
}
void unregister_variant_methods() {
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 8bae6a168b..7b9b7abd9e 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -61,7 +61,6 @@ bool Variant::booleanize(bool &r_valid) const {
case _RID: return (*reinterpret_cast<const RID *>(_data._mem)).is_valid();
case OBJECT: return _get_obj().obj;
case NODE_PATH: return (*reinterpret_cast<const NodePath *>(_data._mem)) != NodePath();
- case INPUT_EVENT:
case DICTIONARY:
case ARRAY:
case POOL_BYTE_ARRAY:
@@ -291,7 +290,6 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, const Variant &
if (p_b.type == NIL)
_RETURN(!p_a._get_obj().obj);
} break;
- DEFAULT_OP_PTRREF(==, INPUT_EVENT, _input_event);
case DICTIONARY: {
@@ -378,7 +376,6 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, const Variant &
if (p_b.type == OBJECT)
_RETURN((p_a._get_obj().obj < p_b._get_obj().obj));
} break;
- DEFAULT_OP_FAIL(INPUT_EVENT);
DEFAULT_OP_FAIL(DICTIONARY);
case ARRAY: {
@@ -443,7 +440,6 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, const Variant &
if (p_b.type == OBJECT)
_RETURN((p_a._get_obj().obj <= p_b._get_obj().obj));
} break;
- DEFAULT_OP_FAIL(INPUT_EVENT);
DEFAULT_OP_FAIL(DICTIONARY);
DEFAULT_OP_FAIL(ARRAY);
DEFAULT_OP_FAIL(POOL_BYTE_ARRAY);
@@ -502,7 +498,6 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, const Variant &
DEFAULT_OP_FAIL(NODE_PATH);
DEFAULT_OP_FAIL(_RID);
DEFAULT_OP_FAIL(OBJECT);
- DEFAULT_OP_FAIL(INPUT_EVENT);
DEFAULT_OP_FAIL(DICTIONARY);
case ARRAY: {
@@ -559,7 +554,6 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, const Variant &
DEFAULT_OP_FAIL(NODE_PATH);
DEFAULT_OP_FAIL(_RID);
DEFAULT_OP_FAIL(OBJECT);
- DEFAULT_OP_FAIL(INPUT_EVENT);
DEFAULT_OP_FAIL(DICTIONARY);
DEFAULT_OP_FAIL(ARRAY);
DEFAULT_OP_FAIL(POOL_BYTE_ARRAY);
@@ -656,7 +650,6 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, const Variant &
DEFAULT_OP_FAIL(NODE_PATH);
DEFAULT_OP_FAIL(_RID);
DEFAULT_OP_FAIL(OBJECT);
- DEFAULT_OP_FAIL(INPUT_EVENT);
DEFAULT_OP_FAIL(DICTIONARY);
DEFAULT_OP_FAIL(ARRAY);
DEFAULT_OP_FAIL(POOL_BYTE_ARRAY);
@@ -729,7 +722,6 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, const Variant &
DEFAULT_OP_FAIL(NODE_PATH);
DEFAULT_OP_FAIL(_RID);
DEFAULT_OP_FAIL(OBJECT);
- DEFAULT_OP_FAIL(INPUT_EVENT);
DEFAULT_OP_FAIL(DICTIONARY);
DEFAULT_OP_FAIL(ARRAY);
DEFAULT_OP_FAIL(POOL_BYTE_ARRAY);
@@ -771,7 +763,6 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, const Variant &
DEFAULT_OP_FAIL(NODE_PATH);
DEFAULT_OP_FAIL(_RID);
DEFAULT_OP_FAIL(OBJECT);
- DEFAULT_OP_FAIL(INPUT_EVENT);
DEFAULT_OP_FAIL(DICTIONARY);
DEFAULT_OP_FAIL(ARRAY);
DEFAULT_OP_FAIL(POOL_BYTE_ARRAY);
@@ -811,7 +802,6 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, const Variant &
DEFAULT_OP_FAIL(NODE_PATH);
DEFAULT_OP_FAIL(_RID);
DEFAULT_OP_FAIL(OBJECT);
- DEFAULT_OP_FAIL(INPUT_EVENT);
DEFAULT_OP_FAIL(DICTIONARY);
DEFAULT_OP_FAIL(ARRAY);
DEFAULT_OP_FAIL(POOL_BYTE_ARRAY);
@@ -1507,389 +1497,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
return obj->set(p_index, p_value, r_valid);
}
} break;
- case INPUT_EVENT: {
-
- InputEvent &ie = *_data._input_event;
-
- if (p_index.get_type() != Variant::STRING)
- return;
-
- const String &str = *reinterpret_cast<const String *>(p_index._data._mem);
-
- if (str == "type") {
-
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
- return;
-
- int type = p_value;
- if (type < 0 || type >= InputEvent::TYPE_MAX)
- return; //fail
- valid = true;
- ie.type = InputEvent::Type(type);
- return;
- } else if (str == "device") {
-
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
- return;
-
- valid = true;
- ie.device = p_value;
- return;
- } else if (str == "ID") {
-
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
- return;
-
- valid = true;
- ie.ID = p_value;
- return;
- }
-
- if (ie.type == InputEvent::KEY || ie.type == InputEvent::MOUSE_BUTTON || ie.type == InputEvent::MOUSE_MOTION) {
-
- if (str == "shift") {
-
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL && p_value.type != Variant::BOOL)
- return;
-
- valid = true;
- ie.key.mod.shift = p_value;
- return;
- }
- if (str == "alt") {
-
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL && p_value.type != Variant::BOOL)
- return;
-
- valid = true;
- ie.key.mod.alt = p_value;
- return;
- }
- if (str == "control") {
-
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL && p_value.type != Variant::BOOL)
- return;
-
- valid = true;
- ie.key.mod.control = p_value;
- return;
- }
- if (str == "meta") {
-
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL && p_value.type != Variant::BOOL)
- return;
-
- valid = true;
- ie.key.mod.meta = p_value;
- return;
- }
- }
-
- if (ie.type == InputEvent::KEY) {
-
- if (str == "pressed") {
-
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL && p_value.type != Variant::BOOL)
- return;
-
- valid = true;
- ie.key.pressed = p_value;
- return;
- } else if (str == "scancode") {
-
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
- return;
-
- valid = true;
- ie.key.scancode = p_value;
- return;
- } else if (str == "unicode") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
- return;
- valid = true;
- ie.key.unicode = p_value;
- return;
- } else if (str == "echo") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL && p_value.type != Variant::BOOL)
- return;
-
- valid = true;
- ie.key.echo = p_value;
- return;
- }
- }
-
- if (ie.type == InputEvent::MOUSE_MOTION || ie.type == InputEvent::MOUSE_BUTTON) {
-
- if (str == "button_mask") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
- return;
- valid = true;
- ie.mouse_button.button_mask = p_value;
- return;
- } else if (str == "x") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
- return;
- valid = true;
- ie.mouse_button.x = p_value;
- return;
- } else if (str == "y") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
- return;
- valid = true;
- ie.mouse_button.y = p_value;
- return;
- } else if (str == "pos") {
- if (p_value.type != Variant::VECTOR2)
- return;
- valid = true;
- Point2 value = p_value;
- ie.mouse_button.x = value.x;
- ie.mouse_button.y = value.y;
- return;
- } else if (str == "global_x") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
- return;
- valid = true;
- ie.mouse_button.global_x = p_value;
- return;
- } else if (str == "global_y") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
- return;
- valid = true;
- ie.mouse_button.global_y = p_value;
- return;
- } else if (str == "global_pos") {
- if (p_value.type != Variant::VECTOR2)
- return;
- valid = true;
- Point2 value = p_value;
- ie.mouse_button.global_x = value.x;
- ie.mouse_button.global_y = value.y;
- return;
- } /*else if (str=="pointer_index") {
- valid=true;
- return ie.mouse_button.pointer_index;
- }*/
-
- if (ie.type == InputEvent::MOUSE_MOTION) {
-
- if (str == "relative_x") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
- return;
- valid = true;
- ie.mouse_motion.relative_x = p_value;
- return;
- } else if (str == "relative_y") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
- return;
- valid = true;
- ie.mouse_motion.relative_y = p_value;
- return;
- } else if (str == "relative_pos") {
- if (p_value.type != Variant::VECTOR2)
- return;
- valid = true;
- Point2 value = p_value;
- ie.mouse_motion.relative_x = value.x;
- ie.mouse_motion.relative_y = value.y;
- return;
- }
-
- if (str == "speed_x") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
- return;
- valid = true;
- ie.mouse_motion.speed_x = p_value;
- return;
- } else if (str == "speed_y") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
- return;
- valid = true;
- ie.mouse_motion.speed_y = p_value;
- return;
- } else if (str == "speed") {
- if (p_value.type != Variant::VECTOR2)
- return;
- valid = true;
- Point2 value = p_value;
- ie.mouse_motion.speed_x = value.x;
- ie.mouse_motion.speed_y = value.y;
- return;
- }
-
- } else if (ie.type == InputEvent::MOUSE_BUTTON) {
-
- if (str == "button_index") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
- return;
- valid = true;
- ie.mouse_button.button_index = p_value;
- return;
- } else if (str == "pressed") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL && p_value.type != Variant::BOOL)
- return;
- valid = true;
- ie.mouse_button.pressed = p_value;
- return;
- } else if (str == "doubleclick") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL && p_value.type != Variant::BOOL)
- return;
- valid = true;
- ie.mouse_button.doubleclick = p_value;
- return;
- }
- }
- }
-
- if (ie.type == InputEvent::JOYPAD_BUTTON) {
-
- if (str == "button_index") {
- if (p_value.type != Variant::REAL && p_value.type != Variant::INT)
- return;
- valid = true;
- ie.joy_button.button_index = p_value;
- return;
- }
- if (str == "pressed") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL && p_value.type != Variant::BOOL)
- return;
-
- valid = true;
- ie.joy_button.pressed = p_value;
- return;
- }
- if (str == "pressure") {
- if (p_value.type != Variant::REAL && p_value.type != Variant::INT)
- return;
- valid = true;
- ie.joy_button.pressure = p_value;
- return;
- }
- }
-
- if (ie.type == InputEvent::JOYPAD_MOTION) {
-
- if (str == "axis") {
- if (p_value.type != Variant::REAL && p_value.type != Variant::INT)
- return;
- valid = true;
- ie.joy_motion.axis = p_value;
- return;
- }
- if (str == "value") {
- if (p_value.type != Variant::REAL && p_value.type != Variant::INT)
- return;
- valid = true;
- ie.joy_motion.axis_value = p_value;
- return;
- }
- }
-
- if (ie.type == InputEvent::SCREEN_TOUCH) {
-
- if (str == "index") {
- valid = true;
- ie.screen_touch.index = p_value;
- return;
- }
- if (str == "x") {
- valid = true;
- ie.screen_touch.x = p_value;
- return;
- }
- if (str == "y") {
- valid = true;
- ie.screen_touch.y = p_value;
- return;
- }
- if (str == "pos") {
- valid = true;
- Vector2 v = p_value;
- ie.screen_touch.x = v.x;
- ie.screen_touch.y = v.y;
- return;
- }
- if (str == "pressed") {
- valid = true;
- ie.screen_touch.pressed = p_value;
- return;
- }
- }
-
- if (ie.type == InputEvent::SCREEN_DRAG) {
-
- if (str == "index") {
- valid = true;
- ie.screen_drag.index = p_value;
- return;
- }
- if (str == "x") {
- valid = true;
- ie.screen_drag.x = p_value;
- return;
- }
- if (str == "y") {
- valid = true;
- ie.screen_drag.y = p_value;
- return;
- }
- if (str == "pos") {
- valid = true;
- Vector2 v = p_value;
- ie.screen_drag.x = v.x;
- ie.screen_drag.y = v.y;
- return;
- }
- if (str == "relative_x") {
- valid = true;
- ie.screen_drag.relative_x = p_value;
- return;
- }
- if (str == "relative_y") {
- valid = true;
- ie.screen_drag.relative_y = p_value;
- return;
- }
- if (str == "relative_pos") {
- valid = true;
- Vector2 v = p_value;
- ie.screen_drag.relative_x = v.x;
- ie.screen_drag.relative_y = v.y;
- return;
- }
- if (str == "speed_x") {
- valid = true;
- ie.screen_drag.speed_x = p_value;
- return;
- }
- if (str == "speed_y") {
- valid = true;
- ie.screen_drag.speed_y = p_value;
- return;
- }
- if (str == "speed") {
- valid = true;
- Vector2 v = p_value;
- ie.screen_drag.speed_x = v.x;
- ie.screen_drag.speed_y = v.y;
- return;
- }
- }
- if (ie.type == InputEvent::ACTION) {
-
- if (str == "action") {
- valid = true;
- ie.action.action = p_value;
- return;
- } else if (str == "pressed") {
- valid = true;
- ie.action.pressed = p_value;
- return;
- }
- }
-
- } break;
case DICTIONARY: {
Dictionary *dic = reinterpret_cast<Dictionary *>(_data._mem);
@@ -2261,235 +1868,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
}
} break;
- case INPUT_EVENT: {
-
- InputEvent ie = operator InputEvent();
-
- if (p_index.get_type() != Variant::STRING)
- break;
-
- const String &str = *reinterpret_cast<const String *>(p_index._data._mem);
-
- if (str == "type") {
- valid = true;
- return ie.type;
- } else if (str == "device") {
- valid = true;
- return ie.device;
- } else if (str == "ID") {
- valid = true;
- return ie.ID;
- }
-
- if (ie.type == InputEvent::KEY || ie.type == InputEvent::MOUSE_BUTTON || ie.type == InputEvent::MOUSE_MOTION) {
-
- if (str == "shift") {
- valid = true;
- return ie.key.mod.shift;
- }
- if (str == "alt") {
- valid = true;
- return ie.key.mod.alt;
- }
- if (str == "control") {
- valid = true;
- return ie.key.mod.control;
- }
- if (str == "meta") {
- valid = true;
- return ie.key.mod.meta;
- }
- }
-
- if (ie.type == InputEvent::KEY) {
-
- if (str == "pressed") {
- valid = true;
- return ie.key.pressed;
- } else if (str == "scancode") {
- valid = true;
- return ie.key.scancode;
- } else if (str == "unicode") {
- valid = true;
- return ie.key.unicode;
- } else if (str == "echo") {
- valid = true;
- return ie.key.echo;
- }
- }
-
- if (ie.type == InputEvent::MOUSE_MOTION || ie.type == InputEvent::MOUSE_BUTTON) {
-
- if (str == "button_mask") {
- valid = true;
- return ie.mouse_button.button_mask;
- } else if (str == "x") {
- valid = true;
- return ie.mouse_button.x;
- } else if (str == "y") {
- valid = true;
- return ie.mouse_button.y;
- } else if (str == "pos") {
- valid = true;
- return Point2(ie.mouse_button.x, ie.mouse_button.y);
- } else if (str == "global_x") {
- valid = true;
- return ie.mouse_button.global_x;
- } else if (str == "global_y") {
- valid = true;
- return ie.mouse_button.global_y;
- } else if (str == "global_pos") {
- valid = true;
- return Point2(ie.mouse_button.global_x, ie.mouse_button.global_y);
- } /*else if (str=="pointer_index") {
- valid=true;
- return ie.mouse_button.pointer_index;
- }*/
-
- if (ie.type == InputEvent::MOUSE_MOTION) {
-
- if (str == "relative_x") {
- valid = true;
- return ie.mouse_motion.relative_x;
- } else if (str == "relative_y") {
- valid = true;
- return ie.mouse_motion.relative_y;
- } else if (str == "relative_pos") {
- valid = true;
- return Point2(ie.mouse_motion.relative_x, ie.mouse_motion.relative_y);
- } else if (str == "speed_x") {
- valid = true;
- return ie.mouse_motion.speed_x;
- } else if (str == "speed_y") {
- valid = true;
- return ie.mouse_motion.speed_y;
- } else if (str == "speed") {
- valid = true;
- return Point2(ie.mouse_motion.speed_x, ie.mouse_motion.speed_y);
- }
-
- } else if (ie.type == InputEvent::MOUSE_BUTTON) {
-
- if (str == "button_index") {
- valid = true;
- return ie.mouse_button.button_index;
- } else if (str == "pressed") {
- valid = true;
- return ie.mouse_button.pressed;
- } else if (str == "doubleclick") {
- valid = true;
- return ie.mouse_button.doubleclick;
- }
- }
- }
-
- if (ie.type == InputEvent::JOYPAD_BUTTON) {
-
- if (str == "button_index") {
- valid = true;
- return ie.joy_button.button_index;
- }
- if (str == "pressed") {
- valid = true;
- return ie.joy_button.pressed;
- }
- if (str == "pressure") {
- valid = true;
- return ie.joy_button.pressure;
- }
- }
-
- if (ie.type == InputEvent::JOYPAD_MOTION) {
-
- if (str == "axis") {
- valid = true;
- return ie.joy_motion.axis;
- }
- if (str == "value") {
- valid = true;
- return ie.joy_motion.axis_value;
- }
- }
-
- if (ie.type == InputEvent::SCREEN_TOUCH) {
-
- if (str == "index") {
- valid = true;
- return ie.screen_touch.index;
- }
- if (str == "x") {
- valid = true;
- return ie.screen_touch.x;
- }
- if (str == "y") {
- valid = true;
- return ie.screen_touch.y;
- }
- if (str == "pos") {
- valid = true;
- return Vector2(ie.screen_touch.x, ie.screen_touch.y);
- }
- if (str == "pressed") {
- valid = true;
- return ie.screen_touch.pressed;
- }
- }
-
- if (ie.type == InputEvent::SCREEN_DRAG) {
-
- if (str == "index") {
- valid = true;
- return ie.screen_drag.index;
- }
- if (str == "x") {
- valid = true;
- return ie.screen_drag.x;
- }
- if (str == "y") {
- valid = true;
- return ie.screen_drag.y;
- }
- if (str == "pos") {
- valid = true;
- return Vector2(ie.screen_drag.x, ie.screen_drag.y);
- }
- if (str == "relative_x") {
- valid = true;
- return ie.screen_drag.relative_x;
- }
- if (str == "relative_y") {
- valid = true;
- return ie.screen_drag.relative_y;
- }
- if (str == "relative_pos") {
- valid = true;
- return Vector2(ie.screen_drag.relative_x, ie.screen_drag.relative_y);
- }
- if (str == "speed_x") {
- valid = true;
- return ie.screen_drag.speed_x;
- }
- if (str == "speed_y") {
- valid = true;
- return ie.screen_drag.speed_y;
- }
- if (str == "speed") {
- valid = true;
- return Vector2(ie.screen_drag.speed_x, ie.screen_drag.speed_y);
- }
- }
- if (ie.type == InputEvent::ACTION) {
-
- if (str == "action") {
- valid = true;
- return ie.action.action;
- } else if (str == "pressed") {
- valid = true;
- return ie.action.pressed;
- }
- }
-
- } break;
case DICTIONARY: {
const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem);
@@ -2823,94 +2201,6 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
}
} break;
- case INPUT_EVENT: {
-
- InputEvent ie = operator InputEvent();
-
- p_list->push_back(PropertyInfo(Variant::INT, "type"));
- p_list->push_back(PropertyInfo(Variant::INT, "device"));
- p_list->push_back(PropertyInfo(Variant::INT, "ID"));
-
- if (ie.type == InputEvent::KEY || ie.type == InputEvent::MOUSE_BUTTON || ie.type == InputEvent::MOUSE_MOTION) {
-
- p_list->push_back(PropertyInfo(Variant::BOOL, "shift"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "alt"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "control"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "meta"));
- }
-
- if (ie.type == InputEvent::KEY) {
-
- p_list->push_back(PropertyInfo(Variant::BOOL, "pressed"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "echo"));
- p_list->push_back(PropertyInfo(Variant::INT, "scancode"));
- p_list->push_back(PropertyInfo(Variant::INT, "unicode"));
- }
-
- if (ie.type == InputEvent::MOUSE_MOTION || ie.type == InputEvent::MOUSE_BUTTON) {
-
- p_list->push_back(PropertyInfo(Variant::INT, "button_mask"));
- p_list->push_back(PropertyInfo(Variant::REAL, "x"));
- p_list->push_back(PropertyInfo(Variant::REAL, "y"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2, "pos"));
- p_list->push_back(PropertyInfo(Variant::REAL, "global_x"));
- p_list->push_back(PropertyInfo(Variant::REAL, "global_y"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2, "global_pos"));
-
- if (ie.type == InputEvent::MOUSE_MOTION) {
-
- p_list->push_back(PropertyInfo(Variant::REAL, "relative_x"));
- p_list->push_back(PropertyInfo(Variant::REAL, "relative_y"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2, "relative_pos"));
- p_list->push_back(PropertyInfo(Variant::REAL, "speed_x"));
- p_list->push_back(PropertyInfo(Variant::REAL, "speed_y"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2, "speed"));
-
- } else if (ie.type == InputEvent::MOUSE_BUTTON) {
-
- p_list->push_back(PropertyInfo(Variant::INT, "button_index"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "pressed"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "doubleclick"));
- }
- }
-
- if (ie.type == InputEvent::JOYPAD_BUTTON) {
-
- p_list->push_back(PropertyInfo(Variant::INT, "button_index"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "pressed"));
- p_list->push_back(PropertyInfo(Variant::REAL, "pressure"));
- }
-
- if (ie.type == InputEvent::JOYPAD_MOTION) {
-
- p_list->push_back(PropertyInfo(Variant::INT, "axis"));
- p_list->push_back(PropertyInfo(Variant::REAL, "value"));
- }
-
- if (ie.type == InputEvent::SCREEN_TOUCH) {
-
- p_list->push_back(PropertyInfo(Variant::INT, "index"));
- p_list->push_back(PropertyInfo(Variant::REAL, "x"));
- p_list->push_back(PropertyInfo(Variant::REAL, "y"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2, "pos"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "pressed"));
- }
-
- if (ie.type == InputEvent::SCREEN_DRAG) {
-
- p_list->push_back(PropertyInfo(Variant::INT, "index"));
- p_list->push_back(PropertyInfo(Variant::REAL, "x"));
- p_list->push_back(PropertyInfo(Variant::REAL, "y"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2, "pos"));
- p_list->push_back(PropertyInfo(Variant::REAL, "relative_x"));
- p_list->push_back(PropertyInfo(Variant::REAL, "relative_y"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2, "relative_pos"));
- p_list->push_back(PropertyInfo(Variant::REAL, "speed_x"));
- p_list->push_back(PropertyInfo(Variant::REAL, "speed_y"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2, "speed"));
- }
-
- } break;
case DICTIONARY: {
const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem);
@@ -3636,10 +2926,6 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
r_dst = a;
}
return;
- case INPUT_EVENT: {
- r_dst = a;
- }
- return;
case DICTIONARY: {
}
return;
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index 798a830dd0..0d4d0429e7 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -30,6 +30,7 @@
#include "variant_parser.h"
#include "io/resource_loader.h"
+#include "os/input_event.h"
#include "os/keyboard.h"
CharType VariantParser::StreamFile::get_char() {
@@ -760,7 +761,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
}
return OK;
-
+#ifndef DISABLE_DEPRECATED
} else if (id == "InputEvent") {
get_token(p_stream, token, line, r_err_str);
@@ -778,12 +779,10 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
String id = token.value;
- InputEvent ie;
+ Ref<InputEvent> ie;
if (id == "NONE") {
- ie.type = InputEvent::NONE;
-
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_PARENTHESIS_CLOSE) {
@@ -793,21 +792,23 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
} else if (id == "KEY") {
+ Ref<InputEventKey> key;
+ key.instance();
+ ie = key;
+
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_COMMA) {
r_err_str = "Expected ','";
return ERR_PARSE_ERROR;
}
- ie.type = InputEvent::KEY;
-
get_token(p_stream, token, line, r_err_str);
if (token.type == TK_IDENTIFIER) {
String name = token.value;
- ie.key.scancode = find_keycode(name);
+ key->set_scancode(find_keycode(name));
} else if (token.type == TK_NUMBER) {
- ie.key.scancode = token.value;
+ key->set_scancode(token.value);
} else {
r_err_str = "Expected string or integer for keycode";
@@ -828,13 +829,13 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
String mods = token.value;
if (mods.findn("C") != -1)
- ie.key.mod.control = true;
+ key->set_control(true);
if (mods.findn("A") != -1)
- ie.key.mod.alt = true;
+ key->set_alt(true);
if (mods.findn("S") != -1)
- ie.key.mod.shift = true;
+ key->set_shift(true);
if (mods.findn("M") != -1)
- ie.key.mod.meta = true;
+ key->set_metakey(true);
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_PARENTHESIS_CLOSE) {
@@ -850,21 +851,23 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
} else if (id == "MBUTTON") {
+ Ref<InputEventMouseButton> mb;
+ mb.instance();
+ ie = mb;
+
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_COMMA) {
r_err_str = "Expected ','";
return ERR_PARSE_ERROR;
}
- ie.type = InputEvent::MOUSE_BUTTON;
-
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_NUMBER) {
r_err_str = "Expected button index";
return ERR_PARSE_ERROR;
}
- ie.mouse_button.button_index = token.value;
+ mb->set_button_index(token.value);
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_PARENTHESIS_CLOSE) {
@@ -874,21 +877,23 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
} else if (id == "JBUTTON") {
+ Ref<InputEventJoypadButton> jb;
+ jb.instance();
+ ie = jb;
+
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_COMMA) {
r_err_str = "Expected ','";
return ERR_PARSE_ERROR;
}
- ie.type = InputEvent::JOYPAD_BUTTON;
-
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_NUMBER) {
r_err_str = "Expected button index";
return ERR_PARSE_ERROR;
}
- ie.joy_button.button_index = token.value;
+ jb->set_button_index(token.value);
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_PARENTHESIS_CLOSE) {
@@ -898,21 +903,23 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
} else if (id == "JAXIS") {
+ Ref<InputEventJoypadMotion> jm;
+ jm.instance();
+ ie = jm;
+
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_COMMA) {
r_err_str = "Expected ','";
return ERR_PARSE_ERROR;
}
- ie.type = InputEvent::JOYPAD_MOTION;
-
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_NUMBER) {
r_err_str = "Expected axis index";
return ERR_PARSE_ERROR;
}
- ie.joy_motion.axis = token.value;
+ jm->set_axis(token.value);
get_token(p_stream, token, line, r_err_str);
@@ -927,7 +934,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return ERR_PARSE_ERROR;
}
- ie.joy_motion.axis_value = token.value;
+ jm->set_axis_value(token.value);
get_token(p_stream, token, line, r_err_str);
@@ -945,7 +952,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
value = ie;
return OK;
-
+#endif
} else if (id == "PoolByteArray" || id == "ByteArray") {
Vector<uint8_t> args;
@@ -1121,91 +1128,6 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
value = arr;
return OK;
- } else if (id == "key") { // compatibility with project.godot
-
- Vector<String> params;
- Error err = _parse_enginecfg(p_stream, params, line, r_err_str);
- if (err)
- return err;
- ERR_FAIL_COND_V(params.size() != 1 && params.size() != 2, ERR_PARSE_ERROR);
-
- int scode = 0;
-
- if (params[0].is_numeric()) {
- scode = params[0].to_int();
- if (scode < 10) {
- scode = KEY_0 + scode;
- }
- } else
- scode = find_keycode(params[0]);
-
- InputEvent ie;
- ie.type = InputEvent::KEY;
- ie.key.scancode = scode;
-
- if (params.size() == 2) {
- String mods = params[1];
- if (mods.findn("C") != -1)
- ie.key.mod.control = true;
- if (mods.findn("A") != -1)
- ie.key.mod.alt = true;
- if (mods.findn("S") != -1)
- ie.key.mod.shift = true;
- if (mods.findn("M") != -1)
- ie.key.mod.meta = true;
- }
- value = ie;
- return OK;
-
- } else if (id == "mbutton") { // compatibility with project.godot
-
- Vector<String> params;
- Error err = _parse_enginecfg(p_stream, params, line, r_err_str);
- if (err)
- return err;
- ERR_FAIL_COND_V(params.size() != 2, ERR_PARSE_ERROR);
-
- InputEvent ie;
- ie.type = InputEvent::MOUSE_BUTTON;
- ie.device = params[0].to_int();
- ie.mouse_button.button_index = params[1].to_int();
-
- value = ie;
- return OK;
- } else if (id == "jbutton") { // compatibility with project.godot
-
- Vector<String> params;
- Error err = _parse_enginecfg(p_stream, params, line, r_err_str);
- if (err)
- return err;
- ERR_FAIL_COND_V(params.size() != 2, ERR_PARSE_ERROR);
- InputEvent ie;
- ie.type = InputEvent::JOYPAD_BUTTON;
- ie.device = params[0].to_int();
- ie.joy_button.button_index = params[1].to_int();
-
- value = ie;
-
- return OK;
- } else if (id == "jaxis") { // compatibility with project.godot
-
- Vector<String> params;
- Error err = _parse_enginecfg(p_stream, params, line, r_err_str);
- if (err)
- return err;
- ERR_FAIL_COND_V(params.size() != 2, ERR_PARSE_ERROR);
-
- InputEvent ie;
- ie.type = InputEvent::JOYPAD_MOTION;
- ie.device = params[0].to_int();
- int axis = params[1].to_int();
- ie.joy_motion.axis = axis >> 1;
- ie.joy_motion.axis_value = axis & 1 ? 1 : -1;
-
- value = ie;
-
- return OK;
-
} else {
r_err_str = "Unexpected identifier: '" + id + "'.";
return ERR_PARSE_ERROR;
@@ -1715,50 +1637,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, res_text);
} break;
- case Variant::INPUT_EVENT: {
-
- String str = "InputEvent(";
-
- InputEvent ev = p_variant;
- switch (ev.type) {
- case InputEvent::KEY: {
-
- str += "KEY," + itos(ev.key.scancode);
- String mod;
- if (ev.key.mod.alt)
- mod += "A";
- if (ev.key.mod.shift)
- mod += "S";
- if (ev.key.mod.control)
- mod += "C";
- if (ev.key.mod.meta)
- mod += "M";
-
- if (mod != String())
- str += "," + mod;
- } break;
- case InputEvent::MOUSE_BUTTON: {
-
- str += "MBUTTON," + itos(ev.mouse_button.button_index);
- } break;
- case InputEvent::JOYPAD_BUTTON: {
- str += "JBUTTON," + itos(ev.joy_button.button_index);
-
- } break;
- case InputEvent::JOYPAD_MOTION: {
- str += "JAXIS," + itos(ev.joy_motion.axis) + "," + itos(ev.joy_motion.axis_value);
- } break;
- case InputEvent::NONE: {
- str += "NONE";
- } break;
- default: {}
- }
- str += ")";
-
- p_store_string_func(p_store_string_ud, str); //will be added later
-
- } break;
case Variant::DICTIONARY: {
Dictionary dict = p_variant;