diff options
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/input.h | 3 | ||||
-rw-r--r-- | core/os/input_event.cpp | 8 | ||||
-rw-r--r-- | core/os/os.cpp | 2 | ||||
-rw-r--r-- | core/os/os.h | 1 |
4 files changed, 9 insertions, 5 deletions
diff --git a/core/os/input.h b/core/os/input.h index 027147b987..001871c5dc 100644 --- a/core/os/input.h +++ b/core/os/input.h @@ -118,7 +118,8 @@ public: void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; - virtual bool is_emulating_touchscreen() const = 0; + virtual bool is_emulating_touch_from_mouse() const = 0; + virtual bool is_emulating_mouse_from_touch() const = 0; virtual CursorShape get_default_cursor_shape() = 0; virtual void set_default_cursor_shape(CursorShape p_shape) = 0; diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index 5003be77ab..4ebb821a2f 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -656,12 +656,14 @@ bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event, bool * if (jm.is_null()) return false; - bool match = (axis == jm->axis && (((axis_value < 0) == (jm->axis_value < 0)) || jm->axis_value == 0)); + bool match = (axis == jm->axis); // Matches even if not in the same direction, but returns a "not pressed" event. if (match) { + bool same_direction = (((axis_value < 0) == (jm->axis_value < 0)) || jm->axis_value == 0); + bool pressed = same_direction ? Math::abs(jm->get_axis_value()) >= p_deadzone : false; if (p_pressed != NULL) - *p_pressed = Math::abs(jm->get_axis_value()) >= p_deadzone; + *p_pressed = pressed; if (p_strength != NULL) - *p_strength = (*p_pressed) ? Math::inverse_lerp(p_deadzone, 1.0f, Math::abs(jm->get_axis_value())) : 0.0f; + *p_strength = pressed ? CLAMP(Math::inverse_lerp(p_deadzone, 1.0f, Math::abs(jm->get_axis_value())), 0.0f, 1.0f) : 0.0f; } return match; } diff --git a/core/os/os.cpp b/core/os/os.cpp index 618a4bbac3..854d554b10 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -411,7 +411,7 @@ Error OS::set_cwd(const String &p_cwd) { bool OS::has_touchscreen_ui_hint() const { //return false; - return Input::get_singleton() && Input::get_singleton()->is_emulating_touchscreen(); + return Input::get_singleton() && Input::get_singleton()->is_emulating_touch_from_mouse(); } int OS::get_free_static_memory() const { diff --git a/core/os/os.h b/core/os/os.h index 943c0498f1..f6404468b1 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -320,6 +320,7 @@ public: virtual void disable_crash_handler() {} virtual bool is_disable_crash_handler() const { return false; } + virtual void initialize_debugging() {} enum CursorShape { CURSOR_ARROW, |