| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef EMBEDDERS_OPENGLUI_ANDROID_EVENTLOOP_H_ | 5 #ifndef EMBEDDERS_OPENGLUI_ANDROID_EVENTLOOP_H_ |
| 6 #define EMBEDDERS_OPENGLUI_ANDROID_EVENTLOOP_H_ | 6 #define EMBEDDERS_OPENGLUI_ANDROID_EVENTLOOP_H_ |
| 7 | 7 |
| 8 #include <android_native_app_glue.h> | 8 #include <android_native_app_glue.h> |
| 9 #include "embedders/openglui/common/events.h" | 9 #include "embedders/openglui/common/events.h" |
| 10 #include "embedders/openglui/common/input_handler.h" | 10 #include "embedders/openglui/common/input_handler.h" |
| 11 #include "embedders/openglui/common/lifecycle_handler.h" | 11 #include "embedders/openglui/common/lifecycle_handler.h" |
| 12 | 12 |
| 13 class EventLoop { | 13 class EventLoop { |
| 14 public: | 14 public: |
| 15 explicit EventLoop(android_app* application); | 15 explicit EventLoop(android_app* application); |
| 16 void Run(LifeCycleHandler* activity_handler, | 16 void Run(LifeCycleHandler* activity_handler, |
| 17 InputHandler* input_handler); | 17 InputHandler* input_handler); |
| 18 | 18 |
| 19 protected: | 19 protected: |
| 20 void Activate(); | |
| 21 void Deactivate(); | |
| 22 void ProcessActivityEvent(int32_t command); | 20 void ProcessActivityEvent(int32_t command); |
| 23 int32_t ProcessInputEvent(AInputEvent* event); | 21 int32_t ProcessInputEvent(AInputEvent* event); |
| 24 bool OnTouchEvent(AInputEvent* event); | 22 bool OnTouchEvent(AInputEvent* event); |
| 25 bool OnKeyEvent(AInputEvent* event); | 23 bool OnKeyEvent(AInputEvent* event); |
| 26 | 24 |
| 27 static void ActivityCallback(android_app* application, int32_t command); | 25 static void ActivityCallback(android_app* application, int32_t command); |
| 28 static int32_t InputCallback(android_app* application, AInputEvent* event); | 26 static int32_t InputCallback(android_app* application, AInputEvent* event); |
| 29 | 27 |
| 30 private: | 28 private: |
| 31 bool enabled_; | 29 bool enabled_, quit_; |
| 32 bool quit_; | 30 bool isResumed_, hasSurface_, hasFocus_; |
| 33 android_app* application_; | 31 android_app* application_; |
| 34 LifeCycleHandler* lifecycle_handler_; | 32 LifeCycleHandler* lifecycle_handler_; |
| 35 InputHandler* input_handler_; | 33 InputHandler* input_handler_; |
| 36 }; | 34 }; |
| 37 | 35 |
| 38 #endif // EMBEDDERS_OPENGLUI_ANDROID_EVENTLOOP_H_ | 36 #endif // EMBEDDERS_OPENGLUI_ANDROID_EVENTLOOP_H_ |
| 39 | 37 |
| OLD | NEW |