os_android.cpp 20 KB

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