Skip to content

Pythonista haptic engine and vibration feedback

Notifications You must be signed in to change notification settings

Dr1zz3l/feelback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

feelback

Pythonista implementation for haptic engine and vibration feedback

Haptic and vibration feedback for the Pythonista iOS app

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.

Installation

Copy from GitHub

Usage

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).

Haptic engine

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 games
  • notificationOccured

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

selectionChanged(workaround = workaround)

Pretty self-explanatory

impactOccured

selectionChanged(workaround = workaround)

Same as selectionChanged

notificationOccured

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

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.

About

Pythonista haptic engine and vibration feedback

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages