diff options
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/input.cpp | 2 | ||||
-rw-r--r-- | core/os/input.h | 20 | ||||
-rw-r--r-- | core/os/input_event.cpp | 4 | ||||
-rw-r--r-- | core/os/os.cpp | 3 | ||||
-rw-r--r-- | core/os/os.h | 8 |
5 files changed, 28 insertions, 9 deletions
diff --git a/core/os/input.cpp b/core/os/input.cpp index 531db73838..401ab7ffe2 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -53,6 +53,8 @@ void Input::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_mouse_button_pressed","button"),&Input::is_mouse_button_pressed); ObjectTypeDB::bind_method(_MD("is_joy_button_pressed","device","button"),&Input::is_joy_button_pressed); ObjectTypeDB::bind_method(_MD("is_action_pressed","action"),&Input::is_action_pressed); + ObjectTypeDB::bind_method(_MD("is_action_just_pressed","action"),&Input::is_action_just_pressed); + ObjectTypeDB::bind_method(_MD("is_action_just_released","action"),&Input::is_action_just_released); ObjectTypeDB::bind_method(_MD("add_joy_mapping","mapping", "update_existing"),&Input::add_joy_mapping, DEFVAL(false)); ObjectTypeDB::bind_method(_MD("remove_joy_mapping","guid"),&Input::remove_joy_mapping); ObjectTypeDB::bind_method(_MD("is_joy_known","device"),&Input::is_joy_known); diff --git a/core/os/input.h b/core/os/input.h index 16bcc0ff9a..665fb4ad99 100644 --- a/core/os/input.h +++ b/core/os/input.h @@ -55,12 +55,14 @@ public: static Input *get_singleton(); - virtual bool is_key_pressed(int p_scancode)=0; - virtual bool is_mouse_button_pressed(int p_button)=0; - virtual bool is_joy_button_pressed(int p_device, int p_button)=0; - virtual bool is_action_pressed(const StringName& p_action)=0; - - virtual float get_joy_axis(int p_device,int p_axis)=0; + virtual bool is_key_pressed(int p_scancode) const=0; + virtual bool is_mouse_button_pressed(int p_button) const=0; + virtual bool is_joy_button_pressed(int p_device, int p_button) const=0; + virtual bool is_action_pressed(const StringName& p_action) const=0; + virtual bool is_action_just_pressed(const StringName& p_action) const=0; + virtual bool is_action_just_released(const StringName& p_action) const=0; + + virtual float get_joy_axis(int p_device,int p_axis) const=0; virtual String get_joy_name(int p_idx)=0; virtual Array get_connected_joysticks()=0; virtual void joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid)=0; @@ -80,9 +82,9 @@ public: virtual void warp_mouse_pos(const Vector2& p_to)=0; - virtual Vector3 get_accelerometer()=0; - virtual Vector3 get_magnetometer()=0; - virtual Vector3 get_gyroscope()=0; + virtual Vector3 get_accelerometer() const=0; + virtual Vector3 get_magnetometer() const=0; + virtual Vector3 get_gyroscope() const=0; virtual void action_press(const StringName& p_action)=0; virtual void action_release(const StringName& p_action)=0; diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index f4a6de0e96..9d920724e1 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) { + case NONE: + return true; case KEY: return key.unicode == p_event.key.unicode && key.scancode == p_event.key.scancode @@ -77,6 +79,8 @@ bool InputEvent::operator==(const InputEvent &p_event) const { case ACTION: return action.action == p_event.action.action && action.pressed == p_event.action.pressed; + default: + ERR_PRINT("No logic to compare InputEvents of this type, this shouldn't happen."); } return false; diff --git a/core/os/os.cpp b/core/os/os.cpp index 5f86962048..ee32476234 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -587,6 +587,9 @@ OS::OS() { _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 2521d67e29..8e9293b3c8 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -62,6 +62,10 @@ class OS { bool _pixel_snap; bool _allow_hidpi; + uint64_t _fixed_frames; + uint64_t _idle_frames; + bool _in_fixed; + char *last_error; public: @@ -282,6 +286,10 @@ public: 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 { |