Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix touch input on Linux #14117

Merged
merged 1 commit into from Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/gui/modalMenu.cpp
Expand Up @@ -273,7 +273,7 @@ bool GUIModalMenu::preprocessEvent(const SEvent &event)
irr_ptr<GUIModalMenu> holder;
holder.grab(this); // keep this alive until return (it might be dropped downstream [?])

if (event.TouchInput.ID == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouch, this shouldn't have passed code review. easy to miss however.

It sounds like what the code should be doing is remember the ID of the first and second touch when they begin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not realise that the ID assignment is different for each device. I just checked on my phone and thought that it resets to zero when there is no touch. My bad.

if (event.TouchInput.touchedCount == 1) {
if (event.TouchInput.Event == ETIE_PRESSED_DOWN || event.TouchInput.Event == ETIE_MOVED)
m_pointer = v2s32(event.TouchInput.X, event.TouchInput.Y);
gui::IGUIElement *hovered = Environment->getRootGUIElement()->getElementFromPoint(core::position2d<s32>(m_pointer));
Expand All @@ -290,7 +290,7 @@ bool GUIModalMenu::preprocessEvent(const SEvent &event)
if (event.TouchInput.Event == ETIE_LEFT_UP)
leave();
return ret;
} else if (event.TouchInput.ID == 1) {
} else if (event.TouchInput.touchedCount == 2) {
if (event.TouchInput.Event != ETIE_LEFT_UP)
return true; // ignore
auto focused = Environment->getFocus();
Expand Down