After reading the related docs I don't get if I can create things like buttons or other UI elements used to get user inputs with just the use of C++/C code compiled with the NDK.

There are no problems when i want to handle a "window" or activity that needs to stay in focus, but I don't get how to build an UI with elements for callbacks and user input.

It's strange that there is a windowing framework in place but without any trace of callbacks for UI elements.

Can I build touch buttons or a virtual gamepad with the NDK ?

---

I appreciate the effort and the fact that we are getting closer to my point but apparently i wasn't explaining myself good enough.

I found this image [here](https://stackoverflow.com/questions/12687575/touch-buttons-and-controllers-with-the-ndk-and-native-activities-only-c-c)
![enter image description here](https://i.stack.imgur.com/P7fNj.png)

Now my problem and the focus of this question is:

Supposing that i can place and draw this virtual joystick, how i can detect only the movements and have a callback like `Joystick.onUp` or `Joystick.onDown` with Android and using only the NDK ?

If there are no callbacks of this kind available from the NDK, I'm supposed to detect the [x,y] position everytime, compare it to the location of my joystick, store the previous position, compare the previous position and the next one to get the direction ?

Since the sensor throws events at a really fast rate, i think that building this on my own considering only the raw X,Y couple, will end up in having a really inefficient control system because it will not be optimized at OS level with the appropriate sensor calls.

According to the NativeActivity example it's also unclear how to handle multiple touch point, for example how i can handle 2 touch event at the same time ?

Just consider the image above and think about having only x,y coordinate for 1 touch point and how i can solve this in an efficient way that is supported by the NDK.

Thanks.