MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / warp_mouse_motion

Method warp_mouse_motion

core/input/input.cpp:1079–1093  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1077}
1078
1079Point2 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
1095void 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));

Callers 3

_sheet_scroll_inputMethod · 0.80

Calls 4

fmodFunction · 0.85
fposmodFunction · 0.85
get_relativeMethod · 0.80
get_global_positionMethod · 0.45

Tested by

no test coverage detected