diff options
Diffstat (limited to 'core/os')
| -rw-r--r-- | core/os/dir_access.cpp | 2 | ||||
| -rw-r--r-- | core/os/dir_access.h | 2 | ||||
| -rw-r--r-- | core/os/file_access.cpp | 2 | ||||
| -rw-r--r-- | core/os/input.cpp | 72 | ||||
| -rw-r--r-- | core/os/input.h | 6 | ||||
| -rw-r--r-- | core/os/input_event.cpp | 3 | ||||
| -rw-r--r-- | core/os/keyboard.cpp | 7 | ||||
| -rw-r--r-- | core/os/main_loop.cpp | 12 | ||||
| -rw-r--r-- | core/os/memory.h | 4 | ||||
| -rw-r--r-- | core/os/mutex.cpp | 2 | ||||
| -rw-r--r-- | core/os/os.cpp | 82 | ||||
| -rw-r--r-- | core/os/os.h | 39 |
12 files changed, 74 insertions, 159 deletions
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index 804fe15c39..974225a3e8 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -30,7 +30,7 @@ #include "os/file_access.h" #include "os/memory.h" #include "os/os.h" -#include "globals.h" +#include "global_config.h" String DirAccess::_get_root_path() const { diff --git a/core/os/dir_access.h b/core/os/dir_access.h index f824b5f319..7c173fc780 100644 --- a/core/os/dir_access.h +++ b/core/os/dir_access.h @@ -72,7 +72,7 @@ protected: public: - virtual bool list_dir_begin()=0; ///< This starts dir listing + virtual Error list_dir_begin()=0; ///< This starts dir listing virtual String get_next(bool* p_is_dir); // compatibility virtual String get_next()=0; virtual bool current_is_dir() const=0; diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index 06723c5131..ae592720e8 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "file_access.h" -#include "globals.h" +#include "global_config.h" #include "os/os.h" #include "core/io/marshalls.h" #include "io/md5.h" diff --git a/core/os/input.cpp b/core/os/input.cpp index d2bd433ed9..34883e63ba 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -29,7 +29,7 @@ #include "input.h" #include "input_map.h" #include "os/os.h" -#include "globals.h" +#include "global_config.h" Input *Input::singleton=NULL; Input *Input::get_singleton() { @@ -38,7 +38,7 @@ Input *Input::get_singleton() { } void Input::set_mouse_mode(MouseMode p_mode) { - ERR_FAIL_INDEX(p_mode,3); + ERR_FAIL_INDEX(p_mode,4); OS::get_singleton()->set_mouse_mode((OS::MouseMode)p_mode); } @@ -49,43 +49,45 @@ Input::MouseMode Input::get_mouse_mode() const { void Input::_bind_methods() { - ClassDB::bind_method(_MD("is_key_pressed","scancode"),&Input::is_key_pressed); - ClassDB::bind_method(_MD("is_mouse_button_pressed","button"),&Input::is_mouse_button_pressed); - ClassDB::bind_method(_MD("is_joy_button_pressed","device","button"),&Input::is_joy_button_pressed); - ClassDB::bind_method(_MD("is_action_pressed","action"),&Input::is_action_pressed); - ClassDB::bind_method(_MD("is_action_just_pressed","action"),&Input::is_action_just_pressed); - ClassDB::bind_method(_MD("is_action_just_released","action"),&Input::is_action_just_released); - ClassDB::bind_method(_MD("add_joy_mapping","mapping", "update_existing"),&Input::add_joy_mapping, DEFVAL(false)); - ClassDB::bind_method(_MD("remove_joy_mapping","guid"),&Input::remove_joy_mapping); - ClassDB::bind_method(_MD("is_joy_known","device"),&Input::is_joy_known); - ClassDB::bind_method(_MD("get_joy_axis","device","axis"),&Input::get_joy_axis); - ClassDB::bind_method(_MD("get_joy_name","device"),&Input::get_joy_name); - ClassDB::bind_method(_MD("get_joy_guid","device"),&Input::get_joy_guid); - ClassDB::bind_method(_MD("get_connected_joypads"),&Input::get_connected_joypads); - ClassDB::bind_method(_MD("get_joy_vibration_strength", "device"), &Input::get_joy_vibration_strength); - ClassDB::bind_method(_MD("get_joy_vibration_duration", "device"), &Input::get_joy_vibration_duration); - ClassDB::bind_method(_MD("get_joy_button_string", "button_index"), &Input::get_joy_button_string); - ClassDB::bind_method(_MD("get_joy_button_index_from_string", "button"), &Input::get_joy_button_index_from_string); - ClassDB::bind_method(_MD("get_joy_axis_string", "axis_index"), &Input::get_joy_axis_string); - ClassDB::bind_method(_MD("get_joy_axis_index_from_string", "axis"), &Input::get_joy_axis_index_from_string); - ClassDB::bind_method(_MD("start_joy_vibration", "device", "weak_magnitude", "strong_magnitude", "duration"), &Input::start_joy_vibration, DEFVAL(0)); - ClassDB::bind_method(_MD("stop_joy_vibration", "device"), &Input::stop_joy_vibration); - ClassDB::bind_method(_MD("get_accelerometer"),&Input::get_accelerometer); - ClassDB::bind_method(_MD("get_magnetometer"),&Input::get_magnetometer); - ClassDB::bind_method(_MD("get_gyroscope"),&Input::get_gyroscope); - //ClassDB::bind_method(_MD("get_mouse_pos"),&Input::get_mouse_pos); - this is not the function you want - ClassDB::bind_method(_MD("get_mouse_speed"),&Input::get_mouse_speed); - ClassDB::bind_method(_MD("get_mouse_button_mask"),&Input::get_mouse_button_mask); - ClassDB::bind_method(_MD("set_mouse_mode","mode"),&Input::set_mouse_mode); - ClassDB::bind_method(_MD("get_mouse_mode"),&Input::get_mouse_mode); - ClassDB::bind_method(_MD("warp_mouse_pos","to"),&Input::warp_mouse_pos); - ClassDB::bind_method(_MD("action_press","action"),&Input::action_press); - ClassDB::bind_method(_MD("action_release","action"),&Input::action_release); - ClassDB::bind_method(_MD("set_custom_mouse_cursor","image:Texture","hotspot"),&Input::set_custom_mouse_cursor,DEFVAL(Vector2())); + ClassDB::bind_method(D_METHOD("is_key_pressed","scancode"),&Input::is_key_pressed); + ClassDB::bind_method(D_METHOD("is_mouse_button_pressed","button"),&Input::is_mouse_button_pressed); + ClassDB::bind_method(D_METHOD("is_joy_button_pressed","device","button"),&Input::is_joy_button_pressed); + ClassDB::bind_method(D_METHOD("is_action_pressed","action"),&Input::is_action_pressed); + ClassDB::bind_method(D_METHOD("is_action_just_pressed","action"),&Input::is_action_just_pressed); + ClassDB::bind_method(D_METHOD("is_action_just_released","action"),&Input::is_action_just_released); + ClassDB::bind_method(D_METHOD("add_joy_mapping","mapping", "update_existing"),&Input::add_joy_mapping, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("remove_joy_mapping","guid"),&Input::remove_joy_mapping); + ClassDB::bind_method(D_METHOD("is_joy_known","device"),&Input::is_joy_known); + ClassDB::bind_method(D_METHOD("get_joy_axis","device","axis"),&Input::get_joy_axis); + ClassDB::bind_method(D_METHOD("get_joy_name","device"),&Input::get_joy_name); + ClassDB::bind_method(D_METHOD("get_joy_guid","device"),&Input::get_joy_guid); + ClassDB::bind_method(D_METHOD("get_connected_joypads"),&Input::get_connected_joypads); + ClassDB::bind_method(D_METHOD("get_joy_vibration_strength", "device"), &Input::get_joy_vibration_strength); + ClassDB::bind_method(D_METHOD("get_joy_vibration_duration", "device"), &Input::get_joy_vibration_duration); + ClassDB::bind_method(D_METHOD("get_joy_button_string", "button_index"), &Input::get_joy_button_string); + ClassDB::bind_method(D_METHOD("get_joy_button_index_from_string", "button"), &Input::get_joy_button_index_from_string); + ClassDB::bind_method(D_METHOD("get_joy_axis_string", "axis_index"), &Input::get_joy_axis_string); + ClassDB::bind_method(D_METHOD("get_joy_axis_index_from_string", "axis"), &Input::get_joy_axis_index_from_string); + ClassDB::bind_method(D_METHOD("start_joy_vibration", "device", "weak_magnitude", "strong_magnitude", "duration"), &Input::start_joy_vibration, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("stop_joy_vibration", "device"), &Input::stop_joy_vibration); + ClassDB::bind_method(D_METHOD("get_gravity"),&Input::get_gravity); + ClassDB::bind_method(D_METHOD("get_accelerometer"),&Input::get_accelerometer); + ClassDB::bind_method(D_METHOD("get_magnetometer"),&Input::get_magnetometer); + ClassDB::bind_method(D_METHOD("get_gyroscope"),&Input::get_gyroscope); + //ClassDB::bind_method(D_METHOD("get_mouse_pos"),&Input::get_mouse_pos); - this is not the function you want + ClassDB::bind_method(D_METHOD("get_last_mouse_speed"),&Input::get_last_mouse_speed); + ClassDB::bind_method(D_METHOD("get_mouse_button_mask"),&Input::get_mouse_button_mask); + ClassDB::bind_method(D_METHOD("set_mouse_mode","mode"),&Input::set_mouse_mode); + ClassDB::bind_method(D_METHOD("get_mouse_mode"),&Input::get_mouse_mode); + ClassDB::bind_method(D_METHOD("warp_mouse_pos","to"),&Input::warp_mouse_pos); + ClassDB::bind_method(D_METHOD("action_press","action"),&Input::action_press); + ClassDB::bind_method(D_METHOD("action_release","action"),&Input::action_release); + ClassDB::bind_method(D_METHOD("set_custom_mouse_cursor","image:Texture","hotspot"),&Input::set_custom_mouse_cursor,DEFVAL(Vector2())); BIND_CONSTANT( MOUSE_MODE_VISIBLE ); BIND_CONSTANT( MOUSE_MODE_HIDDEN ); BIND_CONSTANT( MOUSE_MODE_CAPTURED ); + BIND_CONSTANT( MOUSE_MODE_CONFINED ); ADD_SIGNAL( MethodInfo("joy_connection_changed", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::BOOL, "connected")) ); } diff --git a/core/os/input.h b/core/os/input.h index c365894f46..2cea154a50 100644 --- a/core/os/input.h +++ b/core/os/input.h @@ -47,7 +47,8 @@ public: enum MouseMode { MOUSE_MODE_VISIBLE, MOUSE_MODE_HIDDEN, - MOUSE_MODE_CAPTURED + MOUSE_MODE_CAPTURED, + MOUSE_MODE_CONFINED }; void set_mouse_mode(MouseMode p_mode); @@ -77,11 +78,12 @@ public: virtual void stop_joy_vibration(int p_device)=0; virtual Point2 get_mouse_pos() const=0; - virtual Point2 get_mouse_speed() const=0; + virtual Point2 get_last_mouse_speed() const=0; virtual int get_mouse_button_mask() const=0; virtual void warp_mouse_pos(const Vector2& p_to)=0; + virtual Vector3 get_gravity() const=0; virtual Vector3 get_accelerometer() const=0; virtual Vector3 get_magnetometer() const=0; virtual Vector3 get_gyroscope() const=0; diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index 3cc595208f..4ef99558ad 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -39,6 +39,8 @@ bool InputEvent::operator==(const InputEvent &p_event) const { } switch(type) { + /** Current clang-format style doesn't play well with the aligned return values of that switch. */ + /* clang-format off */ case NONE: return true; case KEY: @@ -80,6 +82,7 @@ bool InputEvent::operator==(const InputEvent &p_event) const { case ACTION: return action.action == p_event.action.action && action.pressed == p_event.action.pressed; + /* clang-format on */ default: ERR_PRINT("No logic to compare InputEvents of this type, this shouldn't happen."); } diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp index 309348ea31..40fa86d09f 100644 --- a/core/os/keyboard.cpp +++ b/core/os/keyboard.cpp @@ -36,6 +36,7 @@ struct _KeyCodeText { static const _KeyCodeText _keycodes[]={ + /* clang-format off */ {KEY_ESCAPE ,"Escape"}, {KEY_TAB ,"Tab"}, {KEY_BACKTAB ,"BackTab"}, @@ -281,7 +282,8 @@ static const _KeyCodeText _keycodes[]={ {KEY_DIVISION ,"Division"}, {KEY_YDIAERESIS ,"Ydiaeresis"}, - {0 ,0} + {0 ,0} + /* clang-format on */ }; bool keycode_has_unicode(uint32_t p_keycode) { @@ -299,7 +301,8 @@ bool keycode_has_unicode(uint32_t p_keycode) { case KEY_MEDIAPREVIOUS: case KEY_MEDIANEXT: case KEY_MEDIARECORD: case KEY_HOMEPAGE: case KEY_FAVORITES: case KEY_SEARCH: case KEY_STANDBY: case KEY_OPENURL: case KEY_LAUNCHMAIL: case KEY_LAUNCHMEDIA: case KEY_LAUNCH0: case KEY_LAUNCH1: case KEY_LAUNCH2: case KEY_LAUNCH3: case KEY_LAUNCH4: case KEY_LAUNCH5: case KEY_LAUNCH6: case KEY_LAUNCH7: case KEY_LAUNCH8: case KEY_LAUNCH9: case KEY_LAUNCHA: case KEY_LAUNCHB: case KEY_LAUNCHC: case KEY_LAUNCHD: - case KEY_LAUNCHE: case KEY_LAUNCHF: return false; + case KEY_LAUNCHE: case KEY_LAUNCHF: + return false; } return true; diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp index 11396666d2..dcda8e8952 100644 --- a/core/os/main_loop.cpp +++ b/core/os/main_loop.cpp @@ -31,12 +31,12 @@ void MainLoop::_bind_methods() { - ClassDB::bind_method(_MD("input_event","ev"),&MainLoop::input_event); - ClassDB::bind_method(_MD("input_text","text"),&MainLoop::input_text); - ClassDB::bind_method(_MD("init"),&MainLoop::init); - ClassDB::bind_method(_MD("iteration","delta"),&MainLoop::iteration); - ClassDB::bind_method(_MD("idle","delta"),&MainLoop::idle); - ClassDB::bind_method(_MD("finish"),&MainLoop::finish); + ClassDB::bind_method(D_METHOD("input_event","ev"),&MainLoop::input_event); + ClassDB::bind_method(D_METHOD("input_text","text"),&MainLoop::input_text); + ClassDB::bind_method(D_METHOD("init"),&MainLoop::init); + ClassDB::bind_method(D_METHOD("iteration","delta"),&MainLoop::iteration); + ClassDB::bind_method(D_METHOD("idle","delta"),&MainLoop::idle); + ClassDB::bind_method(D_METHOD("finish"),&MainLoop::finish); BIND_VMETHOD( MethodInfo("_input_event",PropertyInfo(Variant::INPUT_EVENT,"ev")) ); BIND_VMETHOD( MethodInfo("_input_text",PropertyInfo(Variant::STRING,"text")) ); diff --git a/core/os/memory.h b/core/os/memory.h index 0e6dea48d3..49424037ff 100644 --- a/core/os/memory.h +++ b/core/os/memory.h @@ -97,8 +97,8 @@ _ALWAYS_INLINE_ T *_post_initialize(T *p_obj) { #define memnew(m_class) _post_initialize(new("") m_class) _ALWAYS_INLINE_ void * operator new(size_t p_size,void *p_pointer,size_t check, const char *p_description) { -// void *failptr=0; -// ERR_FAIL_COND_V( check < p_size , failptr); /** bug, or strange compiler, most likely */ + //void *failptr=0; + //ERR_FAIL_COND_V( check < p_size , failptr); /** bug, or strange compiler, most likely */ return p_pointer; } diff --git a/core/os/mutex.cpp b/core/os/mutex.cpp index f5f7f757c3..acdcb492d9 100644 --- a/core/os/mutex.cpp +++ b/core/os/mutex.cpp @@ -47,7 +47,7 @@ Mutex::~Mutex() { } -Mutex *_global_mutex=NULL;; +Mutex *_global_mutex=NULL; void _global_lock() { diff --git a/core/os/os.cpp b/core/os/os.cpp index 677bf63e69..912f7f0b0f 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -27,13 +27,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "os.h" -#include "os/file_access.h" -#include <stdarg.h> + #include "dir_access.h" -#include "globals.h" +#include "global_config.h" #include "input.h" -// For get_engine_version, could be removed if it's moved to a new Engine singleton -#include "version.h" +#include "os/file_access.h" + +#include <stdarg.h> OS* OS::singleton=NULL; @@ -98,23 +98,6 @@ void OS::printerr(const char* p_format, ...) { }; -void OS::set_iterations_per_second(int p_ips) { - - ips=p_ips; -} -int OS::get_iterations_per_second() const { - - return ips; -} - -void OS::set_target_fps(int p_fps) { - _target_fps=p_fps>0? p_fps : 0; -} - -float OS::get_target_fps() const { - return _target_fps; -} - void OS::set_keep_screen_on(bool p_enabled) { _keep_screen_on=p_enabled; } @@ -152,10 +135,6 @@ int OS::get_process_ID() const { return -1; }; -uint64_t OS::get_frames_drawn() { - - return frames_drawn; -} bool OS::is_stdout_verbose() const { @@ -187,7 +166,7 @@ const char *OS::get_last_error() const { void OS::dump_memory_to_file(const char* p_file) { -// Memory::dump_static_mem_to_file(p_file); + //Memory::dump_static_mem_to_file(p_file); } static FileAccess *_OSPRF=NULL; @@ -261,15 +240,7 @@ void OS::clear_last_error() { memfree(last_error); last_error=NULL; } -void OS::set_frame_delay(uint32_t p_msec) { - _frame_delay=p_msec; -} - -uint32_t OS::get_frame_delay() const { - - return _frame_delay; -} void OS::set_no_window_mode(bool p_enable) { @@ -513,20 +484,13 @@ OS::MouseMode OS::get_mouse_mode() const{ return MOUSE_MODE_VISIBLE; } -void OS::set_time_scale(float p_scale) { - - _time_scale=p_scale; -} OS::LatinKeyboardVariant OS::get_latin_keyboard_variant() const { return LATIN_KEYBOARD_QWERTY; } -float OS::get_time_scale() const { - return _time_scale; -} bool OS::is_joy_known(int p_device) { return true; @@ -548,49 +512,21 @@ bool OS::is_vsync_enabled() const{ return true; } -Dictionary OS::get_engine_version() const { - - Dictionary dict; - dict["major"] = _MKSTR(VERSION_MAJOR); - dict["minor"] = _MKSTR(VERSION_MINOR); -#ifdef VERSION_PATCH - dict["patch"] = _MKSTR(VERSION_PATCH); -#else - dict["patch"] = ""; -#endif - dict["status"] = _MKSTR(VERSION_STATUS); - dict["revision"] = _MKSTR(VERSION_REVISION); - - String stringver = String(dict["major"]) + "." + String(dict["minor"]); - if (dict["patch"] != "") - stringver += "." + String(dict["patch"]); - stringver += "-" + String(dict["status"]) + " (" + String(dict["revision"]) + ")"; - dict["string"] = stringver; - - return dict; -} OS::OS() { last_error=NULL; - frames_drawn=0; singleton=this; - ips=60; _keep_screen_on=true; // set default value to true, because this had been true before godot 2.0. low_processor_usage_mode=false; _verbose_stdout=false; - _frame_delay=0; _no_window=false; _exit_code=0; _orientation=SCREEN_LANDSCAPE; - _fps=1; - _target_fps=0; + _render_thread_mode=RENDER_THREAD_SAFE; - _time_scale=1.0; - _pixel_snap=false; + + _allow_hidpi=true; - _fixed_frames=0; - _idle_frames=0; - _in_fixed=false; Math::seed(1234567); } diff --git a/core/os/os.h b/core/os/os.h index 5ea3216f24..e179b82dae 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -32,6 +32,7 @@ #include "ustring.h" #include "list.h" #include "vector.h" +#include "engine.h" #include "os/main_loop.h" #include <stdarg.h> @@ -43,28 +44,17 @@ class OS { static OS* singleton; String _execpath; - String _custom_level; List<String> _cmdline; - int ips; bool _keep_screen_on; bool low_processor_usage_mode; bool _verbose_stdout; String _local_clipboard; - uint64_t frames_drawn; - uint32_t _frame_delay; uint64_t _msec_splash; bool _no_window; int _exit_code; int _orientation; - float _fps; - int _target_fps; - float _time_scale; - bool _pixel_snap; bool _allow_hidpi; - uint64_t _fixed_frames; - uint64_t _idle_frames; - bool _in_fixed; char *last_error; @@ -141,7 +131,8 @@ public: enum MouseMode { MOUSE_MODE_VISIBLE, MOUSE_MODE_HIDDEN, - MOUSE_MODE_CAPTURED + MOUSE_MODE_CAPTURED, + MOUSE_MODE_CONFINED }; virtual void set_mouse_mode(MouseMode p_mode); @@ -185,15 +176,6 @@ public: virtual bool get_borderless_window() { return 0; } - - virtual void set_iterations_per_second(int p_ips); - virtual int get_iterations_per_second() const; - - virtual void set_target_fps(int p_fps); - virtual float get_target_fps() const; - - virtual float get_frames_per_second() const { return _fps; } - virtual void set_keep_screen_on(bool p_enabled); virtual bool is_keep_screen_on() const; virtual void set_low_processor_usage_mode(bool p_enabled); @@ -217,7 +199,6 @@ public: virtual MainLoop *get_main_loop() const=0; - String get_custom_level() const { return _custom_level; } virtual void yield(); @@ -280,17 +261,9 @@ public: uint32_t get_ticks_msec() const; uint64_t get_splash_tick_msec() const; - void set_frame_delay(uint32_t p_msec); - uint32_t get_frame_delay() const; virtual bool can_draw() const = 0; - uint64_t get_frames_drawn(); - - uint64_t get_fixed_frames() const { return _fixed_frames; } - uint64_t get_idle_frames() const { return _idle_frames; } - bool is_in_fixed_frame() const { return _in_fixed; } - bool is_stdout_verbose() const; enum CursorShape { @@ -416,10 +389,6 @@ public: virtual LatinKeyboardVariant get_latin_keyboard_variant() const; - void set_time_scale(float p_scale); - float get_time_scale() const; - - _FORCE_INLINE_ bool get_use_pixel_snap() const { return _pixel_snap; } virtual bool is_joy_known(int p_device); virtual String get_joy_guid(int p_device)const; @@ -434,7 +403,7 @@ public: virtual void set_use_vsync(bool p_enable); virtual bool is_vsync_enabled() const; - Dictionary get_engine_version() const; + virtual bool check_feature_support(const String& p_feature)=0; bool is_hidpi_allowed() const { return _allow_hidpi; } OS(); |