os_android.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. /*************************************************************************/
  2. /* os_android.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2018 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/gles3/rasterizer_gles3.h"
  34. #include "drivers/unix/dir_access_unix.h"
  35. #include "drivers/unix/file_access_unix.h"
  36. #include "file_access_android.h"
  37. #include "main/main.h"
  38. #include "servers/visual/visual_server_raster.h"
  39. //#include "servers/visual/visual_server_wrap_mt.h"
  40. #ifdef ANDROID_NATIVE_ACTIVITY
  41. #include "dir_access_android.h"
  42. #include "file_access_android.h"
  43. #else
  44. #include "dir_access_jandroid.h"
  45. #include "file_access_jandroid.h"
  46. #endif
  47. #include <dlfcn.h>
  48. class AndroidLogger : public Logger {
  49. public:
  50. virtual void logv(const char *p_format, va_list p_list, bool p_err) {
  51. __android_log_vprint(p_err ? ANDROID_LOG_ERROR : ANDROID_LOG_INFO, "godot", p_format, p_list);
  52. }
  53. virtual ~AndroidLogger() {}
  54. };
  55. int OS_Android::get_video_driver_count() const {
  56. return 1;
  57. }
  58. const char *OS_Android::get_video_driver_name(int p_driver) const {
  59. return "GLES2";
  60. }
  61. int OS_Android::get_audio_driver_count() const {
  62. return 1;
  63. }
  64. const char *OS_Android::get_audio_driver_name(int p_driver) const {
  65. return "Android";
  66. }
  67. void OS_Android::initialize_core() {
  68. OS_Unix::initialize_core();
  69. #ifdef ANDROID_NATIVE_ACTIVITY
  70. FileAccess::make_default<FileAccessAndroid>(FileAccess::ACCESS_RESOURCES);
  71. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
  72. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_FILESYSTEM);
  73. //FileAccessBufferedFA<FileAccessUnix>::make_default();
  74. DirAccess::make_default<DirAccessAndroid>(DirAccess::ACCESS_RESOURCES);
  75. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_USERDATA);
  76. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_FILESYSTEM);
  77. #else
  78. if (use_apk_expansion)
  79. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_RESOURCES);
  80. else {
  81. #ifdef USE_JAVA_FILE_ACCESS
  82. FileAccess::make_default<FileAccessBufferedFA<FileAccessJAndroid> >(FileAccess::ACCESS_RESOURCES);
  83. #else
  84. //FileAccess::make_default<FileAccessBufferedFA<FileAccessAndroid> >(FileAccess::ACCESS_RESOURCES);
  85. FileAccess::make_default<FileAccessAndroid>(FileAccess::ACCESS_RESOURCES);
  86. #endif
  87. }
  88. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
  89. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_FILESYSTEM);
  90. //FileAccessBufferedFA<FileAccessUnix>::make_default();
  91. if (use_apk_expansion)
  92. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_RESOURCES);
  93. else
  94. DirAccess::make_default<DirAccessJAndroid>(DirAccess::ACCESS_RESOURCES);
  95. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_USERDATA);
  96. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_FILESYSTEM);
  97. #endif
  98. }
  99. void OS_Android::set_opengl_extensions(const char *p_gl_extensions) {
  100. ERR_FAIL_COND(!p_gl_extensions);
  101. gl_extensions = p_gl_extensions;
  102. }
  103. Error OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
  104. use_gl2 = p_video_driver != 1;
  105. if (gfx_init_func)
  106. gfx_init_func(gfx_init_ud, use_gl2);
  107. AudioDriverManager::add_driver(&audio_driver_android);
  108. RasterizerGLES3::register_config();
  109. RasterizerGLES3::make_current();
  110. visual_server = memnew(VisualServerRaster);
  111. /* if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
  112. visual_server = memnew(VisualServerWrapMT(visual_server, false));
  113. };*/
  114. visual_server->init();
  115. // visual_server->cursor_set_visible(false, 0);
  116. AudioDriverManager::initialize(p_audio_driver);
  117. input = memnew(InputDefault);
  118. input->set_fallback_mapping("Default Android Gamepad");
  119. //power_manager = memnew(power_android);
  120. return OK;
  121. }
  122. void OS_Android::set_main_loop(MainLoop *p_main_loop) {
  123. main_loop = p_main_loop;
  124. input->set_main_loop(p_main_loop);
  125. }
  126. void OS_Android::delete_main_loop() {
  127. memdelete(main_loop);
  128. }
  129. void OS_Android::finalize() {
  130. memdelete(input);
  131. }
  132. void OS_Android::alert(const String &p_alert, const String &p_title) {
  133. //print("ALERT: %s\n", p_alert.utf8().get_data());
  134. if (alert_func)
  135. alert_func(p_alert, p_title);
  136. }
  137. Error OS_Android::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
  138. p_library_handle = dlopen(p_path.utf8().get_data(), RTLD_NOW);
  139. if (!p_library_handle) {
  140. ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + dlerror());
  141. ERR_FAIL_V(ERR_CANT_OPEN);
  142. }
  143. return OK;
  144. }
  145. void OS_Android::set_mouse_show(bool p_show) {
  146. //android has no mouse...
  147. }
  148. void OS_Android::set_mouse_grab(bool p_grab) {
  149. //it really has no mouse...!
  150. }
  151. bool OS_Android::is_mouse_grab_enabled() const {
  152. //*sigh* technology has evolved so much since i was a kid..
  153. return false;
  154. }
  155. Point2 OS_Android::get_mouse_position() const {
  156. return Point2();
  157. }
  158. int OS_Android::get_mouse_button_state() const {
  159. return 0;
  160. }
  161. void OS_Android::set_window_title(const String &p_title) {
  162. }
  163. //interesting byt not yet
  164. //void set_clipboard(const String& p_text);
  165. //String get_clipboard() const;
  166. void OS_Android::set_video_mode(const VideoMode &p_video_mode, int p_screen) {
  167. }
  168. OS::VideoMode OS_Android::get_video_mode(int p_screen) const {
  169. return default_videomode;
  170. }
  171. void OS_Android::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
  172. p_list->push_back(default_videomode);
  173. }
  174. void OS_Android::set_keep_screen_on(bool p_enabled) {
  175. OS::set_keep_screen_on(p_enabled);
  176. if (set_keep_screen_on_func) {
  177. set_keep_screen_on_func(p_enabled);
  178. }
  179. }
  180. Size2 OS_Android::get_window_size() const {
  181. return Vector2(default_videomode.width, default_videomode.height);
  182. }
  183. String OS_Android::get_name() {
  184. return "Android";
  185. }
  186. MainLoop *OS_Android::get_main_loop() const {
  187. return main_loop;
  188. }
  189. bool OS_Android::can_draw() const {
  190. return true; //always?
  191. }
  192. void OS_Android::set_cursor_shape(CursorShape p_shape) {
  193. //android really really really has no mouse.. how amazing..
  194. }
  195. void OS_Android::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
  196. }
  197. void OS_Android::main_loop_begin() {
  198. if (main_loop)
  199. main_loop->init();
  200. }
  201. bool OS_Android::main_loop_iterate() {
  202. if (!main_loop)
  203. return false;
  204. return Main::iteration();
  205. }
  206. void OS_Android::main_loop_end() {
  207. if (main_loop)
  208. main_loop->finish();
  209. }
  210. void OS_Android::main_loop_focusout() {
  211. if (main_loop)
  212. main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
  213. audio_driver_android.set_pause(true);
  214. }
  215. void OS_Android::main_loop_focusin() {
  216. if (main_loop)
  217. main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
  218. audio_driver_android.set_pause(false);
  219. }
  220. void OS_Android::process_joy_event(OS_Android::JoypadEvent p_event) {
  221. switch (p_event.type) {
  222. case JOY_EVENT_BUTTON:
  223. input->joy_button(p_event.device, p_event.index, p_event.pressed);
  224. break;
  225. case JOY_EVENT_AXIS:
  226. InputDefault::JoyAxis value;
  227. value.min = -1;
  228. value.value = p_event.value;
  229. input->joy_axis(p_event.device, p_event.index, value);
  230. break;
  231. case JOY_EVENT_HAT:
  232. input->joy_hat(p_event.device, p_event.hat);
  233. break;
  234. default:
  235. return;
  236. }
  237. }
  238. void OS_Android::process_event(Ref<InputEvent> p_event) {
  239. input->parse_input_event(p_event);
  240. }
  241. void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos> &p_points) {
  242. //print_line("ev: "+itos(p_what)+" pnt: "+itos(p_pointer)+" pointc: "+itos(p_points.size()));
  243. switch (p_what) {
  244. case 0: { //gesture begin
  245. if (touch.size()) {
  246. //end all if exist
  247. for (int i = 0; i < touch.size(); i++) {
  248. Ref<InputEventScreenTouch> ev;
  249. ev.instance();
  250. ev->set_index(touch[i].id);
  251. ev->set_pressed(false);
  252. ev->set_position(touch[i].pos);
  253. input->parse_input_event(ev);
  254. }
  255. }
  256. touch.resize(p_points.size());
  257. for (int i = 0; i < p_points.size(); i++) {
  258. touch[i].id = p_points[i].id;
  259. touch[i].pos = p_points[i].pos;
  260. }
  261. //send touch
  262. for (int i = 0; i < touch.size(); i++) {
  263. Ref<InputEventScreenTouch> ev;
  264. ev.instance();
  265. ev->set_index(touch[i].id);
  266. ev->set_pressed(true);
  267. ev->set_position(touch[i].pos);
  268. input->parse_input_event(ev);
  269. }
  270. } break;
  271. case 1: { //motion
  272. ERR_FAIL_COND(touch.size() != p_points.size());
  273. for (int i = 0; i < touch.size(); i++) {
  274. int idx = -1;
  275. for (int j = 0; j < p_points.size(); j++) {
  276. if (touch[i].id == p_points[j].id) {
  277. idx = j;
  278. break;
  279. }
  280. }
  281. ERR_CONTINUE(idx == -1);
  282. if (touch[i].pos == p_points[idx].pos)
  283. continue; //no move unncesearily
  284. Ref<InputEventScreenDrag> ev;
  285. ev.instance();
  286. ev->set_index(touch[i].id);
  287. ev->set_position(p_points[idx].pos);
  288. ev->set_relative(p_points[idx].pos - touch[i].pos);
  289. input->parse_input_event(ev);
  290. touch[i].pos = p_points[idx].pos;
  291. }
  292. } break;
  293. case 2: { //release
  294. if (touch.size()) {
  295. //end all if exist
  296. for (int i = 0; i < touch.size(); i++) {
  297. Ref<InputEventScreenTouch> ev;
  298. ev.instance();
  299. ev->set_index(touch[i].id);
  300. ev->set_pressed(false);
  301. ev->set_position(touch[i].pos);
  302. input->parse_input_event(ev);
  303. }
  304. touch.clear();
  305. }
  306. } break;
  307. case 3: { // add touch
  308. for (int i = 0; i < p_points.size(); i++) {
  309. if (p_points[i].id == p_pointer) {
  310. TouchPos tp = p_points[i];
  311. touch.push_back(tp);
  312. Ref<InputEventScreenTouch> ev;
  313. ev.instance();
  314. ev->set_index(tp.id);
  315. ev->set_pressed(true);
  316. ev->set_position(tp.pos);
  317. input->parse_input_event(ev);
  318. break;
  319. }
  320. }
  321. } break;
  322. case 4: { // remove touch
  323. for (int i = 0; i < touch.size(); i++) {
  324. if (touch[i].id == p_pointer) {
  325. Ref<InputEventScreenTouch> ev;
  326. ev.instance();
  327. ev->set_index(touch[i].id);
  328. ev->set_pressed(false);
  329. ev->set_position(touch[i].pos);
  330. input->parse_input_event(ev);
  331. touch.remove(i);
  332. break;
  333. }
  334. }
  335. } break;
  336. }
  337. }
  338. void OS_Android::process_accelerometer(const Vector3 &p_accelerometer) {
  339. input->set_accelerometer(p_accelerometer);
  340. }
  341. void OS_Android::process_gravity(const Vector3 &p_gravity) {
  342. input->set_gravity(p_gravity);
  343. }
  344. void OS_Android::process_magnetometer(const Vector3 &p_magnetometer) {
  345. input->set_magnetometer(p_magnetometer);
  346. }
  347. void OS_Android::process_gyroscope(const Vector3 &p_gyroscope) {
  348. input->set_gyroscope(p_gyroscope);
  349. }
  350. bool OS_Android::has_touchscreen_ui_hint() const {
  351. return true;
  352. }
  353. bool OS_Android::has_virtual_keyboard() const {
  354. return true;
  355. }
  356. int OS_Android::get_virtual_keyboard_height() const {
  357. if (get_virtual_keyboard_height_func) {
  358. return get_virtual_keyboard_height_func();
  359. }
  360. ERR_PRINT("Cannot obtain virtual keyboard height.");
  361. return 0;
  362. }
  363. void OS_Android::show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect) {
  364. if (show_virtual_keyboard_func) {
  365. show_virtual_keyboard_func(p_existing_text);
  366. } else {
  367. ERR_PRINT("Virtual keyboard not available");
  368. };
  369. }
  370. void OS_Android::hide_virtual_keyboard() {
  371. if (hide_virtual_keyboard_func) {
  372. hide_virtual_keyboard_func();
  373. } else {
  374. ERR_PRINT("Virtual keyboard not available");
  375. };
  376. }
  377. void OS_Android::init_video_mode(int p_video_width, int p_video_height) {
  378. default_videomode.width = p_video_width;
  379. default_videomode.height = p_video_height;
  380. default_videomode.fullscreen = true;
  381. default_videomode.resizable = false;
  382. }
  383. void OS_Android::main_loop_request_go_back() {
  384. if (main_loop)
  385. main_loop->notification(MainLoop::NOTIFICATION_WM_GO_BACK_REQUEST);
  386. }
  387. void OS_Android::set_display_size(Size2 p_size) {
  388. default_videomode.width = p_size.x;
  389. default_videomode.height = p_size.y;
  390. }
  391. void OS_Android::reload_gfx() {
  392. if (gfx_init_func)
  393. gfx_init_func(gfx_init_ud, use_gl2);
  394. //if (rasterizer)
  395. // rasterizer->reload_vram();
  396. }
  397. Error OS_Android::shell_open(String p_uri) {
  398. if (open_uri_func)
  399. return open_uri_func(p_uri) ? ERR_CANT_OPEN : OK;
  400. return ERR_UNAVAILABLE;
  401. }
  402. String OS_Android::get_resource_dir() const {
  403. return "/"; //android has it's own filesystem for resources inside the APK
  404. }
  405. String OS_Android::get_locale() const {
  406. if (get_locale_func)
  407. return get_locale_func();
  408. return OS_Unix::get_locale();
  409. }
  410. String OS_Android::get_model_name() const {
  411. if (get_model_func)
  412. return get_model_func();
  413. return OS_Unix::get_model_name();
  414. }
  415. int OS_Android::get_screen_dpi(int p_screen) const {
  416. if (get_screen_dpi_func) {
  417. return get_screen_dpi_func();
  418. }
  419. return 160;
  420. }
  421. void OS_Android::set_need_reload_hooks(bool p_needs_them) {
  422. use_reload_hooks = p_needs_them;
  423. }
  424. String OS_Android::get_user_data_dir() const {
  425. if (data_dir_cache != String())
  426. return data_dir_cache;
  427. if (get_user_data_dir_func) {
  428. String data_dir = get_user_data_dir_func();
  429. //store current dir
  430. char real_current_dir_name[2048];
  431. getcwd(real_current_dir_name, 2048);
  432. //go to data dir
  433. chdir(data_dir.utf8().get_data());
  434. //get actual data dir, so we resolve potential symlink (Android 6.0+ seems to use symlink)
  435. char data_current_dir_name[2048];
  436. getcwd(data_current_dir_name, 2048);
  437. //cache by parsing utf8
  438. data_dir_cache.parse_utf8(data_current_dir_name);
  439. //restore original dir so we don't mess things up
  440. chdir(real_current_dir_name);
  441. return data_dir_cache;
  442. }
  443. return ".";
  444. }
  445. void OS_Android::set_screen_orientation(ScreenOrientation p_orientation) {
  446. if (set_screen_orientation_func)
  447. set_screen_orientation_func(p_orientation);
  448. }
  449. String OS_Android::get_unique_id() const {
  450. if (get_unique_id_func)
  451. return get_unique_id_func();
  452. return OS::get_unique_id();
  453. }
  454. Error OS_Android::native_video_play(String p_path, float p_volume) {
  455. if (video_play_func)
  456. video_play_func(p_path);
  457. return OK;
  458. }
  459. bool OS_Android::native_video_is_playing() {
  460. if (video_is_playing_func)
  461. return video_is_playing_func();
  462. return false;
  463. }
  464. void OS_Android::native_video_pause() {
  465. if (video_pause_func)
  466. video_pause_func();
  467. }
  468. String OS_Android::get_system_dir(SystemDir p_dir) const {
  469. if (get_system_dir_func)
  470. return get_system_dir_func(p_dir);
  471. return String(".");
  472. }
  473. void OS_Android::native_video_stop() {
  474. if (video_stop_func)
  475. video_stop_func();
  476. }
  477. void OS_Android::set_context_is_16_bits(bool p_is_16) {
  478. //use_16bits_fbo = p_is_16;
  479. //if (rasterizer)
  480. // rasterizer->set_force_16_bits_fbo(p_is_16);
  481. }
  482. void OS_Android::joy_connection_changed(int p_device, bool p_connected, String p_name) {
  483. return input->joy_connection_changed(p_device, p_connected, p_name, "");
  484. }
  485. bool OS_Android::is_joy_known(int p_device) {
  486. return input->is_joy_mapped(p_device);
  487. }
  488. String OS_Android::get_joy_guid(int p_device) const {
  489. return input->get_joy_guid_remapped(p_device);
  490. }
  491. bool OS_Android::_check_internal_feature_support(const String &p_feature) {
  492. if (p_feature == "mobile" || p_feature == "etc" || p_feature == "etc2") {
  493. //TODO support etc2 only if GLES3 driver is selected
  494. return true;
  495. }
  496. #if defined(__aarch64__)
  497. if (p_feature == "arm64-v8a") {
  498. return true;
  499. }
  500. #elif defined(__ARM_ARCH_7A__)
  501. if (p_feature == "armeabi-v7a" || p_feature == "armeabi") {
  502. return true;
  503. }
  504. #elif defined(__arm__)
  505. if (p_feature == "armeabi") {
  506. return true;
  507. }
  508. #endif
  509. return false;
  510. }
  511. 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, 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, bool p_use_apk_expansion) {
  512. use_apk_expansion = p_use_apk_expansion;
  513. default_videomode.width = 800;
  514. default_videomode.height = 600;
  515. default_videomode.fullscreen = true;
  516. default_videomode.resizable = false;
  517. gfx_init_func = p_gfx_init_func;
  518. gfx_init_ud = p_gfx_init_ud;
  519. main_loop = NULL;
  520. gl_extensions = NULL;
  521. //rasterizer = NULL;
  522. use_gl2 = false;
  523. open_uri_func = p_open_uri_func;
  524. get_user_data_dir_func = p_get_user_data_dir_func;
  525. get_locale_func = p_get_locale_func;
  526. get_model_func = p_get_model_func;
  527. get_screen_dpi_func = p_get_screen_dpi_func;
  528. get_unique_id_func = p_get_unique_id;
  529. get_system_dir_func = p_get_sdir_func;
  530. video_play_func = p_video_play_func;
  531. video_is_playing_func = p_video_is_playing_func;
  532. video_pause_func = p_video_pause_func;
  533. video_stop_func = p_video_stop_func;
  534. show_virtual_keyboard_func = p_show_vk;
  535. hide_virtual_keyboard_func = p_hide_vk;
  536. get_virtual_keyboard_height_func = p_vk_height_func;
  537. set_screen_orientation_func = p_screen_orient;
  538. set_keep_screen_on_func = p_set_keep_screen_on_func;
  539. alert_func = p_alert_func;
  540. use_reload_hooks = false;
  541. Vector<Logger *> loggers;
  542. loggers.push_back(memnew(AndroidLogger));
  543. _set_logger(memnew(CompositeLogger(loggers)));
  544. }
  545. OS_Android::~OS_Android() {
  546. }