os_iphone.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*************************************************************************/
  2. /* os_iphone.h */
  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. #ifdef IPHONE_ENABLED
  30. #ifndef OS_IPHONE_H
  31. #define OS_IPHONE_H
  32. #include "os/input.h"
  33. #include "drivers/unix/os_unix.h"
  34. #include "servers/visual_server.h"
  35. #include "servers/visual/rasterizer.h"
  36. #include "servers/physics/physics_server_sw.h"
  37. #include "servers/physics_2d/physics_2d_server_sw.h"
  38. #include "servers/audio/audio_server_sw.h"
  39. #include "servers/audio/sample_manager_sw.h"
  40. #include "servers/spatial_sound/spatial_sound_server_sw.h"
  41. #include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
  42. #include "game_center.h"
  43. #include "in_app_store.h"
  44. class AudioDriverIphone;
  45. class RasterizerGLES2;
  46. class OSIPhone : public OS_Unix {
  47. public:
  48. enum Orientations {
  49. PortraitDown,
  50. PortraitUp,
  51. LandscapeLeft,
  52. LandscapeRight,
  53. };
  54. private:
  55. enum {
  56. MAX_MOUSE_COUNT = 8,
  57. MAX_EVENTS = 64,
  58. };
  59. uint8_t supported_orientations;
  60. Rasterizer *rasterizer;
  61. RasterizerGLES2* rasterizer_gles22;
  62. VisualServer *visual_server;
  63. PhysicsServer* physics_server;
  64. Physics2DServer *physics_2d_server;
  65. AudioServerSW *audio_server;
  66. SampleManagerMallocSW *sample_manager;
  67. SpatialSoundServerSW *spatial_sound_server;
  68. SpatialSound2DServerSW *spatial_sound_2d_server;
  69. AudioDriverIphone* audio_driver;
  70. #ifdef GAME_CENTER_ENABLED
  71. GameCenter* game_center;
  72. #endif
  73. #ifdef STOREKIT_ENABLED
  74. InAppStore* store_kit;
  75. #endif
  76. MainLoop *main_loop;
  77. VideoMode video_mode;
  78. virtual int get_video_driver_count() const;
  79. virtual const char * get_video_driver_name(int p_driver) const;
  80. virtual VideoMode get_default_video_mode() const;
  81. virtual void initialize_core();
  82. virtual void initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver);
  83. virtual void set_main_loop( MainLoop * p_main_loop );
  84. virtual MainLoop *get_main_loop() const;
  85. virtual void delete_main_loop();
  86. virtual void finalize();
  87. struct MouseList {
  88. bool pressed[MAX_MOUSE_COUNT];
  89. MouseList() {
  90. for (int i=0; i<MAX_MOUSE_COUNT; i++)
  91. pressed[i] = false;
  92. };
  93. };
  94. MouseList mouse_list;
  95. Vector3 last_accel;
  96. InputEvent event_queue[MAX_EVENTS];
  97. int event_count;
  98. int last_event_id;
  99. void queue_event(const InputEvent& p_event);
  100. String data_dir;
  101. String unique_ID;
  102. String locale_code;
  103. InputDefault *input;
  104. public:
  105. bool iterate();
  106. uint8_t get_orientations() const;
  107. void mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick, bool p_use_as_mouse);
  108. void mouse_move(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y, bool p_use_as_mouse);
  109. void touches_cancelled();
  110. void key(uint32_t p_key, bool p_pressed);
  111. int set_base_framebuffer(int p_fb);
  112. void update_accelerometer(float p_x, float p_y, float p_z);
  113. static OSIPhone* get_singleton();
  114. virtual void set_mouse_show(bool p_show);
  115. virtual void set_mouse_grab(bool p_grab);
  116. virtual bool is_mouse_grab_enabled() const;
  117. virtual Point2 get_mouse_pos() const;
  118. virtual int get_mouse_button_state() const;
  119. virtual void set_window_title(const String& p_title);
  120. virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen=0);
  121. virtual VideoMode get_video_mode(int p_screen=0) const;
  122. virtual void get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const;
  123. virtual bool can_draw() const;
  124. virtual bool has_virtual_keyboard() const;
  125. virtual void show_virtual_keyboard(const String& p_existing_text,const Rect2& p_screen_rect=Rect2());
  126. virtual void hide_virtual_keyboard();
  127. virtual void set_cursor_shape(CursorShape p_shape);
  128. virtual Size2 get_window_size() const;
  129. virtual bool has_touchscreen_ui_hint() const;
  130. void set_data_dir(String p_dir);
  131. virtual String get_name();
  132. Error shell_open(String p_uri);
  133. String get_data_dir() const;
  134. void set_locale(String p_locale);
  135. String get_locale() const;
  136. void set_unique_ID(String p_ID);
  137. String get_unique_ID() const;
  138. virtual Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
  139. virtual bool native_video_is_playing() const;
  140. virtual void native_video_pause();
  141. virtual void native_video_unpause();
  142. virtual void native_video_focus_out();
  143. virtual void native_video_stop();
  144. OSIPhone(int width, int height);
  145. ~OSIPhone();
  146. };
  147. #endif // OS_IPHONE_H
  148. #endif