lichess-org / lichobile

lichess.org mobile application
https://lichess.org/mobile
GNU General Public License v3.0
2.03k stars 318 forks source link

Use nicer taptic feedback on iOS instead of generic “vibrate” #1918

Closed ulope closed 2 years ago

ulope commented 2 years ago

Is your feature request related to a problem? Please describe. When vibration is enabled a generic (and relatively long) “vibrate” is used.

Describe the solution you'd like All current iPhones have a Taptic Engine that allows much nicer / richer haptic feedback. For example for an opponents move a simple tap could be enough while a check might be a stronger double tap.

jas14 commented 2 years ago

@ulope thanks for the feedback. If you're interested, this should be "fairly straightforward" (famous last words) to implement! Capacitor already has a Haptics plugin, which is what we use. We only use the vibrate method right now, with the default 300ms duration. You could certainly vary the duration based on move type (no check / check /checkmate) and/or game speed, maybe use an "impact"-type vibration, or even do more complex "double-tap" sort of haptics as you've mentioned. It would all be contained in the TypeScript code, meaning you could write once for both platforms. 😃

ulope commented 2 years ago

Ok I might have a look at that, although I don't have any experience with capacitor. The docs aren't very exhaustive it seems. They mention that on platforms that lack enhanced taptics support the API calls silently do nothing. Do you know a way to query for supported features?

jas14 commented 2 years ago

I don't know of a way to query for supported features, but fortunately I don't think that's necessary in this case. If a device doesn't support vibration at all, the user would presumably know and would not be surprised if there were no vibration when the setting is enabled. Furthermore, from a cursory look at the @capacitor/haptics source code for Android and iOS, it appears all of the haptics interfaces are implemented on both platforms, so you don't have to worry that certain calls will work on one platform but not the other.

So the TL;DR good news is that you just have to focus on the JS-side calls.