Add support for event accumlation (off by default, on for editor), fixes #26536
This commit is contained in:
@ -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;
|
||||
|
||||
@ -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();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user