os_android.cpp 20 KB

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