Tony Barbour | 2f18b29 | 2016-02-25 15:44:10 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 Google, Inc. |
| 3 | * |
Jon Ashburn | 43b53e8 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
Tony Barbour | 2f18b29 | 2016-02-25 15:44:10 -0700 | [diff] [blame] | 7 | * |
Jon Ashburn | 43b53e8 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Tony Barbour | 2f18b29 | 2016-02-25 15:44:10 -0700 | [diff] [blame] | 9 | * |
Jon Ashburn | 43b53e8 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
Tony Barbour | 2f18b29 | 2016-02-25 15:44:10 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #ifndef SHELL_ANDROID_H |
| 18 | #define SHELL_ANDROID_H |
| 19 | |
| 20 | #include <android_native_app_glue.h> |
| 21 | #include "Shell.h" |
| 22 | |
| 23 | class ShellAndroid : public Shell { |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 24 | public: |
Cody Northrop | cf4815b | 2016-12-02 11:25:54 -0700 | [diff] [blame] | 25 | static std::vector<std::string> get_args(android_app &app); |
| 26 | |
Tony Barbour | 2f18b29 | 2016-02-25 15:44:10 -0700 | [diff] [blame] | 27 | ShellAndroid(android_app &app, Game &game); |
| 28 | ~ShellAndroid(); |
| 29 | |
| 30 | void log(LogPriority priority, const char *msg); |
| 31 | |
| 32 | void run(); |
| 33 | void quit(); |
| 34 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 35 | private: |
Tony Barbour | 2f18b29 | 2016-02-25 15:44:10 -0700 | [diff] [blame] | 36 | PFN_vkGetInstanceProcAddr load_vk(); |
| 37 | bool can_present(VkPhysicalDevice phy, uint32_t queue_family) { return true; } |
| 38 | |
| 39 | VkSurfaceKHR create_surface(VkInstance instance); |
| 40 | |
| 41 | void on_app_cmd(int32_t cmd); |
| 42 | int32_t on_input_event(const AInputEvent *event); |
| 43 | |
| 44 | static inline void on_app_cmd(android_app *app, int32_t cmd); |
| 45 | static inline int32_t on_input_event(android_app *app, AInputEvent *event); |
| 46 | |
| 47 | android_app &app_; |
| 48 | |
| 49 | void *lib_handle_; |
| 50 | }; |
| 51 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 52 | void ShellAndroid::on_app_cmd(android_app *app, int32_t cmd) { |
Tony Barbour | 2f18b29 | 2016-02-25 15:44:10 -0700 | [diff] [blame] | 53 | auto android = reinterpret_cast<ShellAndroid *>(app->userData); |
| 54 | android->on_app_cmd(cmd); |
| 55 | } |
| 56 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 57 | int32_t ShellAndroid::on_input_event(android_app *app, AInputEvent *event) { |
Tony Barbour | 2f18b29 | 2016-02-25 15:44:10 -0700 | [diff] [blame] | 58 | auto android = reinterpret_cast<ShellAndroid *>(app->userData); |
| 59 | return android->on_input_event(event); |
| 60 | } |
| 61 | |
| 62 | #endif // SHELL_ANDROID_H |