Skip to content

Conversation

@ej-sanmartin
Copy link

@ej-sanmartin ej-sanmartin commented Nov 18, 2025

Fixes #1904

Changes

  • Pass seconds duration field from vibrate calls to void vibrate() method in /src/common/ios.mm that was previously being ignored.
  • Implemented duration based vibrate() iOS method using iOS 13+ CHHapticEngine.

Tested

  • Built successfully locally with the following command:
xcodebuild -project platform/xcode/love.xcodeproj \
  -scheme love-ios \
  -configuration Debug \
  -sdk iphonesimulator \
  -destination 'platform=iOS Simulator,name=iPhone 17' \
  clean build

@slime73
Copy link
Member

slime73 commented Nov 22, 2025

Built successfully locally with the following command:

Can it be tested on a physical device too?

@ej-sanmartin
Copy link
Author

Thanks for the comment, yes ideally it should be async so it's not blocking the rest of the game's processes. I haven't measured it but most likely there'd be a noticeable performance cost using synchronous implementation that's currently in place.

And I'll test it in my mobile device. With this native API, there's fields that can be adjusted to change how intense and "sharp" the vibration feels. I'll keep them in them as is since further customization would necessitate us to update Love2D's vibrate API for macOS, which would not be so clean potentially if we want to keep this in parity with the Android version.

@ej-sanmartin ej-sanmartin force-pushed the feat/ios-modern-vibration-api branch from 2681c9f to fbb0c7f Compare December 15, 2025 07:17
@ej-sanmartin ej-sanmartin force-pushed the feat/ios-modern-vibration-api branch from 66f010c to 53f56fc Compare December 15, 2025 07:19
@ej-sanmartin
Copy link
Author

ej-sanmartin commented Dec 15, 2025

Made the changes and created a minimal Love2D project, which cycles through 3 different vibration calls on iOS.

1st tap tap goes for 1 second, 2nd tap goes for 3 seconds, and the 3rd tap goes for 5 seconds. 4th tap rotates back to the 1 second vibration.

Love2D-vibration-change-on-iOS.MOV

Built successfully with no errors or warnings related to the Haptic Engine initialization (error message did help me identify a missing field though so thanks for suggesting that).

Btw device is an iPhone 14 Pro Max, iOS 26.2

@ej-sanmartin ej-sanmartin requested a review from slime73 December 16, 2025 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support vibrate(intensity, mode) for iOS

2 participants