From 74dbff4e7e7cd427ac50820cc6366ea421d4d049 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 19 Dec 2014 03:30:41 +0200 Subject: [PATCH] Add touchscreen support on Android --- source/input/android/mouse.cpp | 4 ++++ source/input/android/touchscreen.cpp | 28 +++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) 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