os_android.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  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. Error OS_Android::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
  168. p_library_handle = dlopen(p_path.utf8().get_data(), RTLD_NOW);
  169. if (!p_library_handle) {
  170. ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + dlerror());
  171. ERR_FAIL_V(ERR_CANT_OPEN);
  172. }
  173. return OK;
  174. }
  175. void OS_Android::set_mouse_show(bool p_show) {
  176. //android has no mouse...
  177. }
  178. void OS_Android::set_mouse_grab(bool p_grab) {
  179. //it really has no mouse...!
  180. }
  181. bool OS_Android::is_mouse_grab_enabled() const {
  182. //*sigh* technology has evolved so much since i was a kid..
  183. return false;
  184. }
  185. Point2 OS_Android::get_mouse_position() const {
  186. return Point2();
  187. }
  188. int OS_Android::get_mouse_button_state() const {
  189. return 0;
  190. }
  191. void OS_Android::set_window_title(const String &p_title) {
  192. }
  193. void OS_Android::set_video_mode(const VideoMode &p_video_mode, int p_screen) {
  194. }
  195. OS::VideoMode OS_Android::get_video_mode(int p_screen) const {
  196. return default_videomode;
  197. }
  198. void OS_Android::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
  199. p_list->push_back(default_videomode);
  200. }
  201. void OS_Android::set_keep_screen_on(bool p_enabled) {
  202. OS::set_keep_screen_on(p_enabled);
  203. if (set_keep_screen_on_func) {
  204. set_keep_screen_on_func(p_enabled);
  205. }
  206. }
  207. Size2 OS_Android::get_window_size() const {
  208. return Vector2(default_videomode.width, default_videomode.height);
  209. }
  210. String OS_Android::get_name() {
  211. return "Android";
  212. }
  213. MainLoop *OS_Android::get_main_loop() const {
  214. return main_loop;
  215. }
  216. bool OS_Android::can_draw() const {
  217. return true; //always?
  218. }
  219. void OS_Android::set_cursor_shape(CursorShape p_shape) {
  220. //android really really really has no mouse.. how amazing..
  221. }
  222. void OS_Android::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
  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. void OS_Android::reload_gfx() {
  418. if (gfx_init_func)
  419. gfx_init_func(gfx_init_ud, use_gl2);
  420. //if (rasterizer)
  421. // rasterizer->reload_vram();
  422. }
  423. Error OS_Android::shell_open(String p_uri) {
  424. if (open_uri_func)
  425. return open_uri_func(p_uri) ? ERR_CANT_OPEN : OK;
  426. return ERR_UNAVAILABLE;
  427. }
  428. String OS_Android::get_resource_dir() const {
  429. return "/"; //android has its own filesystem for resources inside the APK
  430. }
  431. String OS_Android::get_locale() const {
  432. if (get_locale_func)
  433. return get_locale_func();
  434. return OS_Unix::get_locale();
  435. }
  436. void OS_Android::set_clipboard(const String &p_text) {
  437. if (set_clipboard_func) {
  438. set_clipboard_func(p_text);
  439. } else {
  440. OS_Unix::set_clipboard(p_text);
  441. }
  442. }
  443. String OS_Android::get_clipboard() const {
  444. if (get_clipboard_func) {
  445. return get_clipboard_func();
  446. }
  447. return OS_Unix::get_clipboard();
  448. }
  449. String OS_Android::get_model_name() const {
  450. if (get_model_func)
  451. return get_model_func();
  452. return OS_Unix::get_model_name();
  453. }
  454. int OS_Android::get_screen_dpi(int p_screen) const {
  455. if (get_screen_dpi_func) {
  456. return get_screen_dpi_func();
  457. }
  458. return 160;
  459. }
  460. void OS_Android::set_need_reload_hooks(bool p_needs_them) {
  461. use_reload_hooks = p_needs_them;
  462. }
  463. String OS_Android::get_user_data_dir() const {
  464. if (data_dir_cache != String())
  465. return data_dir_cache;
  466. if (get_user_data_dir_func) {
  467. String data_dir = get_user_data_dir_func();
  468. //store current dir
  469. char real_current_dir_name[2048];
  470. getcwd(real_current_dir_name, 2048);
  471. //go to data dir
  472. chdir(data_dir.utf8().get_data());
  473. //get actual data dir, so we resolve potential symlink (Android 6.0+ seems to use symlink)
  474. char data_current_dir_name[2048];
  475. getcwd(data_current_dir_name, 2048);
  476. //cache by parsing utf8
  477. data_dir_cache.parse_utf8(data_current_dir_name);
  478. //restore original dir so we don't mess things up
  479. chdir(real_current_dir_name);
  480. return data_dir_cache;
  481. }
  482. return ".";
  483. }
  484. void OS_Android::set_screen_orientation(ScreenOrientation p_orientation) {
  485. if (set_screen_orientation_func)
  486. set_screen_orientation_func(p_orientation);
  487. }
  488. String OS_Android::get_unique_id() const {
  489. if (get_unique_id_func)
  490. return get_unique_id_func();
  491. return OS::get_unique_id();
  492. }
  493. Error OS_Android::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
  494. // FIXME: Add support for volume, audio and subtitle tracks
  495. if (video_play_func)
  496. video_play_func(p_path);
  497. return OK;
  498. }
  499. bool OS_Android::native_video_is_playing() const {
  500. if (video_is_playing_func)
  501. return video_is_playing_func();
  502. return false;
  503. }
  504. void OS_Android::native_video_pause() {
  505. if (video_pause_func)
  506. video_pause_func();
  507. }
  508. String OS_Android::get_system_dir(SystemDir p_dir) const {
  509. if (get_system_dir_func)
  510. return get_system_dir_func(p_dir);
  511. return String(".");
  512. }
  513. void OS_Android::native_video_stop() {
  514. if (video_stop_func)
  515. video_stop_func();
  516. }
  517. void OS_Android::set_context_is_16_bits(bool p_is_16) {
  518. //use_16bits_fbo = p_is_16;
  519. //if (rasterizer)
  520. // rasterizer->set_force_16_bits_fbo(p_is_16);
  521. }
  522. void OS_Android::joy_connection_changed(int p_device, bool p_connected, String p_name) {
  523. return input->joy_connection_changed(p_device, p_connected, p_name, "");
  524. }
  525. bool OS_Android::is_joy_known(int p_device) {
  526. return input->is_joy_mapped(p_device);
  527. }
  528. String OS_Android::get_joy_guid(int p_device) const {
  529. return input->get_joy_guid_remapped(p_device);
  530. }
  531. bool OS_Android::_check_internal_feature_support(const String &p_feature) {
  532. if (p_feature == "mobile") {
  533. //TODO support etc2 only if GLES3 driver is selected
  534. return true;
  535. }
  536. #if defined(__aarch64__)
  537. if (p_feature == "arm64-v8a") {
  538. return true;
  539. }
  540. #elif defined(__ARM_ARCH_7A__)
  541. if (p_feature == "armeabi-v7a" || p_feature == "armeabi") {
  542. return true;
  543. }
  544. #elif defined(__arm__)
  545. if (p_feature == "armeabi") {
  546. return true;
  547. }
  548. #endif
  549. return false;
  550. }
  551. 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, bool p_use_apk_expansion) {
  552. use_apk_expansion = p_use_apk_expansion;
  553. default_videomode.width = 800;
  554. default_videomode.height = 600;
  555. default_videomode.fullscreen = true;
  556. default_videomode.resizable = false;
  557. gfx_init_func = p_gfx_init_func;
  558. gfx_init_ud = p_gfx_init_ud;
  559. main_loop = NULL;
  560. gl_extensions = NULL;
  561. //rasterizer = NULL;
  562. use_gl2 = false;
  563. open_uri_func = p_open_uri_func;
  564. get_user_data_dir_func = p_get_user_data_dir_func;
  565. get_locale_func = p_get_locale_func;
  566. get_model_func = p_get_model_func;
  567. get_screen_dpi_func = p_get_screen_dpi_func;
  568. get_unique_id_func = p_get_unique_id;
  569. get_system_dir_func = p_get_sdir_func;
  570. get_gl_version_code_func = p_get_gl_version_func;
  571. video_play_func = p_video_play_func;
  572. video_is_playing_func = p_video_is_playing_func;
  573. video_pause_func = p_video_pause_func;
  574. video_stop_func = p_video_stop_func;
  575. show_virtual_keyboard_func = p_show_vk;
  576. hide_virtual_keyboard_func = p_hide_vk;
  577. get_virtual_keyboard_height_func = p_vk_height_func;
  578. set_clipboard_func = p_set_clipboard_func;
  579. get_clipboard_func = p_get_clipboard_func;
  580. set_screen_orientation_func = p_screen_orient;
  581. set_keep_screen_on_func = p_set_keep_screen_on_func;
  582. alert_func = p_alert_func;
  583. use_reload_hooks = false;
  584. Vector<Logger *> loggers;
  585. loggers.push_back(memnew(AndroidLogger));
  586. _set_logger(memnew(CompositeLogger(loggers)));
  587. AudioDriverManager::add_driver(&audio_driver_android);
  588. }
  589. OS_Android::~OS_Android() {
  590. }