From 778d70c0010cd5a6408bd3a813cb9546dc9fa0a9 Mon Sep 17 00:00:00 2001 From: lucasmerlin Date: Sat, 12 Aug 2023 14:22:22 +0200 Subject: [PATCH] Fix touch force for Apple Pencil --- CHANGELOG.md | 1 + src/platform_impl/ios/view.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16c00a27..429d09a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ And please only add new entries to the top of this list, right below the `# Unre - Added `AboutToWait` event which is emitted when the event loop is about to block and wait for new events ([#2900](https://github.com/rust-windowing/winit/issues/2900)) - **Breaking:** `with_x11_visual` now takes the visual ID instead of the bare pointer. - On X11, add a `with_embedded_parent_window` function to the window builder to allow embedding a window into another window. +- On iOS, add force data to touch events when using the Apple Pencil. # 0.29.0-beta.0 diff --git a/src/platform_impl/ios/view.rs b/src/platform_impl/ios/view.rs index b097d216..ce66483d 100644 --- a/src/platform_impl/ios/view.rs +++ b/src/platform_impl/ios/view.rs @@ -201,7 +201,9 @@ impl WinitView { let trait_collection = unsafe { self.traitCollection() }; let touch_capability = trait_collection.forceTouchCapability(); // Both the OS _and_ the device need to be checked for force touch support. - if touch_capability == UIForceTouchCapability::Available { + if touch_capability == UIForceTouchCapability::Available + || touch_type == UITouchType::Pencil + { let force = touch.force(); let max_possible_force = touch.maximumPossibleForce(); let altitude_angle: Option = if touch_type == UITouchType::Pencil {