Time for action – handling touch events
Let's intercept touch events in DroidBlaster
:
- In the same way that we created
ActivityHandler
to process application events in Chapter 5, Writing a Fully Native Application, createjni/InputHandler.hpp
to process input events. The input API is declared inandroid/input.h
. CreateonTouchEvent()
to handle touch events. These events are packaged in anAInputEvent
structure. Other input peripherals will be described later in this chapter:#ifndef _PACKT_INPUTHANDLER_HPP_ #define _PACKT_INPUTHANDLER_HPP_ #include <android/input.h> class InputHandler { public: virtual ~InputHandler() {}; virtual bool onTouchEvent(AInputEvent* pEvent) = 0; }; #endif
- Modify the
jni/EventLoop.hpp
header file to include and handle an ...
Get Android NDK Beginner's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.