os_android.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  1. /*************************************************************************/
  2. /* os_android.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "os_android.h"
  31. #include "core/io/file_access_buffered_fa.h"
  32. #include "core/project_settings.h"
  33. #include "drivers/gles2/rasterizer_gles2.h"
  34. #include "drivers/gles3/rasterizer_gles3.h"
  35. #include "drivers/unix/dir_access_unix.h"
  36. #include "drivers/unix/file_access_unix.h"
  37. #include "file_access_android.h"
  38. #include "main/main.h"
  39. #include "servers/visual/visual_server_raster.h"
  40. #include "servers/visual/visual_server_wrap_mt.h"
  41. #include "dir_access_jandroid.h"
  42. #include "file_access_jandroid.h"
  43. #include <dlfcn.h>
  44. class AndroidLogger : public Logger {
  45. public:
  46. virtual void logv(const char *p_format, va_list p_list, bool p_err) {
  47. __android_log_vprint(p_err ? ANDROID_LOG_ERROR : ANDROID_LOG_INFO, "godot", p_format, p_list);
  48. }
  49. virtual ~AndroidLogger() {}
  50. };
  51. int OS_Android::get_video_driver_count() const {
  52. return 2;
  53. }
  54. const char *OS_Android::get_video_driver_name(int p_driver) const {
  55. switch (p_driver) {
  56. case VIDEO_DRIVER_GLES3:
  57. return "GLES3";
  58. case VIDEO_DRIVER_GLES2:
  59. return "GLES2";
  60. }
  61. ERR_EXPLAIN("Invalid video driver index " + itos(p_driver));
  62. ERR_FAIL_V(NULL);
  63. }
  64. int OS_Android::get_audio_driver_count() const {
  65. return 1;
  66. }
  67. const char *OS_Android::get_audio_driver_name(int p_driver) const {
  68. return "Android";
  69. }
  70. void OS_Android::initialize_core() {
  71. OS_Unix::initialize_core();
  72. if (use_apk_expansion)
  73. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_RESOURCES);
  74. else {
  75. #ifdef USE_JAVA_FILE_ACCESS
  76. FileAccess::make_default<FileAccessBufferedFA<FileAccessJAndroid> >(FileAccess::ACCESS_RESOURCES);
  77. #else
  78. //FileAccess::make_default<FileAccessBufferedFA<FileAccessAndroid> >(FileAccess::ACCESS_RESOURCES);
  79. FileAccess::make_default<FileAccessAndroid>(FileAccess::ACCESS_RESOURCES);
  80. #endif
  81. }
  82. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
  83. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_FILESYSTEM);
  84. //FileAccessBufferedFA<FileAccessUnix>::make_default();
  85. if (use_apk_expansion)
  86. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_RESOURCES);
  87. else
  88. DirAccess::make_default<DirAccessJAndroid>(DirAccess::ACCESS_RESOURCES);
  89. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_USERDATA);
  90. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_FILESYSTEM);
  91. }
  92. void OS_Android::set_opengl_extensions(const char *p_gl_extensions) {
  93. ERR_FAIL_COND(!p_gl_extensions);
  94. gl_extensions = p_gl_extensions;
  95. }
  96. int OS_Android::get_current_video_driver() const {
  97. return video_driver_index;
  98. }
  99. Error OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
  100. bool use_gl3 = get_gl_version_code_func() >= 0x00030000;
  101. use_gl3 = use_gl3 && (GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES3");
  102. bool gl_initialization_error = false;
  103. while (true) {
  104. if (use_gl3) {
  105. if (RasterizerGLES3::is_viable() == OK) {
  106. if (gfx_init_func)
  107. gfx_init_func(gfx_init_ud, false);
  108. RasterizerGLES3::register_config();
  109. RasterizerGLES3::make_current();
  110. break;
  111. } else {
  112. if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) {
  113. p_video_driver = VIDEO_DRIVER_GLES2;
  114. use_gl3 = false;
  115. continue;
  116. } else {
  117. gl_initialization_error = true;
  118. break;
  119. }
  120. }
  121. } else {
  122. if (RasterizerGLES2::is_viable() == OK) {
  123. if (gfx_init_func)
  124. gfx_init_func(gfx_init_ud, true);
  125. RasterizerGLES2::register_config();
  126. RasterizerGLES2::make_current();
  127. break;
  128. } else {
  129. gl_initialization_error = true;
  130. break;
  131. }
  132. }
  133. }
  134. if (gl_initialization_error) {
  135. OS::get_singleton()->alert("Your device does not support any of the supported OpenGL versions.\n"
  136. "Please try updating your Android version.",
  137. "Unable to initialize Video driver");
  138. return ERR_UNAVAILABLE;
  139. }
  140. video_driver_index = p_video_driver;
  141. visual_server = memnew(VisualServerRaster);
  142. if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
  143. visual_server = memnew(VisualServerWrapMT(visual_server, false));
  144. }
  145. visual_server->init();
  146. AudioDriverManager::initialize(p_audio_driver);
  147. input = memnew(InputDefault);
  148. input->set_fallback_mapping("Default Android Gamepad");
  149. //power_manager = memnew(PowerAndroid);
  150. return OK;
  151. }
  152. void OS_Android::set_main_loop(MainLoop *p_main_loop) {
  153. main_loop = p_main_loop;
  154. input->set_main_loop(p_main_loop);
  155. }
  156. void OS_Android::delete_main_loop() {
  157. memdelete(main_loop);
  158. }
  159. void OS_Android::finalize() {
  160. memdelete(input);
  161. }
  162. void OS_Android::alert(const String &p_alert, const String &p_title) {
  163. //print("ALERT: %s\n", p_alert.utf8().get_data());
  164. if (alert_func)
  165. alert_func(p_alert, p_title);
  166. }
  167. bool OS_Android::request_permission(const String &p_name) {
  168. if (request_permission_func)
  169. return request_permission_func(p_name);
  170. return false;
  171. }
  172. Error OS_Android::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
  173. p_library_handle = dlopen(p_path.utf8().get_data(), RTLD_NOW);
  174. if (!p_library_handle) {
  175. ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + dlerror());
  176. ERR_FAIL_V(ERR_CANT_OPEN);
  177. }
  178. return OK;
  179. }
  180. void OS_Android::set_mouse_show(bool p_show) {
  181. //android has no mouse...
  182. }
  183. void OS_Android::set_mouse_grab(bool p_grab) {
  184. //it really has no mouse...!
  185. }
  186. bool OS_Android::is_mouse_grab_enabled() const {
  187. //*sigh* technology has evolved so much since i was a kid..
  188. return false;
  189. }
  190. Point2 OS_Android::get_mouse_position() const {
  191. return Point2();
  192. }
  193. int OS_Android::get_mouse_button_state() const {
  194. return 0;
  195. }
  196. void OS_Android::set_window_title(const String &p_title) {
  197. }
  198. void OS_Android::set_video_mode(const VideoMode &p_video_mode, int p_screen) {
  199. }
  200. OS::VideoMode OS_Android::get_video_mode(int p_screen) const {
  201. return default_videomode;
  202. }
  203. void OS_Android::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
  204. p_list->push_back(default_videomode);
  205. }
  206. void OS_Android::set_keep_screen_on(bool p_enabled) {
  207. OS::set_keep_screen_on(p_enabled);
  208. if (set_keep_screen_on_func) {
  209. set_keep_screen_on_func(p_enabled);
  210. }
  211. }
  212. Size2 OS_Android::get_window_size() const {
  213. return Vector2(default_videomode.width, default_videomode.height);
  214. }
  215. String OS_Android::get_name() {
  216. return "Android";
  217. }
  218. MainLoop *OS_Android::get_main_loop() const {
  219. return main_loop;
  220. }
  221. bool OS_Android::can_draw() const {
  222. return true; //always?
  223. }
  224. void OS_Android::main_loop_begin() {
  225. if (main_loop)
  226. main_loop->init();
  227. }
  228. bool OS_Android::main_loop_iterate() {
  229. if (!main_loop)
  230. return false;
  231. return Main::iteration();
  232. }
  233. void OS_Android::main_loop_end() {
  234. if (main_loop)
  235. main_loop->finish();
  236. }
  237. void OS_Android::main_loop_focusout() {
  238. if (main_loop)
  239. main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
  240. audio_driver_android.set_pause(true);
  241. }
  242. void OS_Android::main_loop_focusin() {
  243. if (main_loop)
  244. main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
  245. audio_driver_android.set_pause(false);
  246. }
  247. void OS_Android::process_joy_event(OS_Android::JoypadEvent p_event) {
  248. switch (p_event.type) {
  249. case JOY_EVENT_BUTTON:
  250. input->joy_button(p_event.device, p_event.index, p_event.pressed);
  251. break;
  252. case JOY_EVENT_AXIS:
  253. InputDefault::JoyAxis value;
  254. value.min = -1;
  255. value.value = p_event.value;
  256. input->joy_axis(p_event.device, p_event.index, value);
  257. break;
  258. case JOY_EVENT_HAT:
  259. input->joy_hat(p_event.device, p_event.hat);
  260. break;
  261. default:
  262. return;
  263. }
  264. }
  265. void OS_Android::process_event(Ref<InputEvent> p_event) {
  266. input->parse_input_event(p_event);
  267. }
  268. void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos> &p_points) {
  269. switch (p_what) {
  270. case 0: { //gesture begin
  271. if (touch.size()) {
  272. //end all if exist
  273. for (int i = 0; i < touch.size(); i++) {
  274. Ref<InputEventScreenTouch> ev;
  275. ev.instance();
  276. ev->set_index(touch[i].id);
  277. ev->set_pressed(false);
  278. ev->set_position(touch[i].pos);
  279. input->parse_input_event(ev);
  280. }
  281. }
  282. touch.resize(p_points.size());
  283. for (int i = 0; i < p_points.size(); i++) {
  284. touch.write[i].id = p_points[i].id;
  285. touch.write[i].pos = p_points[i].pos;
  286. }
  287. //send touch
  288. for (int i = 0; i < touch.size(); i++) {
  289. Ref<InputEventScreenTouch> ev;
  290. ev.instance();
  291. ev->set_index(touch[i].id);
  292. ev->set_pressed(true);
  293. ev->set_position(touch[i].pos);
  294. input->parse_input_event(ev);
  295. }
  296. } break;
  297. case 1: { //motion
  298. ERR_FAIL_COND(touch.size() != p_points.size());
  299. for (int i = 0; i < touch.size(); i++) {
  300. int idx = -1;
  301. for (int j = 0; j < p_points.size(); j++) {
  302. if (touch[i].id == p_points[j].id) {
  303. idx = j;
  304. break;
  305. }
  306. }
  307. ERR_CONTINUE(idx == -1);
  308. if (touch[i].pos == p_points[idx].pos)
  309. continue; //no move unncesearily
  310. Ref<InputEventScreenDrag> ev;
  311. ev.instance();
  312. ev->set_index(touch[i].id);
  313. ev->set_position(p_points[idx].pos);
  314. ev->set_relative(p_points[idx].pos - touch[i].pos);
  315. input->parse_input_event(ev);
  316. touch.write[i].pos = p_points[idx].pos;
  317. }
  318. } break;
  319. case 2: { //release
  320. if (touch.size()) {
  321. //end all if exist
  322. for (int i = 0; i < touch.size(); i++) {
  323. Ref<InputEventScreenTouch> ev;
  324. ev.instance();
  325. ev->set_index(touch[i].id);
  326. ev->set_pressed(false);
  327. ev->set_position(touch[i].pos);
  328. input->parse_input_event(ev);
  329. }
  330. touch.clear();
  331. }
  332. } break;
  333. case 3: { // add touch
  334. for (int i = 0; i < p_points.size(); i++) {
  335. if (p_points[i].id == p_pointer) {
  336. TouchPos tp = p_points[i];
  337. touch.push_back(tp);
  338. Ref<InputEventScreenTouch> ev;
  339. ev.instance();
  340. ev->set_index(tp.id);
  341. ev->set_pressed(true);
  342. ev->set_position(tp.pos);
  343. input->parse_input_event(ev);
  344. break;
  345. }
  346. }
  347. } break;
  348. case 4: { // remove touch
  349. for (int i = 0; i < touch.size(); i++) {
  350. if (touch[i].id == p_pointer) {
  351. Ref<InputEventScreenTouch> ev;
  352. ev.instance();
  353. ev->set_index(touch[i].id);
  354. ev->set_pressed(false);
  355. ev->set_position(touch[i].pos);
  356. input->parse_input_event(ev);
  357. touch.remove(i);
  358. break;
  359. }
  360. }
  361. } break;
  362. }
  363. }
  364. void OS_Android::process_accelerometer(const Vector3 &p_accelerometer) {
  365. input->set_accelerometer(p_accelerometer);
  366. }
  367. void OS_Android::process_gravity(const Vector3 &p_gravity) {
  368. input->set_gravity(p_gravity);
  369. }
  370. void OS_Android::process_magnetometer(const Vector3 &p_magnetometer) {
  371. input->set_magnetometer(p_magnetometer);
  372. }
  373. void OS_Android::process_gyroscope(const Vector3 &p_gyroscope) {
  374. input->set_gyroscope(p_gyroscope);
  375. }
  376. bool OS_Android::has_touchscreen_ui_hint() const {
  377. return true;
  378. }
  379. bool OS_Android::has_virtual_keyboard() const {
  380. return true;
  381. }
  382. int OS_Android::get_virtual_keyboard_height() const {
  383. if (get_virtual_keyboard_height_func) {
  384. return get_virtual_keyboard_height_func();
  385. }
  386. ERR_PRINT("Cannot obtain virtual keyboard height.");
  387. return 0;
  388. }
  389. void OS_Android::show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect) {
  390. if (show_virtual_keyboard_func) {
  391. show_virtual_keyboard_func(p_existing_text);
  392. } else {
  393. ERR_PRINT("Virtual keyboard not available");
  394. };
  395. }
  396. void OS_Android::hide_virtual_keyboard() {
  397. if (hide_virtual_keyboard_func) {
  398. hide_virtual_keyboard_func();
  399. } else {
  400. ERR_PRINT("Virtual keyboard not available");
  401. };
  402. }
  403. void OS_Android::init_video_mode(int p_video_width, int p_video_height) {
  404. default_videomode.width = p_video_width;
  405. default_videomode.height = p_video_height;
  406. default_videomode.fullscreen = true;
  407. default_videomode.resizable = false;
  408. }
  409. void OS_Android::main_loop_request_go_back() {
  410. if (main_loop)
  411. main_loop->notification(MainLoop::NOTIFICATION_WM_GO_BACK_REQUEST);
  412. }
  413. void OS_Android::set_display_size(Size2 p_size) {
  414. default_videomode.width = p_size.x;
  415. default_videomode.height = p_size.y;
  416. }
  417. Error OS_Android::shell_open(String p_uri) {
  418. if (open_uri_func)
  419. return open_uri_func(p_uri) ? ERR_CANT_OPEN : OK;
  420. return ERR_UNAVAILABLE;
  421. }
  422. String OS_Android::get_resource_dir() const {
  423. return "/"; //android has its own filesystem for resources inside the APK
  424. }
  425. String OS_Android::get_locale() const {
  426. if (get_locale_func)
  427. return get_locale_func();
  428. return OS_Unix::get_locale();
  429. }
  430. void OS_Android::set_clipboard(const String &p_text) {
  431. if (set_clipboard_func) {
  432. set_clipboard_func(p_text);
  433. } else {
  434. OS_Unix::set_clipboard(p_text);
  435. }
  436. }
  437. String OS_Android::get_clipboard() const {
  438. if (get_clipboard_func) {
  439. return get_clipboard_func();
  440. }
  441. return OS_Unix::get_clipboard();
  442. }
  443. String OS_Android::get_model_name() const {
  444. if (get_model_func)
  445. return get_model_func();
  446. return OS_Unix::get_model_name();
  447. }
  448. int OS_Android::get_screen_dpi(int p_screen) const {
  449. if (get_screen_dpi_func) {
  450. return get_screen_dpi_func();
  451. }
  452. return 160;
  453. }
  454. String OS_Android::get_user_data_dir() const {
  455. if (data_dir_cache != String())
  456. return data_dir_cache;
  457. if (get_user_data_dir_func) {
  458. String data_dir = get_user_data_dir_func();
  459. //store current dir
  460. char real_current_dir_name[2048];
  461. getcwd(real_current_dir_name, 2048);
  462. //go to data dir
  463. chdir(data_dir.utf8().get_data());
  464. //get actual data dir, so we resolve potential symlink (Android 6.0+ seems to use symlink)
  465. char data_current_dir_name[2048];
  466. getcwd(data_current_dir_name, 2048);
  467. //cache by parsing utf8
  468. data_dir_cache.parse_utf8(data_current_dir_name);
  469. //restore original dir so we don't mess things up
  470. chdir(real_current_dir_name);
  471. return data_dir_cache;
  472. }
  473. return ".";
  474. }
  475. void OS_Android::set_screen_orientation(ScreenOrientation p_orientation) {
  476. if (set_screen_orientation_func)
  477. set_screen_orientation_func(p_orientation);
  478. }
  479. String OS_Android::get_unique_id() const {
  480. if (get_unique_id_func)
  481. return get_unique_id_func();
  482. return OS::get_unique_id();
  483. }
  484. Error OS_Android::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
  485. // FIXME: Add support for volume, audio and subtitle tracks
  486. if (video_play_func)
  487. video_play_func(p_path);
  488. return OK;
  489. }
  490. bool OS_Android::native_video_is_playing() const {
  491. if (video_is_playing_func)
  492. return video_is_playing_func();
  493. return false;
  494. }
  495. void OS_Android::native_video_pause() {
  496. if (video_pause_func)
  497. video_pause_func();
  498. }
  499. String OS_Android::get_system_dir(SystemDir p_dir) const {
  500. if (get_system_dir_func)
  501. return get_system_dir_func(p_dir);
  502. return String(".");
  503. }
  504. void OS_Android::native_video_stop() {
  505. if (video_stop_func)
  506. video_stop_func();
  507. }
  508. void OS_Android::set_context_is_16_bits(bool p_is_16) {
  509. //use_16bits_fbo = p_is_16;
  510. //if (rasterizer)
  511. // rasterizer->set_force_16_bits_fbo(p_is_16);
  512. }
  513. void OS_Android::joy_connection_changed(int p_device, bool p_connected, String p_name) {
  514. return input->joy_connection_changed(p_device, p_connected, p_name, "");
  515. }
  516. bool OS_Android::is_joy_known(int p_device) {
  517. return input->is_joy_mapped(p_device);
  518. }
  519. String OS_Android::get_joy_guid(int p_device) const {
  520. return input->get_joy_guid_remapped(p_device);
  521. }
  522. void OS_Android::vibrate_handheld(int p_duration_ms) {
  523. if (vibrate_func)
  524. vibrate_func(p_duration_ms);
  525. }
  526. bool OS_Android::_check_internal_feature_support(const String &p_feature) {
  527. if (p_feature == "mobile") {
  528. //TODO support etc2 only if GLES3 driver is selected
  529. return true;
  530. }
  531. #if defined(__aarch64__)
  532. if (p_feature == "arm64-v8a") {
  533. return true;
  534. }
  535. #elif defined(__ARM_ARCH_7A__)
  536. if (p_feature == "armeabi-v7a" || p_feature == "armeabi") {
  537. return true;
  538. }
  539. #elif defined(__arm__)
  540. if (p_feature == "armeabi") {
  541. return true;
  542. }
  543. #endif
  544. return false;
  545. }
  546. OS_Android::OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetUserDataDirFunc p_get_user_data_dir_func, GetLocaleFunc p_get_locale_func, GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, VirtualKeyboardHeightFunc p_vk_height_func, SetScreenOrientationFunc p_screen_orient, GetUniqueIDFunc p_get_unique_id, GetSystemDirFunc p_get_sdir_func, GetGLVersionCodeFunc p_get_gl_version_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, AlertFunc p_alert_func, SetClipboardFunc p_set_clipboard_func, GetClipboardFunc p_get_clipboard_func, RequestPermissionFunc p_request_permission, VibrateFunc p_vibrate_func, bool p_use_apk_expansion) {
  547. use_apk_expansion = p_use_apk_expansion;
  548. default_videomode.width = 800;
  549. default_videomode.height = 600;
  550. default_videomode.fullscreen = true;
  551. default_videomode.resizable = false;
  552. gfx_init_func = p_gfx_init_func;
  553. gfx_init_ud = p_gfx_init_ud;
  554. main_loop = NULL;
  555. gl_extensions = NULL;
  556. //rasterizer = NULL;
  557. use_gl2 = false;
  558. open_uri_func = p_open_uri_func;
  559. get_user_data_dir_func = p_get_user_data_dir_func;
  560. get_locale_func = p_get_locale_func;
  561. get_model_func = p_get_model_func;
  562. get_screen_dpi_func = p_get_screen_dpi_func;
  563. get_unique_id_func = p_get_unique_id;
  564. get_system_dir_func = p_get_sdir_func;
  565. get_gl_version_code_func = p_get_gl_version_func;
  566. video_play_func = p_video_play_func;
  567. video_is_playing_func = p_video_is_playing_func;
  568. video_pause_func = p_video_pause_func;
  569. video_stop_func = p_video_stop_func;
  570. show_virtual_keyboard_func = p_show_vk;
  571. hide_virtual_keyboard_func = p_hide_vk;
  572. get_virtual_keyboard_height_func = p_vk_height_func;
  573. set_clipboard_func = p_set_clipboard_func;
  574. get_clipboard_func = p_get_clipboard_func;
  575. set_screen_orientation_func = p_screen_orient;
  576. set_keep_screen_on_func = p_set_keep_screen_on_func;
  577. alert_func = p_alert_func;
  578. request_permission_func = p_request_permission;
  579. vibrate_func = p_vibrate_func;
  580. Vector<Logger *> loggers;
  581. loggers.push_back(memnew(AndroidLogger));
  582. _set_logger(memnew(CompositeLogger(loggers)));
  583. AudioDriverManager::add_driver(&audio_driver_android);
  584. }
  585. OS_Android::~OS_Android() {
  586. }