Improve input event accumulation
- API has been simplified: all events now go through `parse_input_event()`. Whether they are accumulated or not depends on the `use_accumulated_input` flag. - Event accumulation is now thread-safe (it was not needed so far, but it prepares the ground for the following changes). - Touch drag events now support accumulation.
This commit is contained in:
@ -1210,6 +1210,22 @@ String InputEventScreenDrag::to_string() {
|
||||
return vformat("InputEventScreenDrag: index=%d, position=(%s), relative=(%s), speed=(%s)", index, String(get_position()), String(get_relative()), String(get_speed()));
|
||||
}
|
||||
|
||||
bool InputEventScreenDrag::accumulate(const Ref<InputEvent> &p_event) {
|
||||
Ref<InputEventScreenDrag> drag = p_event;
|
||||
if (drag.is_null())
|
||||
return false;
|
||||
|
||||
if (get_index() != drag->get_index()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set_position(drag->get_position());
|
||||
set_speed(drag->get_speed());
|
||||
relative += drag->get_relative();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user