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
[no squash] Auto-toggle TouchScreenGUI in-game when receiving touch/mouse input #14542
base: master
Are you sure you want to change the base?
Conversation
e3adfb7
to
f4ca1ea
Compare
I've finally been able to fix the camera jump issue on Android using two changes from MoNTE48/irrlicht and one own change. Idk why this combination of changes works, but it does work and I've spent too many hours on this bug already. The remaining hard issue is the "fake mouse events on X11" one. |
MouseY = irrevent.MouseInput.Y = SDL_event.motion.y; | ||
} else { | ||
MouseX = irrevent.MouseInput.X = MouseX + SDL_event.motion.xrel; | ||
MouseY = irrevent.MouseInput.Y = MouseY + SDL_event.motion.yrel; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this make a difference on platforms other than Android? at least Multicraft Irrlicht also applies it on all platforms: https://github.com/MoNTE48/Irrlicht/blob/a2910941a0c64e58f294e3e4aa041fb6f7a1db9a/source/Irrlicht/CIrrDeviceSDL.cpp#L856-L865
9d37510
to
da9f2ea
Compare
This PR now implements the approach suggested by @okias since my own idea didn't work as well:
slightly modified, original by okias in #14400 (comment) I've also renamed @okias Would you be interested in giving my changes a review? There's still some cleanup of accumulated quick-and-dirty fixes to do, but the PR should be ready in terms of concept and features now. |
src/defaultsettings.cpp
Outdated
// where fake mouse events were generated from touch events if in relative | ||
// mouse, resulting in the touchscreen controls being instantly disabled again | ||
// and thus making them unusable. Therefore, I've disabled automatic switching. | ||
settings->setDefault("touch_controls", "false"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obviously suboptimal. I still don't even know whether that bug is a general one or specific to my system. But it works.
EDIT: Actually, the fallback should be bool_to_cstr(has_touch)
, not false
(already applied)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would go with .. I missed the edit 😉bool_to_cstr(has_touch)
here (for the workaround)
But I hope after next release there will be rewrite, where UI will become hack-free for touchscreen and just universal code for both desktop and mobile. |
to avoid confusion between touchscreen-related settings that affect GUIs (formspecs) and touchscreen-related settings that affect the touch controls (TouchControls / formerly TouchScreenGUI)
With this PR, the touch controls are automatically created/deleted based on the last used pointer type (mouse or touch).
It is based on #14472 because before that PR, TouchScreenGUI didn't ever delete its IGUIButtons, it just hid them. They were deleted somewhere else on shutdown. While this worked without in-game creation/deletion of TouchScreenGUIs, it would result in memory leaks with this PR.
Note that no automatic switching is done on keyboard input. This is because TouchScreenGUI + keyboard works while TouchScreenGUI + mouse doesn't.
Related: #14400, #14400 (comment), #14400 (comment)
To do
This PR is a Work in Progress.
enable_touch
setting as well?How to test
Buy an Android phone, a bluetooth mouse and a bluetooth keyboard. See that the touch controls are automatically created/deleted when you use the touchscreen/mouse.