Pythonista implementation for haptic engine and vibration feedback
allows feelable feedback over the haptic engine and vibration.
The iPhone 6s is the first iOS device to come with a haptic engine, which is only supported over a little workaround. This is used automatically. More info below.
Copy from GitHub
import feelback
feelback.selectionChanged()
feelback.impactOccured(workaround = True)
for id in range (0, 3): feelback.notificationOccured(id)
feelback.vibrate()
It is also possible to play predefined SystemSounds by calling AudioServicesPlaySystemSound(id)
.
Apart of simple vibrations, there basically are three different types of haptic feedback. Their intended uses are defined in the Apple developer docs as these:
selectionChanged
impactOccured
- e.g. for gamesnotificationOccured
Since the iPhone 6s only supports this over a little workaround, the boolean workaround
is used to change between using the "proper" method and the workaround.
If, for any reason, you need to use the workaround instead of the "proper" method, just pass workaround = True
.
selectionChanged(workaround = workaround)
Pretty self-explanatory
selectionChanged(workaround = workaround)
Same as selectionChanged
notificationOccured(id = False, workaround = workaround)
If the "proper" method is used, there are different types (0, 1 and 2) to choose from. Maybe there's more, but I only know of these. if no id is passed, the workaround is used automatically. This is because I haven't yet found the AudioServices ids of any types except one, assuming they exist.
vibrate()
As far as I know, there is no way to contol the strength or duration of the vibration. The latter can only be achieved by calling the vibrate
multiple times with a slight delay, so they still overlap.