Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[ios] Provide haptic feedback when user rotates to due north #10847

Merged
merged 2 commits into from
Feb 28, 2018

Conversation

friedbunny
Copy link
Contributor

@friedbunny friedbunny commented Jan 5, 2018

This is an embellishment, brought about by the fact that I have a phone that supports it now. 😉

  • Adds light haptic feedback when a user rotates the compass to/across due north.
    • Acts as a hint to users that they’ve found north/0°.
    • Requires iOS 10+ and a device that supports haptic feedback (iPhone 7 or newer).
    • Does not play haptics when the compass auto-snaps back, as that seemed too distracting/disconnected. Could reinvestigate, if folks thought that’d be worthwhile.
  • Adds MGLMapView.hapticFeedbackEnabled, enabled by default.
  • Makes iosapp’s zoom/tilt/rotation HUD persistent across launches and repositions it to the top-left.

/cc @fabian-guerra @akitchen @1ec5

@friedbunny friedbunny added feature iOS Mapbox Maps SDK for iOS labels Jan 5, 2018
@friedbunny friedbunny self-assigned this Jan 5, 2018
This feature requires a device that supports haptic feedback, running iOS 10 or
newer.
*/
@property(nonatomic, getter=isHapticFeedbackEnabled) BOOL hapticFeedbackEnabled;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we’ll eventually outgrow this single Boolean flag. Something akin to AppKit’s NSHapticFeedbackPattern enumeration would give us a bit more flexibility.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which would be the events that may provide haptic feedback?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, just compass snapping, though #10847 (comment) hints at a couple more possibilities. An enumeration with “haptic feedback levels” would give us room to add more in the future without overwhelming the default behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having an enum would allow us to offer a higher/broader level of feedback as a configurable option, which could be nice. I think that’s a #future thing, though, when/if we’re able to find multiple other use cases for rumbling people’s devices.

nintendo_rumble_pak

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, though note that this design locks us into a binary option until v5.0.0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a very good point. An enum with just two values (on and off, essentially) would make this easier to extend in the #future without the need for a deprecation and subsequent breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we call the on enum value if we don’t know what future options will be? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of a bitfield along the lines of MGLDebugMaskOptions, except perhaps with an All option that occupies the entire width of the type.

@@ -493,6 +493,19 @@ MGL_EXPORT IB_DESIGNABLE
*/
@property(nonatomic, getter=isPitchEnabled) BOOL pitchEnabled;

/**
A Boolean value that determines whether the user will receive haptic feedback
for certain interactions with the map.
Copy link
Contributor

@1ec5 1ec5 Jan 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going forward, any gesture that results in a snapping motion should trigger haptic feedback, if only for consistency. What about situations where we limit user interaction without snapping? Eventually we’ll want to implement snapping if the user tilts too far (#2191) or the developer returns NO in -[MGLMapViewDelegate mapView:shouldChangeFromCamera:toCamera:], but these interactions do represent a hard stop currently.

@friedbunny friedbunny added this to the ios-v4.0.0 milestone Jan 11, 2018
@friedbunny
Copy link
Contributor Author

Per discussion, I’ll look into converting BOOL hapticFeedbackEnabled to a bitmasked enum.

@friedbunny friedbunny changed the base branch from master to release-boba February 22, 2018 18:52
@friedbunny
Copy link
Contributor Author

On second thought, I’d like to just proceed with BOOL hapticFeedbackEnabled. Here’s my reasoning:

  • There aren’t many haptic use-cases in this SDK that we should implement by default — limit snapping/stopping seems to be essentially it. Developers are free to implement marker-dropping thuds today, but that’s probably not something we’d offer either way.
  • Anything more than a BOOL feels like over-designing for a future that probably won’t happen. (E.g., it’s taken us 1.5 years to get to haptic feedback at all, we’re not designing AppKit, etc.)
  • If we find additional use-cases that would overwhelm the current implementation, eventually deprecating one BOOL is not a huge risk — I think it’s better to keep a simpler API today.

@friedbunny friedbunny merged commit ab27e24 into release-boba Feb 28, 2018
@friedbunny friedbunny deleted the fb-haptic-compass branch February 28, 2018 00:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants