From: Mikko Rasa Date: Fri, 19 Dec 2014 01:30:41 +0000 (+0200) Subject: Add touchscreen support on Android X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=74dbff4e7e7cd427ac50820cc6366ea421d4d049;p=libs%2Fgui.git Add touchscreen support on Android --- diff --git a/source/input/android/mouse.cpp b/source/input/android/mouse.cpp index b16b6be..3fbc5be 100644 --- a/source/input/android/mouse.cpp +++ b/source/input/android/mouse.cpp @@ -10,6 +10,10 @@ void Mouse::input_event(const Graphics::Window::Event &event) if(type!=AINPUT_EVENT_TYPE_MOTION) return; + int source = AInputEvent_getSource(event.aevent); + if(window.get_touch_input() && source!=AINPUT_SOURCE_MOUSE && source!=AINPUT_SOURCE_TOUCHPAD) + return; + /* Emulate a mouse with the touch events of a single finger. If more fingers appear while the first one is held down, they are ignored, even if the first finger is released. */ diff --git a/source/input/android/touchscreen.cpp b/source/input/android/touchscreen.cpp index bfbf7aa..f4703c3 100644 --- a/source/input/android/touchscreen.cpp +++ b/source/input/android/touchscreen.cpp @@ -1,10 +1,36 @@ +#include #include "touchscreen.h" namespace Msp { namespace Input { -void Touchscreen::input_event(const Graphics::Window::Event &) +void Touchscreen::input_event(const Graphics::Window::Event &event) { + int action = AMotionEvent_getAction(event.aevent); + int action_pointer = (action&AMOTION_EVENT_ACTION_POINTER_INDEX_MASK)>>AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; + action &= AMOTION_EVENT_ACTION_MASK; + + int pointer_count = AMotionEvent_getPointerCount(event.aevent); + for(int i=0; i