From b65bde6b91c05fb9e90ceae8d65e5af1e1a7d1ab Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Fri, 29 Mar 2013 18:03:57 +0000 Subject: [PATCH] android: add a temporary hack for mouse emulation on Android devices. --- src/platform/android/androidapp.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/platform/android/androidapp.cpp b/src/platform/android/androidapp.cpp index 7f15c9b6..de12f91c 100644 --- a/src/platform/android/androidapp.cpp +++ b/src/platform/android/androidapp.cpp @@ -91,6 +91,10 @@ public: android_app* m_native_app; + /* The resolution that was asked (not the one we got) */ + /* FIXME: we need proper unproject or at least screen space events!! */ + ivec2 m_wanted_resolution; + SavedState m_state; private: @@ -200,8 +204,12 @@ int32_t lol::AndroidAppData::HandleInput(AInputEvent* event) switch (AInputEvent_getType(event)) { case AINPUT_EVENT_TYPE_MOTION: - Input::SetMousePos(ivec2(AMotionEvent_getX(event, 0), - AMotionEvent_getY(event, 0))); + /* FIXME: we flip the Y axis here, but is it the right place? */ + ivec2 pos(AMotionEvent_getX(event, 0), + AMotionEvent_getY(event, 0)); + pos = pos * m_wanted_resolution / Video::GetSize(); + pos.y = m_wanted_resolution.y - 1 - pos.y; + Input::SetMousePos(pos); switch (AKeyEvent_getAction(event) & AMOTION_EVENT_ACTION_MASK) { case AMOTION_EVENT_ACTION_DOWN: @@ -284,7 +292,7 @@ void android_main(android_app* native_app) lol::AndroidApp::AndroidApp(char const *title, ivec2 res, float fps) : m_data(g_data) { - ; + m_data->m_wanted_resolution = res; } void lol::AndroidApp::ShowPointer(bool show)