summaryrefslogtreecommitdiff
path: root/core/input
diff options
context:
space:
mode:
Diffstat (limited to 'core/input')
-rw-r--r--core/input/input.cpp10
-rw-r--r--core/input/input.h4
-rw-r--r--core/input/input_event.cpp14
3 files changed, 19 insertions, 9 deletions
diff --git a/core/input/input.cpp b/core/input/input.cpp
index 656bb92203..e64b5a3ab7 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -72,7 +72,7 @@ Input *Input::singleton = nullptr;
void (*Input::set_mouse_mode_func)(Input::MouseMode) = nullptr;
Input::MouseMode (*Input::get_mouse_mode_func)() = nullptr;
-void (*Input::warp_mouse_func)(const Vector2 &p_to_pos) = nullptr;
+void (*Input::warp_mouse_func)(const Vector2 &p_position) = nullptr;
Input::CursorShape (*Input::get_current_cursor_shape_func)() = nullptr;
void (*Input::set_custom_mouse_cursor_func)(const RES &, Input::CursorShape, const Vector2 &) = nullptr;
@@ -126,7 +126,7 @@ void Input::_bind_methods() {
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_position", "to"), &Input::warp_mouse_position);
+ ClassDB::bind_method(D_METHOD("warp_mouse", "position"), &Input::warp_mouse);
ClassDB::bind_method(D_METHOD("action_press", "action", "strength"), &Input::action_press, DEFVAL(1.f));
ClassDB::bind_method(D_METHOD("action_release", "action"), &Input::action_release);
ClassDB::bind_method(D_METHOD("set_default_cursor_shape", "shape"), &Input::set_default_cursor_shape, DEFVAL(CURSOR_ARROW));
@@ -733,8 +733,8 @@ MouseButton Input::get_mouse_button_mask() const {
return mouse_button_mask; // do not trust OS implementation, should remove it - OS::get_singleton()->get_mouse_button_state();
}
-void Input::warp_mouse_position(const Vector2 &p_to) {
- warp_mouse_func(p_to);
+void Input::warp_mouse(const Vector2 &p_position) {
+ warp_mouse_func(p_position);
}
Point2i Input::warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect) {
@@ -756,7 +756,7 @@ Point2i Input::warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, con
const Point2i pos_local = p_motion->get_global_position() - p_rect.position;
const Point2i pos_warped(Math::fposmod(pos_local.x, p_rect.size.x), Math::fposmod(pos_local.y, p_rect.size.y));
if (pos_warped != pos_local) {
- warp_mouse_position(pos_warped + p_rect.position);
+ warp_mouse(pos_warped + p_rect.position);
}
return rel_warped;
diff --git a/core/input/input.h b/core/input/input.h
index ab2cd377f4..ac688b53b8 100644
--- a/core/input/input.h
+++ b/core/input/input.h
@@ -216,7 +216,7 @@ private:
static void (*set_mouse_mode_func)(MouseMode);
static MouseMode (*get_mouse_mode_func)();
- static void (*warp_mouse_func)(const Vector2 &p_to_pos);
+ static void (*warp_mouse_func)(const Vector2 &p_position);
static CursorShape (*get_current_cursor_shape_func)();
static void (*set_custom_mouse_cursor_func)(const RES &, CursorShape, const Vector2 &);
@@ -273,7 +273,7 @@ public:
Vector2 get_last_mouse_velocity();
MouseButton get_mouse_button_mask() const;
- void warp_mouse_position(const Vector2 &p_to);
+ void warp_mouse(const Vector2 &p_position);
Point2i warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect);
void parse_input_event(const Ref<InputEvent> &p_event);
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index ab0f36132f..52c7c69315 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -424,8 +424,13 @@ bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool p_exact_ma
} else {
match = get_physical_keycode() == key->get_physical_keycode();
}
+ Key action_mask = get_modifiers_mask();
+ Key key_mask = key->get_modifiers_mask();
+ if (key->is_pressed()) {
+ match &= (action_mask & key_mask) == action_mask;
+ }
if (p_exact_match) {
- match &= get_modifiers_mask() == key->get_modifiers_mask();
+ match &= action_mask == key_mask;
}
if (match) {
bool pressed = key->is_pressed();
@@ -589,8 +594,13 @@ bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event, bool p_
}
bool match = button_index == mb->button_index;
+ Key action_mask = get_modifiers_mask();
+ Key button_mask = mb->get_modifiers_mask();
+ if (mb->is_pressed()) {
+ match &= (action_mask & button_mask) == action_mask;
+ }
if (p_exact_match) {
- match &= get_modifiers_mask() == mb->get_modifiers_mask();
+ match &= action_mask == button_mask;
}
if (match) {
bool pressed = mb->is_pressed();