summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2019-03-03 19:52:18 -0300
committerJuan Linietsky <juan@godotengine.org>2019-03-03 19:53:13 -0300
commita1e73dcc944627ab7185aec7cd4141fe4ebb97d7 (patch)
tree917b9912d48607e19d214a0e3931dd325f75d1e6 /main
parenta9fe834a8e962a7b9e15e5dc218af4b857b47da4 (diff)
Add support for event accumlation (off by default, on for editor), fixes #26536
Diffstat (limited to 'main')
-rw-r--r--main/input_default.cpp27
-rw-r--r--main/input_default.h8
2 files changed, 35 insertions, 0 deletions
diff --git a/main/input_default.cpp b/main/input_default.cpp
index 18b4649f4d..fd76b91a0b 100644
--- a/main/input_default.cpp
+++ b/main/input_default.cpp
@@ -657,8 +657,35 @@ void InputDefault::set_mouse_in_window(bool p_in_window) {
*/
}
+void InputDefault::accumulate_input_event(const Ref<InputEvent> &p_event) {
+ ERR_FAIL_COND(p_event.is_null());
+
+ if (!use_accumulated_input) {
+ parse_input_event(p_event);
+ return;
+ }
+ if (!accumulated_events.empty() && accumulated_events.back()->get()->accumulate(p_event)) {
+ return; //event was accumulated, exit
+ }
+
+ accumulated_events.push_back(p_event);
+}
+void InputDefault::flush_accumulated_events() {
+
+ while (accumulated_events.front()) {
+ parse_input_event(accumulated_events.front()->get());
+ accumulated_events.pop_front();
+ }
+}
+
+void InputDefault::set_use_accumulated_input(bool p_enable) {
+
+ use_accumulated_input = p_enable;
+}
+
InputDefault::InputDefault() {
+ use_accumulated_input = false;
mouse_button_mask = 0;
emulate_touch_from_mouse = false;
emulate_mouse_from_touch = false;
diff --git a/main/input_default.h b/main/input_default.h
index 75dd1e67f6..79a90cc4a4 100644
--- a/main/input_default.h
+++ b/main/input_default.h
@@ -183,6 +183,9 @@ private:
void _parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_emulated);
+ List<Ref<InputEvent> > accumulated_events;
+ bool use_accumulated_input;
+
public:
virtual bool is_key_pressed(int p_scancode) const;
virtual bool is_mouse_button_pressed(int p_button) const;
@@ -264,6 +267,11 @@ public:
bool is_joy_mapped(int p_device);
String get_joy_guid_remapped(int p_device) const;
void set_fallback_mapping(String p_guid);
+
+ virtual void accumulate_input_event(const Ref<InputEvent> &p_event);
+ virtual void flush_accumulated_events();
+ virtual void set_use_accumulated_input(bool p_enable);
+
InputDefault();
};