os_android.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  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 "core/globals.h"
  38. #ifdef ANDROID_NATIVE_ACTIVITY
  39. #include "file_access_android.h"
  40. #include "dir_access_android.h"
  41. #else
  42. #include "file_access_jandroid.h"
  43. #include "dir_access_jandroid.h"
  44. #endif
  45. int OS_Android::get_video_driver_count() const {
  46. return 1;
  47. }
  48. const char * OS_Android::get_video_driver_name(int p_driver) const {
  49. return "GLES2";
  50. }
  51. OS::VideoMode OS_Android::get_default_video_mode() const {
  52. return OS::VideoMode();
  53. }
  54. int OS_Android::get_audio_driver_count() const {
  55. return 1;
  56. }
  57. const char * OS_Android::get_audio_driver_name(int p_driver) const {
  58. return "Android";
  59. }
  60. void OS_Android::initialize_core() {
  61. OS_Unix::initialize_core();
  62. #ifdef ANDROID_NATIVE_ACTIVITY
  63. FileAccess::make_default<FileAccessAndroid>(FileAccess::ACCESS_RESOURCES);
  64. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
  65. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_FILESYSTEM);
  66. //FileAccessBufferedFA<FileAccessUnix>::make_default();
  67. DirAccess::make_default<DirAccessAndroid>(DirAccess::ACCESS_RESOURCES);
  68. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_USERDATA);
  69. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_FILESYSTEM);
  70. #else
  71. if (use_apk_expansion)
  72. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_RESOURCES);
  73. else
  74. FileAccess::make_default<FileAccessBufferedFA<FileAccessJAndroid> >(FileAccess::ACCESS_RESOURCES);
  75. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
  76. FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_FILESYSTEM);
  77. //FileAccessBufferedFA<FileAccessUnix>::make_default();
  78. if (use_apk_expansion)
  79. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_RESOURCES);
  80. else
  81. DirAccess::make_default<DirAccessJAndroid>(DirAccess::ACCESS_RESOURCES);
  82. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_USERDATA);
  83. DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_FILESYSTEM);
  84. #endif
  85. }
  86. void OS_Android::set_opengl_extensions(const char* p_gl_extensions) {
  87. ERR_FAIL_COND(!p_gl_extensions);
  88. gl_extensions=p_gl_extensions;
  89. }
  90. void OS_Android::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) {
  91. use_gl2=p_video_driver!=1;
  92. if (gfx_init_func)
  93. gfx_init_func(gfx_init_ud,use_gl2);
  94. AudioDriverManagerSW::add_driver(&audio_driver_android);
  95. if (true) {
  96. RasterizerGLES2 *rasterizer_gles22=memnew( RasterizerGLES2(false,use_reload_hooks,false,use_reload_hooks ) );
  97. if (gl_extensions)
  98. rasterizer_gles22->set_extensions(gl_extensions);
  99. rasterizer = rasterizer_gles22;
  100. } else {
  101. //rasterizer = memnew( RasterizerGLES1(use_reload_hooks, use_reload_hooks) );
  102. }
  103. visual_server = memnew( VisualServerRaster(rasterizer) );
  104. if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
  105. visual_server = memnew(VisualServerWrapMT(visual_server, false));
  106. };
  107. visual_server->init();
  108. visual_server->cursor_set_visible(false, 0);
  109. AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
  110. if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) {
  111. ERR_PRINT("Initializing audio failed.");
  112. }
  113. sample_manager = memnew( SampleManagerMallocSW );
  114. audio_server = memnew( AudioServerSW(sample_manager) );
  115. audio_server->set_mixer_params(AudioMixerSW::INTERPOLATION_LINEAR,true);
  116. audio_server->init();
  117. spatial_sound_server = memnew( SpatialSoundServerSW );
  118. spatial_sound_server->init();
  119. spatial_sound_2d_server = memnew( SpatialSound2DServerSW );
  120. spatial_sound_2d_server->init();
  121. //
  122. physics_server = memnew( PhysicsServerSW );
  123. physics_server->init();
  124. physics_2d_server = memnew( Physics2DServerSW );
  125. physics_2d_server->init();
  126. input = memnew( InputDefault );
  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. #if 0
  132. print_line("preGS");
  133. FileAccess *f=memnew( FileAccessAndroid );
  134. print("made f %p\n",f);
  135. Error err = f->open("AndroidManifest.xml",FileAccess::READ);
  136. if (err) {
  137. print("************NO FILE!!\n");
  138. } else {
  139. print("************YES FILE!!\n");
  140. }
  141. f->close();
  142. print_line("end");
  143. AAssetDir* aad = AAssetManager_openDir(FileAccessAndroid::asset_manager,".");
  144. if (aad) {
  145. print_line("DIR OPEN OK");
  146. const char *fn= AAssetDir_getNextFileName(aad);
  147. while(fn) {
  148. print_line("FNAME: "+String(fn));
  149. fn= AAssetDir_getNextFileName(aad);
  150. }
  151. AAssetDir_close(aad);
  152. } else {
  153. print_line("DIR NO OPEN");
  154. }
  155. #endif
  156. }
  157. void OS_Android::delete_main_loop() {
  158. memdelete( main_loop );
  159. }
  160. void OS_Android::finalize() {
  161. memdelete(input);
  162. }
  163. void OS_Android::vprint(const char* p_format, va_list p_list, bool p_stderr) {
  164. __android_log_vprint(p_stderr?ANDROID_LOG_ERROR:ANDROID_LOG_INFO,"godot",p_format,p_list);
  165. }
  166. void OS_Android::print(const char *p_format, ... ) {
  167. va_list argp;
  168. va_start(argp, p_format);
  169. __android_log_vprint(ANDROID_LOG_INFO,"godot",p_format,argp);
  170. va_end(argp);
  171. }
  172. void OS_Android::alert(const String& p_alert) {
  173. print("ALERT: %s\n",p_alert.utf8().get_data());
  174. }
  175. void OS_Android::set_mouse_show(bool p_show) {
  176. //android has no mouse...
  177. }
  178. void OS_Android::set_mouse_grab(bool p_grab) {
  179. //it really has no mouse...!
  180. }
  181. bool OS_Android::is_mouse_grab_enabled() const {
  182. //*sigh* technology has evolved so much since i was a kid..
  183. return false;
  184. }
  185. Point2 OS_Android::get_mouse_pos() const {
  186. return Point2();
  187. }
  188. int OS_Android::get_mouse_button_state() const {
  189. return 0;
  190. }
  191. void OS_Android::set_window_title(const String& p_title) {
  192. }
  193. //interesting byt not yet
  194. //void set_clipboard(const String& p_text);
  195. //String get_clipboard() const;
  196. void OS_Android::set_video_mode(const VideoMode& p_video_mode,int p_screen) {
  197. }
  198. OS::VideoMode OS_Android::get_video_mode(int p_screen) const {
  199. return default_videomode;
  200. }
  201. void OS_Android::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const {
  202. p_list->push_back(default_videomode);
  203. }
  204. Size2 OS_Android::get_window_size() const {
  205. return Vector2(default_videomode.width,default_videomode.height);
  206. }
  207. String OS_Android::get_name() {
  208. return "Android";
  209. }
  210. MainLoop *OS_Android::get_main_loop() const {
  211. return main_loop;
  212. }
  213. bool OS_Android::can_draw() const {
  214. return true; //always?
  215. }
  216. void OS_Android::set_cursor_shape(CursorShape p_shape) {
  217. //android really really really has no mouse.. how amazing..
  218. }
  219. void OS_Android::main_loop_begin() {
  220. if (main_loop)
  221. main_loop->init();
  222. }
  223. bool OS_Android::main_loop_iterate() {
  224. if (!main_loop)
  225. return false;
  226. return Main::iteration();
  227. }
  228. void OS_Android::main_loop_end() {
  229. if (main_loop)
  230. main_loop->finish();
  231. }
  232. void OS_Android::main_loop_focusout() {
  233. if (main_loop)
  234. main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
  235. audio_driver_android.set_pause(true);
  236. }
  237. void OS_Android::main_loop_focusin(){
  238. if (main_loop)
  239. main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
  240. audio_driver_android.set_pause(false);
  241. }
  242. void OS_Android::process_event(InputEvent p_event) {
  243. p_event.ID = last_id++;
  244. input->parse_input_event(p_event);
  245. };
  246. void OS_Android::process_touch(int p_what,int p_pointer, const Vector<TouchPos>& p_points) {
  247. // print_line("ev: "+itos(p_what)+" pnt: "+itos(p_pointer)+" pointc: "+itos(p_points.size()));
  248. switch(p_what) {
  249. case 0: { //gesture begin
  250. if (touch.size()) {
  251. //end all if exist
  252. InputEvent ev;
  253. ev.type=InputEvent::MOUSE_BUTTON;
  254. ev.ID=last_id++;
  255. ev.mouse_button.button_index=BUTTON_LEFT;
  256. ev.mouse_button.button_mask=BUTTON_MASK_LEFT;
  257. ev.mouse_button.pressed=false;
  258. ev.mouse_button.x=touch[0].pos.x;
  259. ev.mouse_button.y=touch[0].pos.y;
  260. ev.mouse_button.global_x=touch[0].pos.x;
  261. ev.mouse_button.global_y=touch[0].pos.y;
  262. input->parse_input_event(ev);
  263. for(int i=0;i<touch.size();i++) {
  264. InputEvent ev;
  265. ev.type=InputEvent::SCREEN_TOUCH;
  266. ev.ID=last_id++;
  267. ev.screen_touch.index=touch[i].id;
  268. ev.screen_touch.pressed=false;
  269. ev.screen_touch.x=touch[i].pos.x;
  270. ev.screen_touch.y=touch[i].pos.y;
  271. input->parse_input_event(ev);
  272. }
  273. }
  274. touch.resize(p_points.size());
  275. for(int i=0;i<p_points.size();i++) {
  276. touch[i].id=p_points[i].id;
  277. touch[i].pos=p_points[i].pos;
  278. }
  279. {
  280. //send mouse
  281. InputEvent ev;
  282. ev.type=InputEvent::MOUSE_BUTTON;
  283. ev.ID=last_id++;
  284. ev.mouse_button.button_index=BUTTON_LEFT;
  285. ev.mouse_button.button_mask=BUTTON_MASK_LEFT;
  286. ev.mouse_button.pressed=true;
  287. ev.mouse_button.x=touch[0].pos.x;
  288. ev.mouse_button.y=touch[0].pos.y;
  289. ev.mouse_button.global_x=touch[0].pos.x;
  290. ev.mouse_button.global_y=touch[0].pos.y;
  291. last_mouse=touch[0].pos;
  292. input->parse_input_event(ev);
  293. }
  294. //send touch
  295. for(int i=0;i<touch.size();i++) {
  296. InputEvent ev;
  297. ev.type=InputEvent::SCREEN_TOUCH;
  298. ev.ID=last_id++;
  299. ev.screen_touch.index=touch[i].id;
  300. ev.screen_touch.pressed=true;
  301. ev.screen_touch.x=touch[i].pos.x;
  302. ev.screen_touch.y=touch[i].pos.y;
  303. input->parse_input_event(ev);
  304. }
  305. } break;
  306. case 1: { //motion
  307. if (p_points.size()) {
  308. //send mouse, should look for point 0?
  309. InputEvent ev;
  310. ev.type=InputEvent::MOUSE_MOTION;
  311. ev.ID=last_id++;
  312. ev.mouse_motion.button_mask=BUTTON_MASK_LEFT;
  313. ev.mouse_motion.x=p_points[0].pos.x;
  314. ev.mouse_motion.y=p_points[0].pos.y;
  315. input->set_mouse_pos(Point2(ev.mouse_motion.x,ev.mouse_motion.y));
  316. ev.mouse_motion.speed_x=input->get_mouse_speed().x;
  317. ev.mouse_motion.speed_y=input->get_mouse_speed().y;
  318. ev.mouse_motion.relative_x=p_points[0].pos.x-last_mouse.x;
  319. ev.mouse_motion.relative_y=p_points[0].pos.y-last_mouse.y;
  320. last_mouse=p_points[0].pos;
  321. input->parse_input_event(ev);
  322. }
  323. ERR_FAIL_COND(touch.size()!=p_points.size());
  324. for(int i=0;i<touch.size();i++) {
  325. int idx=-1;
  326. for(int j=0;j<p_points.size();j++) {
  327. if (touch[i].id==p_points[j].id) {
  328. idx=j;
  329. break;
  330. }
  331. }
  332. ERR_CONTINUE(idx==-1);
  333. if (touch[i].pos==p_points[idx].pos)
  334. continue; //no move unncesearily
  335. InputEvent ev;
  336. ev.type=InputEvent::SCREEN_DRAG;
  337. ev.ID=last_id++;
  338. ev.screen_drag.index=touch[i].id;
  339. ev.screen_drag.x=p_points[idx].pos.x;
  340. ev.screen_drag.y=p_points[idx].pos.y;
  341. ev.screen_drag.relative_x=p_points[idx].pos.x - touch[i].pos.x;
  342. ev.screen_drag.relative_y=p_points[idx].pos.y - touch[i].pos.y;
  343. input->parse_input_event(ev);
  344. touch[i].pos=p_points[idx].pos;
  345. }
  346. } break;
  347. case 2: { //release
  348. if (touch.size()) {
  349. //end all if exist
  350. InputEvent ev;
  351. ev.type=InputEvent::MOUSE_BUTTON;
  352. ev.ID=last_id++;
  353. ev.mouse_button.button_index=BUTTON_LEFT;
  354. ev.mouse_button.button_mask=BUTTON_MASK_LEFT;
  355. ev.mouse_button.pressed=false;
  356. ev.mouse_button.x=touch[0].pos.x;
  357. ev.mouse_button.y=touch[0].pos.y;
  358. ev.mouse_button.global_x=touch[0].pos.x;
  359. ev.mouse_button.global_y=touch[0].pos.y;
  360. input->parse_input_event(ev);
  361. for(int i=0;i<touch.size();i++) {
  362. InputEvent ev;
  363. ev.type=InputEvent::SCREEN_TOUCH;
  364. ev.ID=last_id++;
  365. ev.screen_touch.index=touch[i].id;
  366. ev.screen_touch.pressed=false;
  367. ev.screen_touch.x=touch[i].pos.x;
  368. ev.screen_touch.y=touch[i].pos.y;
  369. input->parse_input_event(ev);
  370. }
  371. touch.clear();
  372. }
  373. } break;
  374. case 3: { // add tuchi
  375. ERR_FAIL_INDEX(p_pointer,p_points.size());
  376. TouchPos tp=p_points[p_pointer];
  377. touch.push_back(tp);
  378. InputEvent ev;
  379. ev.type=InputEvent::SCREEN_TOUCH;
  380. ev.ID=last_id++;
  381. ev.screen_touch.index=tp.id;
  382. ev.screen_touch.pressed=true;
  383. ev.screen_touch.x=tp.pos.x;
  384. ev.screen_touch.y=tp.pos.y;
  385. input->parse_input_event(ev);
  386. } break;
  387. case 4: {
  388. for(int i=0;i<touch.size();i++) {
  389. if (touch[i].id==p_pointer) {
  390. InputEvent ev;
  391. ev.type=InputEvent::SCREEN_TOUCH;
  392. ev.ID=last_id++;
  393. ev.screen_touch.index=touch[i].id;
  394. ev.screen_touch.pressed=false;
  395. ev.screen_touch.x=touch[i].pos.x;
  396. ev.screen_touch.y=touch[i].pos.y;
  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. bool OS_Android::has_touchscreen_ui_hint() const {
  409. return true;
  410. }
  411. bool OS_Android::has_virtual_keyboard() const {
  412. return true;
  413. };
  414. void OS_Android::show_virtual_keyboard(const String& p_existing_text,const Rect2& p_screen_rect) {
  415. if (show_virtual_keyboard_func) {
  416. show_virtual_keyboard_func(p_existing_text);
  417. } else {
  418. ERR_PRINT("Virtual keyboard not available");
  419. };
  420. };
  421. void OS_Android::hide_virtual_keyboard() {
  422. if (hide_virtual_keyboard_func) {
  423. hide_virtual_keyboard_func();
  424. } else {
  425. ERR_PRINT("Virtual keyboard not available");
  426. };
  427. };
  428. void OS_Android::init_video_mode(int p_video_width,int p_video_height) {
  429. default_videomode.width=p_video_width;
  430. default_videomode.height=p_video_height;
  431. default_videomode.fullscreen=true;
  432. default_videomode.resizable=false;
  433. }
  434. void OS_Android::main_loop_request_quit() {
  435. if (main_loop)
  436. main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
  437. }
  438. void OS_Android::set_display_size(Size2 p_size) {
  439. default_videomode.width=p_size.x;
  440. default_videomode.height=p_size.y;
  441. }
  442. void OS_Android::reload_gfx() {
  443. if (gfx_init_func)
  444. gfx_init_func(gfx_init_ud,use_gl2);
  445. if (rasterizer)
  446. rasterizer->reload_vram();
  447. }
  448. Error OS_Android::shell_open(String p_uri) {
  449. if (open_uri_func)
  450. return open_uri_func(p_uri)?ERR_CANT_OPEN:OK;
  451. return ERR_UNAVAILABLE;
  452. };
  453. String OS_Android::get_resource_dir() const {
  454. return "/"; //android has it's own filesystem for resources inside the APK
  455. }
  456. String OS_Android::get_locale() const {
  457. if (get_locale_func)
  458. return get_locale_func();
  459. return OS_Unix::get_locale();
  460. }
  461. String OS_Android::get_model_name() const {
  462. if (get_model_func)
  463. return get_model_func();
  464. return OS_Unix::get_model_name();
  465. }
  466. void OS_Android::set_need_reload_hooks(bool p_needs_them) {
  467. use_reload_hooks=p_needs_them;
  468. }
  469. String OS_Android::get_data_dir() const {
  470. if (get_data_dir_func)
  471. return get_data_dir_func();
  472. return ".";
  473. //return Globals::get_singleton()->get_singleton_object("GodotOS")->call("get_data_dir");
  474. };
  475. void OS_Android::set_screen_orientation(ScreenOrientation p_orientation) {
  476. if (set_screen_orientation_func)
  477. set_screen_orientation_func(p_orientation);
  478. }
  479. String OS_Android::get_unique_ID() const {
  480. if (get_unique_id_func)
  481. return get_unique_id_func();
  482. return OS::get_unique_ID();
  483. }
  484. Error OS_Android::native_video_play(String p_path, float p_volume) {
  485. if (video_play_func)
  486. video_play_func(p_path);
  487. return OK;
  488. }
  489. bool OS_Android::native_video_is_playing() {
  490. if (video_is_playing_func)
  491. return video_is_playing_func();
  492. return false;
  493. }
  494. void OS_Android::native_video_pause() {
  495. if (video_pause_func)
  496. video_pause_func();
  497. }
  498. String OS_Android::get_system_dir(SystemDir p_dir) const {
  499. if (get_system_dir_func)
  500. return get_system_dir_func(p_dir);
  501. return String(".");
  502. }
  503. void OS_Android::native_video_stop() {
  504. if (video_stop_func)
  505. video_stop_func();
  506. }
  507. 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) {
  508. use_apk_expansion=p_use_apk_expansion;
  509. default_videomode.width=800;
  510. default_videomode.height=600;
  511. default_videomode.fullscreen=true;
  512. default_videomode.resizable=false;
  513. gfx_init_func=p_gfx_init_func;
  514. gfx_init_ud=p_gfx_init_ud;
  515. main_loop=NULL;
  516. last_id=1;
  517. gl_extensions=NULL;
  518. rasterizer=NULL;
  519. use_gl2=false;
  520. open_uri_func=p_open_uri_func;
  521. get_data_dir_func=p_get_data_dir_func;
  522. get_locale_func=p_get_locale_func;
  523. get_model_func=p_get_model_func;
  524. get_unique_id_func=p_get_unique_id;
  525. get_system_dir_func=p_get_sdir_func;
  526. video_play_func = p_video_play_func;
  527. video_is_playing_func = p_video_is_playing_func;
  528. video_pause_func = p_video_pause_func;
  529. video_stop_func = p_video_stop_func;
  530. show_virtual_keyboard_func = p_show_vk;
  531. hide_virtual_keyboard_func = p_hide_vk;
  532. set_screen_orientation_func=p_screen_orient;
  533. use_reload_hooks=false;
  534. }
  535. OS_Android::~OS_Android() {
  536. }