| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 #ifndef EMBEDDERS_OPENGLUI_ANDROID_EVENTLOOP_H_ | |
| 6 #define EMBEDDERS_OPENGLUI_ANDROID_EVENTLOOP_H_ | |
| 7 | |
| 8 #include <android_native_app_glue.h> | |
| 9 #include <android/sensor.h> | |
| 10 #include "embedders/openglui/common/events.h" | |
| 11 #include "embedders/openglui/common/input_handler.h" | |
| 12 #include "embedders/openglui/common/lifecycle_handler.h" | |
| 13 | |
| 14 class EventLoop { | |
| 15 public: | |
| 16 explicit EventLoop(android_app* application); | |
| 17 void Run(LifeCycleHandler* activity_handler, | |
| 18 InputHandler* input_handler); | |
| 19 | |
| 20 protected: | |
| 21 void EnableSensorEvents(); | |
| 22 void DisableSensorEvents(); | |
| 23 | |
| 24 void ProcessActivityEvent(int32_t command); | |
| 25 int32_t ProcessInputEvent(AInputEvent* event); | |
| 26 void ProcessSensorEvent(); | |
| 27 | |
| 28 bool OnTouchEvent(AInputEvent* event); | |
| 29 bool OnKeyEvent(AInputEvent* event); | |
| 30 | |
| 31 static void ActivityCallback(android_app* application, int32_t command); | |
| 32 static int32_t InputCallback(android_app* application, AInputEvent* event); | |
| 33 static void SensorCallback(android_app* application, | |
| 34 android_poll_source* source); | |
| 35 | |
| 36 private: | |
| 37 friend class Sensor; | |
| 38 | |
| 39 bool enabled_, quit_; | |
| 40 bool isResumed_, hasSurface_, hasFocus_; | |
| 41 android_app* application_; | |
| 42 LifeCycleHandler* lifecycle_handler_; | |
| 43 InputHandler* input_handler_; | |
| 44 const ASensor* sensor_; | |
| 45 ASensorManager* sensor_manager_; | |
| 46 ASensorEventQueue* sensor_event_queue_; | |
| 47 android_poll_source sensor_poll_source_; | |
| 48 }; | |
| 49 | |
| 50 #endif // EMBEDDERS_OPENGLUI_ANDROID_EVENTLOOP_H_ | |
| 51 | |
| OLD | NEW |