Debian Codegraph @

plyer/platforms/ios/vibrator.py

raw symbols SCIP
1 '''Implementation Vibrator for iOS.
2
3 Install: Add AudioToolbox framework to your application.
4 '''
5
6 import ctypes
7 from plyer.facades import Vibrator
8
9
10 class IosVibrator(Vibrator):
11 '''iOS Vibrator class.
12
13 iOS doesn't support any feature.
14 All time, pattern, repetition are ignored.
15 '''
16
17 def __init__(self):
18 super().__init__()
19 try:
20 self._func = ctypes.CDLL(None).AudioServicesPlaySystemSound
21 except AttributeError:
22 self._func = None
23
24 def _vibrate(self, time=None, **kwargs):
25 # kSystemSoundID_Vibrate is 0x00000FFF
26 self._func(0xFFF)
27
28 def _pattern(self, pattern=None, repeat=None, **kwargs):
29 self._vibrate()
30
31 def _exists(self, **kwargs):
32 return self._func is not None
33
34 def _cancel(self, **kwargs):
35 pass
36
37
38 def instance():
39 '''Returns Vibrator
40
41 :return: instance of class IosVibrator
42 '''
43 return IosVibrator()