From 1225fd2b70055c9c68833ce7e854b756c132e23a Mon Sep 17 00:00:00 2001 From: mgood7123 Date: Fri, 11 Jun 2021 23:25:29 +1000 Subject: [PATCH] reset relative position to stay relative with desktop --- src/Magnum/Platform/AndroidApplication.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Magnum/Platform/AndroidApplication.cpp b/src/Magnum/Platform/AndroidApplication.cpp index d70dccbd2..bf3bbe111 100644 --- a/src/Magnum/Platform/AndroidApplication.cpp +++ b/src/Magnum/Platform/AndroidApplication.cpp @@ -256,7 +256,17 @@ std::int32_t AndroidApplication::inputEvent(android_app* state, AInputEvent* eve always */ app._previousMouseMovePosition = {Int(AMotionEvent_getX(event, 0)), Int(AMotionEvent_getY(event, 0))}; MouseEvent e(event); - action == AMOTION_EVENT_ACTION_DOWN ? app.mousePressEvent(e) : app.mouseReleaseEvent(e); + if (action == AMOTION_EVENT_ACTION_DOWN) { + app.mousePressEvent(e); + } else { + app.mouseReleaseEvent(e); + // reset the relative position + // if the relative position is not reset, then + // the relative position of mouse press will be + // relative to the last location of mouse release + // which differs from desktop behaviour + app._previousMouseMovePosition = Vector2i{-1}; + } return e.isAccepted() ? 1 : 0; }