diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/ios/display_server_ios.h | 4 | ||||
-rw-r--r-- | platform/ios/display_server_ios.mm | 4 | ||||
-rw-r--r-- | platform/ios/godot_view.mm | 4 |
3 files changed, 8 insertions, 4 deletions
diff --git a/platform/ios/display_server_ios.h b/platform/ios/display_server_ios.h index 0ca0d3d1fe..82351a536b 100644 --- a/platform/ios/display_server_ios.h +++ b/platform/ios/display_server_ios.h @@ -105,10 +105,10 @@ public: // MARK: - Input - // MARK: Touches + // MARK: Touches and Apple Pencil void touch_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_double_click); - void touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y); + void touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y, float p_pressure, Vector2 p_tilt); void touches_cancelled(int p_idx); // MARK: Keyboard diff --git a/platform/ios/display_server_ios.mm b/platform/ios/display_server_ios.mm index ce78b8d20f..789364494d 100644 --- a/platform/ios/display_server_ios.mm +++ b/platform/ios/display_server_ios.mm @@ -237,10 +237,12 @@ void DisplayServerIOS::touch_press(int p_idx, int p_x, int p_y, bool p_pressed, perform_event(ev); } -void DisplayServerIOS::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y) { +void DisplayServerIOS::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y, float p_pressure, Vector2 p_tilt) { Ref<InputEventScreenDrag> ev; ev.instantiate(); ev->set_index(p_idx); + ev->set_pressure(p_pressure); + ev->set_tilt(p_tilt); ev->set_position(Vector2(p_x, p_y)); ev->set_relative(Vector2(p_x - p_prev_x, p_y - p_prev_y)); perform_event(ev); diff --git a/platform/ios/godot_view.mm b/platform/ios/godot_view.mm index 19cb914521..5aff75ea04 100644 --- a/platform/ios/godot_view.mm +++ b/platform/ios/godot_view.mm @@ -363,7 +363,9 @@ static const float earth_gravity = 9.80665; ERR_FAIL_COND(tid == -1); CGPoint touchPoint = [touch locationInView:self]; CGPoint prev_point = [touch previousLocationInView:self]; - DisplayServerIOS::get_singleton()->touch_drag(tid, prev_point.x * self.contentScaleFactor, prev_point.y * self.contentScaleFactor, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor); + CGFloat alt = [touch altitudeAngle]; + CGVector azim = [touch azimuthUnitVectorInView:self]; + DisplayServerIOS::get_singleton()->touch_drag(tid, prev_point.x * self.contentScaleFactor, prev_point.y * self.contentScaleFactor, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, [touch force] / [touch maximumPossibleForce], Vector2(azim.dx, azim.dy) * Math::cos(alt)); } } } |