os_unix.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*************************************************************************/
  2. /* os_unix.h */
  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. #ifndef OS_UNIX_H
  31. #define OS_UNIX_H
  32. /**
  33. @author Juan Linietsky <reduzio@gmail.com>
  34. */
  35. #ifdef UNIX_ENABLED
  36. #include "drivers/unix/ip_unix.h"
  37. #include "os/os.h"
  38. class OS_Unix : public OS {
  39. uint64_t ticks_start;
  40. protected:
  41. // UNIX only handles the core functions.
  42. // inheriting platforms under unix (eg. X11) should handle the rest
  43. //virtual int get_video_driver_count() const;
  44. //virtual const char * get_video_driver_name(int p_driver) const;
  45. //virtual VideoMode get_default_video_mode() const;
  46. virtual int get_audio_driver_count() const;
  47. virtual const char *get_audio_driver_name(int p_driver) const;
  48. virtual void initialize_logger();
  49. virtual void initialize_core();
  50. virtual int unix_initialize_audio(int p_audio_driver);
  51. //virtual void initialize(int p_video_driver,int p_audio_driver);
  52. virtual void finalize_core();
  53. String stdin_buf;
  54. String get_global_settings_path() const;
  55. public:
  56. virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
  57. virtual String get_stdin_string(bool p_block);
  58. //virtual void set_mouse_show(bool p_show);
  59. //virtual void set_mouse_grab(bool p_grab);
  60. //virtual bool is_mouse_grab_enabled() const = 0;
  61. //virtual void get_mouse_position(int &x, int &y) const;
  62. //virtual void set_window_title(const String& p_title);
  63. //virtual void set_video_mode(const VideoMode& p_video_mode);
  64. //virtual VideoMode get_video_mode() const;
  65. //virtual void get_fullscreen_mode_list(List<VideoMode> *p_list) const;
  66. virtual Error open_dynamic_library(const String p_path, void *&p_library_handle);
  67. virtual Error close_dynamic_library(void *p_library_handle);
  68. virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false);
  69. virtual Error set_cwd(const String &p_cwd);
  70. virtual String get_name();
  71. virtual Date get_date(bool utc) const;
  72. virtual Time get_time(bool utc) const;
  73. virtual TimeZoneInfo get_time_zone_info() const;
  74. virtual uint64_t get_unix_time() const;
  75. virtual uint64_t get_system_time_secs() const;
  76. virtual void delay_usec(uint32_t p_usec) const;
  77. virtual uint64_t get_ticks_usec() const;
  78. virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false);
  79. virtual Error kill(const ProcessID &p_pid);
  80. virtual int get_process_id() const;
  81. virtual bool has_environment(const String &p_var) const;
  82. virtual String get_environment(const String &p_var) const;
  83. virtual String get_locale() const;
  84. virtual int get_processor_count() const;
  85. virtual void debug_break();
  86. virtual String get_installed_templates_path() const;
  87. virtual String get_executable_path() const;
  88. virtual String get_data_dir() const;
  89. //virtual void run( MainLoop * p_main_loop );
  90. };
  91. class UnixTerminalLogger : public StdLogger {
  92. public:
  93. virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type = ERR_ERROR);
  94. virtual ~UnixTerminalLogger();
  95. };
  96. #endif
  97. #endif