Using HashMap to track touches on web
Modified how display_server_web.h stores info about touches to fix bug described by issue https://github.com/godotengine/godot/issues/94346.
This commit is contained in:
parent
88d9325065
commit
00555a54c5
|
@ -673,7 +673,7 @@ void DisplayServerWeb::_touch_callback(int p_type, int p_count) {
|
||||||
ev->set_index(touch_event.identifier[i]);
|
ev->set_index(touch_event.identifier[i]);
|
||||||
ev->set_position(point);
|
ev->set_position(point);
|
||||||
|
|
||||||
Point2 &prev = ds->touches[i];
|
Point2 &prev = ds->touches[touch_event.identifier[i]];
|
||||||
ev->set_relative(ev->get_position() - prev);
|
ev->set_relative(ev->get_position() - prev);
|
||||||
ev->set_relative_screen_position(ev->get_relative());
|
ev->set_relative_screen_position(ev->get_relative());
|
||||||
prev = ev->get_position();
|
prev = ev->get_position();
|
||||||
|
@ -690,7 +690,12 @@ void DisplayServerWeb::_touch_callback(int p_type, int p_count) {
|
||||||
ev->set_index(touch_event.identifier[i]);
|
ev->set_index(touch_event.identifier[i]);
|
||||||
ev->set_position(point);
|
ev->set_position(point);
|
||||||
ev->set_pressed(p_type == 0);
|
ev->set_pressed(p_type == 0);
|
||||||
ds->touches[i] = point;
|
|
||||||
|
if (p_type == 0) {
|
||||||
|
ds->touches[touch_event.identifier[i]] = point;
|
||||||
|
} else {
|
||||||
|
ds->touches.erase(touch_event.identifier[i]);
|
||||||
|
}
|
||||||
|
|
||||||
Input::get_singleton()->parse_input_event(ev);
|
Input::get_singleton()->parse_input_event(ev);
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ private:
|
||||||
Callable drop_files_callback;
|
Callable drop_files_callback;
|
||||||
|
|
||||||
String clipboard;
|
String clipboard;
|
||||||
Point2 touches[32];
|
HashMap<uint32_t, Point2> touches;
|
||||||
|
|
||||||
Array voices;
|
Array voices;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue