Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android ndk multitouch?

im writing an application that uses only native code.
So is it possible to get multitouch events in ndk?
I feel like ive serched the whole web, but without finding anything!

Does anyone know how to do this?

like image 317
bricklore Avatar asked Sep 19 '12 18:09

bricklore


People also ask

How do you handle single and multi-touch?

You can react to touch events in your custom views and your activities. Android supports multiple pointers, e.g. fingers which are interacting with the screen. The base class for touch support is the MotionEvent class which is passed to Views via the onTouchEvent() method. you override the onTouchEvent() method.

Which MotionEvent constant is used to detect multi-touch gesture?

When multiple pointers touch the screen at the same time, the system generates the following touch events: ACTION_DOWN —For the first pointer that touches the screen. This starts the gesture. The pointer data for this pointer is always at index 0 in the MotionEvent .


1 Answers

Yes, it is. You can check example called native-activity to see how to get input events. Look for engine_handle_input function. AInputEvent_getType function returns type of event. If it is AINPUT_EVENT_TYPE_MOTION then using AKeyEvent_getAction function you can get different information about touch event. Use the AMOTION_EVENT_ACTION_MASK, AMOTION_EVENT_ACTION_POINTER_INDEX_MASK, AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP enums in same way you use them in Java API: http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html

like image 54
Mārtiņš Možeiko Avatar answered Oct 14 '22 06:10

Mārtiņš Možeiko