| 1077 | } |
| 1078 | |
| 1079 | Point2 Input::warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect) { |
| 1080 | const Point2 rel_sign(p_motion->get_relative().x >= 0.0f ? 1 : -1, p_motion->get_relative().y >= 0.0 ? 1 : -1); |
| 1081 | const Size2 warp_margin = p_rect.size * 0.5f; |
| 1082 | const Point2 rel_warped( |
| 1083 | Math::fmod(p_motion->get_relative().x + rel_sign.x * warp_margin.x, p_rect.size.x) - rel_sign.x * warp_margin.x, |
| 1084 | Math::fmod(p_motion->get_relative().y + rel_sign.y * warp_margin.y, p_rect.size.y) - rel_sign.y * warp_margin.y); |
| 1085 | |
| 1086 | const Point2 pos_local = p_motion->get_global_position() - p_rect.position; |
| 1087 | const Point2 pos_warped(Math::fposmod(pos_local.x, p_rect.size.x), Math::fposmod(pos_local.y, p_rect.size.y)); |
| 1088 | if (pos_warped != pos_local) { |
| 1089 | warp_mouse(pos_warped + p_rect.position); |
| 1090 | } |
| 1091 | |
| 1092 | return rel_warped; |
| 1093 | } |
| 1094 | |
| 1095 | void Input::action_press(const StringName &p_action, float p_strength) { |
| 1096 | ERR_FAIL_COND_MSG(!InputMap::get_singleton()->has_action(p_action), InputMap::get_singleton()->suggest_actions(p_action)); |
no test coverage detected