os_android.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  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-2015 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #include "os_android.h"
  30. #include "drivers/gles2/rasterizer_gles2.h"
  31. #include "core/io/file_access_buffered_fa.h"
  32. #include "drivers/unix/file_access_unix.h"
  33. #include "drivers/unix/dir_access_unix.h"
  34. #include "servers/visual/visual_server_raster.h"
  35. #include "servers/visual/visual_server_wrap_mt.h"
  36. #include "main/main.h"
  37. #include "file_access_android.h"
  38. #include "core/globals.h"
  39. #ifdef ANDROID_NATIVE_ACTIVITY
  40. #include "file_access_android.h"
  41. #include "dir_access_android.h"
  42. #else
  43. #include "file_access_jandroid.h"
  44. #include "dir_access_jandroid.h"
  45. #endif
  46. int OS_Android::get_video_driver_count() const {
  47. return 1;
  48. }
  49. const char * OS_Android::get_video_driver_name(int p_driver) const {
  50. return "GLES2";
  51. }
  52. OS::VideoMode OS_Android::get_default_video_mode() const {
  53. return OS::VideoMode();
  54. }
  55. int OS_Android::get_audio_driver_count() const {
  56. return 1;
  57. }
  58. const char * OS_Android::get_audio_driver_name(int p_driver) const {
  59. return "Android";
  60. }
  61. void OS_Android::initialize_core() {
  62. OS_Unix::initialize_core();
  63. #ifdef ANDROID_NATIVE_ACTIVITY
  64. FileAccess::make_default<FileAccessAndroid>(FileAccess::ACCESS_RESOURCES);
  65. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
  66. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_FILESYSTEM);
  67. //FileAccessBufferedFA<FileAccessUnix>::make_default();
  68. DirAccess::make_default<DirAccessAndroid>(DirAccess::ACCESS_RESOURCES);
  69. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_USERDATA);
  70. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_FILESYSTEM);
  71. #else
  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. #endif
  92. }
  93. void OS_Android::set_opengl_extensions(const char* p_gl_extensions) {
  94. ERR_FAIL_COND(!p_gl_extensions);
  95. gl_extensions=p_gl_extensions;
  96. }
  97. void OS_Android::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) {
  98. use_gl2=p_video_driver!=1;
  99. if (gfx_init_func)
  100. gfx_init_func(gfx_init_ud,use_gl2);
  101. AudioDriverManagerSW::add_driver(&audio_driver_android);
  102. if (true) {
  103. RasterizerGLES2 *rasterizer_gles22=memnew( RasterizerGLES2(false,use_reload_hooks,false,use_reload_hooks ) );
  104. if (gl_extensions)
  105. rasterizer_gles22->set_extensions(gl_extensions);
  106. rasterizer = rasterizer_gles22;
  107. } else {
  108. //rasterizer = memnew( RasterizerGLES1(use_reload_hooks, use_reload_hooks) );
  109. }
  110. visual_server = memnew( VisualServerRaster(rasterizer) );
  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. AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
  117. if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) {
  118. ERR_PRINT("Initializing audio failed.");
  119. }
  120. sample_manager = memnew( SampleManagerMallocSW );
  121. audio_server = memnew( AudioServerSW(sample_manager) );
  122. audio_server->set_mixer_params(AudioMixerSW::INTERPOLATION_LINEAR,true);
  123. audio_server->init();
  124. spatial_sound_server = memnew( SpatialSoundServerSW );
  125. spatial_sound_server->init();
  126. spatial_sound_2d_server = memnew( SpatialSound2DServerSW );
  127. spatial_sound_2d_server->init();
  128. //
  129. physics_server = memnew( PhysicsServerSW );
  130. physics_server->init();
  131. //physics_2d_server = memnew( Physics2DServerSW );
  132. physics_2d_server = Physics2DServerWrapMT::init_server<Physics2DServerSW>();
  133. physics_2d_server->init();
  134. input = memnew( InputDefault );
  135. }
  136. void OS_Android::set_main_loop( MainLoop * p_main_loop ) {
  137. main_loop=p_main_loop;
  138. input->set_main_loop(p_main_loop);
  139. #if 0
  140. print_line("preGS");
  141. FileAccess *f=memnew( FileAccessAndroid );
  142. print("made f %p\n",f);
  143. Error err = f->open("AndroidManifest.xml",FileAccess::READ);
  144. if (err) {
  145. print("************NO FILE!!\n");
  146. } else {
  147. print("************YES FILE!!\n");
  148. }
  149. f->close();
  150. print_line("end");
  151. AAssetDir* aad = AAssetManager_openDir(FileAccessAndroid::asset_manager,".");
  152. if (aad) {
  153. print_line("DIR OPEN OK");
  154. const char *fn= AAssetDir_getNextFileName(aad);
  155. while(fn) {
  156. print_line("FNAME: "+String(fn));
  157. fn= AAssetDir_getNextFileName(aad);
  158. }
  159. AAssetDir_close(aad);
  160. } else {
  161. print_line("DIR NO OPEN");
  162. }
  163. #endif
  164. }
  165. void OS_Android::delete_main_loop() {
  166. memdelete( main_loop );
  167. }
  168. void OS_Android::finalize() {
  169. memdelete(input);
  170. }
  171. void OS_Android::vprint(const char* p_format, va_list p_list, bool p_stderr) {
  172. __android_log_vprint(p_stderr?ANDROID_LOG_ERROR:ANDROID_LOG_INFO,"godot",p_format,p_list);
  173. }
  174. void OS_Android::print(const char *p_format, ... ) {
  175. va_list argp;
  176. va_start(argp, p_format);
  177. __android_log_vprint(ANDROID_LOG_INFO,"godot",p_format,argp);
  178. va_end(argp);
  179. }
  180. void OS_Android::alert(const String& p_alert) {
  181. print("ALERT: %s\n",p_alert.utf8().get_data());
  182. }
  183. void OS_Android::set_mouse_show(bool p_show) {
  184. //android has no mouse...
  185. }
  186. void OS_Android::set_mouse_grab(bool p_grab) {
  187. //it really has no mouse...!
  188. }
  189. bool OS_Android::is_mouse_grab_enabled() const {
  190. //*sigh* technology has evolved so much since i was a kid..
  191. return false;
  192. }
  193. Point2 OS_Android::get_mouse_pos() const {
  194. return Point2();
  195. }
  196. int OS_Android::get_mouse_button_state() const {
  197. return 0;
  198. }
  199. void OS_Android::set_window_title(const String& p_title) {
  200. }
  201. //interesting byt not yet
  202. //void set_clipboard(const String& p_text);
  203. //String get_clipboard() const;
  204. void OS_Android::set_video_mode(const VideoMode& p_video_mode,int p_screen) {
  205. }
  206. OS::VideoMode OS_Android::get_video_mode(int p_screen) const {
  207. return default_videomode;
  208. }
  209. void OS_Android::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const {
  210. p_list->push_back(default_videomode);
  211. }
  212. Size2 OS_Android::get_window_size() const {
  213. return Vector2(default_videomode.width,default_videomode.height);
  214. }
  215. String OS_Android::get_name() {
  216. return "Android";
  217. }
  218. MainLoop *OS_Android::get_main_loop() const {
  219. return main_loop;
  220. }
  221. bool OS_Android::can_draw() const {
  222. return true; //always?
  223. }
  224. void OS_Android::set_cursor_shape(CursorShape p_shape) {
  225. //android really really really has no mouse.. how amazing..
  226. }
  227. void OS_Android::main_loop_begin() {
  228. if (main_loop)
  229. main_loop->init();
  230. }
  231. bool OS_Android::main_loop_iterate() {
  232. if (!main_loop)
  233. return false;
  234. return Main::iteration();
  235. }
  236. void OS_Android::main_loop_end() {
  237. if (main_loop)
  238. main_loop->finish();
  239. }
  240. void OS_Android::main_loop_focusout() {
  241. if (main_loop)
  242. main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
  243. audio_driver_android.set_pause(true);
  244. }
  245. void OS_Android::main_loop_focusin(){
  246. if (main_loop)
  247. main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
  248. audio_driver_android.set_pause(false);
  249. }
  250. void OS_Android::process_event(InputEvent p_event) {
  251. p_event.ID = last_id++;
  252. input->parse_input_event(p_event);
  253. };
  254. void OS_Android::process_touch(int p_what,int p_pointer, const Vector<TouchPos>& p_points) {
  255. // print_line("ev: "+itos(p_what)+" pnt: "+itos(p_pointer)+" pointc: "+itos(p_points.size()));
  256. switch(p_what) {
  257. case 0: { //gesture begin
  258. if (touch.size()) {
  259. //end all if exist
  260. InputEvent ev;
  261. ev.type=InputEvent::MOUSE_BUTTON;
  262. ev.ID=last_id++;
  263. ev.mouse_button.button_index=BUTTON_LEFT;
  264. ev.mouse_button.button_mask=BUTTON_MASK_LEFT;
  265. ev.mouse_button.pressed=false;
  266. ev.mouse_button.x=touch[0].pos.x;
  267. ev.mouse_button.y=touch[0].pos.y;
  268. ev.mouse_button.global_x=touch[0].pos.x;
  269. ev.mouse_button.global_y=touch[0].pos.y;
  270. input->parse_input_event(ev);
  271. for(int i=0;i<touch.size();i++) {
  272. InputEvent ev;
  273. ev.type=InputEvent::SCREEN_TOUCH;
  274. ev.ID=last_id++;
  275. ev.screen_touch.index=touch[i].id;
  276. ev.screen_touch.pressed=false;
  277. ev.screen_touch.x=touch[i].pos.x;
  278. ev.screen_touch.y=touch[i].pos.y;
  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[i].id=p_points[i].id;
  285. touch[i].pos=p_points[i].pos;
  286. }
  287. {
  288. //send mouse
  289. InputEvent ev;
  290. ev.type=InputEvent::MOUSE_BUTTON;
  291. ev.ID=last_id++;
  292. ev.mouse_button.button_index=BUTTON_LEFT;
  293. ev.mouse_button.button_mask=BUTTON_MASK_LEFT;
  294. ev.mouse_button.pressed=true;
  295. ev.mouse_button.x=touch[0].pos.x;
  296. ev.mouse_button.y=touch[0].pos.y;
  297. ev.mouse_button.global_x=touch[0].pos.x;
  298. ev.mouse_button.global_y=touch[0].pos.y;
  299. last_mouse=touch[0].pos;
  300. input->parse_input_event(ev);
  301. }
  302. //send touch
  303. for(int i=0;i<touch.size();i++) {
  304. InputEvent ev;
  305. ev.type=InputEvent::SCREEN_TOUCH;
  306. ev.ID=last_id++;
  307. ev.screen_touch.index=touch[i].id;
  308. ev.screen_touch.pressed=true;
  309. ev.screen_touch.x=touch[i].pos.x;
  310. ev.screen_touch.y=touch[i].pos.y;
  311. input->parse_input_event(ev);
  312. }
  313. } break;
  314. case 1: { //motion
  315. if (p_points.size()) {
  316. //send mouse, should look for point 0?
  317. InputEvent ev;
  318. ev.type=InputEvent::MOUSE_MOTION;
  319. ev.ID=last_id++;
  320. ev.mouse_motion.button_mask=BUTTON_MASK_LEFT;
  321. ev.mouse_motion.x=p_points[0].pos.x;
  322. ev.mouse_motion.y=p_points[0].pos.y;
  323. input->set_mouse_pos(Point2(ev.mouse_motion.x,ev.mouse_motion.y));
  324. ev.mouse_motion.speed_x=input->get_mouse_speed().x;
  325. ev.mouse_motion.speed_y=input->get_mouse_speed().y;
  326. ev.mouse_motion.relative_x=p_points[0].pos.x-last_mouse.x;
  327. ev.mouse_motion.relative_y=p_points[0].pos.y-last_mouse.y;
  328. last_mouse=p_points[0].pos;
  329. input->parse_input_event(ev);
  330. }
  331. ERR_FAIL_COND(touch.size()!=p_points.size());
  332. for(int i=0;i<touch.size();i++) {
  333. int idx=-1;
  334. for(int j=0;j<p_points.size();j++) {
  335. if (touch[i].id==p_points[j].id) {
  336. idx=j;
  337. break;
  338. }
  339. }
  340. ERR_CONTINUE(idx==-1);
  341. if (touch[i].pos==p_points[idx].pos)
  342. continue; //no move unncesearily
  343. InputEvent ev;
  344. ev.type=InputEvent::SCREEN_DRAG;
  345. ev.ID=last_id++;
  346. ev.screen_drag.index=touch[i].id;
  347. ev.screen_drag.x=p_points[idx].pos.x;
  348. ev.screen_drag.y=p_points[idx].pos.y;
  349. ev.screen_drag.relative_x=p_points[idx].pos.x - touch[i].pos.x;
  350. ev.screen_drag.relative_y=p_points[idx].pos.y - touch[i].pos.y;
  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. InputEvent ev;
  359. ev.type=InputEvent::MOUSE_BUTTON;
  360. ev.ID=last_id++;
  361. ev.mouse_button.button_index=BUTTON_LEFT;
  362. ev.mouse_button.button_mask=BUTTON_MASK_LEFT;
  363. ev.mouse_button.pressed=false;
  364. ev.mouse_button.x=touch[0].pos.x;
  365. ev.mouse_button.y=touch[0].pos.y;
  366. ev.mouse_button.global_x=touch[0].pos.x;
  367. ev.mouse_button.global_y=touch[0].pos.y;
  368. input->parse_input_event(ev);
  369. for(int i=0;i<touch.size();i++) {
  370. InputEvent ev;
  371. ev.type=InputEvent::SCREEN_TOUCH;
  372. ev.ID=last_id++;
  373. ev.screen_touch.index=touch[i].id;
  374. ev.screen_touch.pressed=false;
  375. ev.screen_touch.x=touch[i].pos.x;
  376. ev.screen_touch.y=touch[i].pos.y;
  377. input->parse_input_event(ev);
  378. }
  379. touch.clear();
  380. }
  381. } break;
  382. case 3: { // add tuchi
  383. ERR_FAIL_INDEX(p_pointer,p_points.size());
  384. TouchPos tp=p_points[p_pointer];
  385. touch.push_back(tp);
  386. InputEvent ev;
  387. ev.type=InputEvent::SCREEN_TOUCH;
  388. ev.ID=last_id++;
  389. ev.screen_touch.index=tp.id;
  390. ev.screen_touch.pressed=true;
  391. ev.screen_touch.x=tp.pos.x;
  392. ev.screen_touch.y=tp.pos.y;
  393. input->parse_input_event(ev);
  394. } break;
  395. case 4: {
  396. for(int i=0;i<touch.size();i++) {
  397. if (touch[i].id==p_pointer) {
  398. InputEvent ev;
  399. ev.type=InputEvent::SCREEN_TOUCH;
  400. ev.ID=last_id++;
  401. ev.screen_touch.index=touch[i].id;
  402. ev.screen_touch.pressed=false;
  403. ev.screen_touch.x=touch[i].pos.x;
  404. ev.screen_touch.y=touch[i].pos.y;
  405. input->parse_input_event(ev);
  406. touch.remove(i);
  407. i--;
  408. }
  409. }
  410. } break;
  411. }
  412. }
  413. void OS_Android::process_accelerometer(const Vector3& p_accelerometer) {
  414. input->set_accelerometer(p_accelerometer);
  415. }
  416. bool OS_Android::has_touchscreen_ui_hint() const {
  417. return true;
  418. }
  419. bool OS_Android::has_virtual_keyboard() const {
  420. return true;
  421. };
  422. void OS_Android::show_virtual_keyboard(const String& p_existing_text,const Rect2& p_screen_rect) {
  423. if (show_virtual_keyboard_func) {
  424. show_virtual_keyboard_func(p_existing_text);
  425. } else {
  426. ERR_PRINT("Virtual keyboard not available");
  427. };
  428. };
  429. void OS_Android::hide_virtual_keyboard() {
  430. if (hide_virtual_keyboard_func) {
  431. hide_virtual_keyboard_func();
  432. } else {
  433. ERR_PRINT("Virtual keyboard not available");
  434. };
  435. };
  436. void OS_Android::init_video_mode(int p_video_width,int p_video_height) {
  437. default_videomode.width=p_video_width;
  438. default_videomode.height=p_video_height;
  439. default_videomode.fullscreen=true;
  440. default_videomode.resizable=false;
  441. }
  442. void OS_Android::main_loop_request_quit() {
  443. if (main_loop)
  444. main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
  445. }
  446. void OS_Android::set_display_size(Size2 p_size) {
  447. default_videomode.width=p_size.x;
  448. default_videomode.height=p_size.y;
  449. }
  450. void OS_Android::reload_gfx() {
  451. if (gfx_init_func)
  452. gfx_init_func(gfx_init_ud,use_gl2);
  453. if (rasterizer)
  454. rasterizer->reload_vram();
  455. }
  456. Error OS_Android::shell_open(String p_uri) {
  457. if (open_uri_func)
  458. return open_uri_func(p_uri)?ERR_CANT_OPEN:OK;
  459. return ERR_UNAVAILABLE;
  460. };
  461. String OS_Android::get_resource_dir() const {
  462. return "/"; //android has it's own filesystem for resources inside the APK
  463. }
  464. String OS_Android::get_locale() const {
  465. if (get_locale_func)
  466. return get_locale_func();
  467. return OS_Unix::get_locale();
  468. }
  469. String OS_Android::get_model_name() const {
  470. if (get_model_func)
  471. return get_model_func();
  472. return OS_Unix::get_model_name();
  473. }
  474. void OS_Android::set_need_reload_hooks(bool p_needs_them) {
  475. use_reload_hooks=p_needs_them;
  476. }
  477. String OS_Android::get_data_dir() const {
  478. if (get_data_dir_func)
  479. return get_data_dir_func();
  480. return ".";
  481. //return Globals::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. 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, 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,bool p_use_apk_expansion) {
  516. use_apk_expansion=p_use_apk_expansion;
  517. default_videomode.width=800;
  518. default_videomode.height=600;
  519. default_videomode.fullscreen=true;
  520. default_videomode.resizable=false;
  521. gfx_init_func=p_gfx_init_func;
  522. gfx_init_ud=p_gfx_init_ud;
  523. main_loop=NULL;
  524. last_id=1;
  525. gl_extensions=NULL;
  526. rasterizer=NULL;
  527. use_gl2=false;
  528. open_uri_func=p_open_uri_func;
  529. get_data_dir_func=p_get_data_dir_func;
  530. get_locale_func=p_get_locale_func;
  531. get_model_func=p_get_model_func;
  532. get_unique_id_func=p_get_unique_id;
  533. get_system_dir_func=p_get_sdir_func;
  534. video_play_func = p_video_play_func;
  535. video_is_playing_func = p_video_is_playing_func;
  536. video_pause_func = p_video_pause_func;
  537. video_stop_func = p_video_stop_func;
  538. show_virtual_keyboard_func = p_show_vk;
  539. hide_virtual_keyboard_func = p_hide_vk;
  540. set_screen_orientation_func=p_screen_orient;
  541. use_reload_hooks=false;
  542. }
  543. OS_Android::~OS_Android() {
  544. }