haptic and vibration feedback
-
I was just playing around, and thought this might be useful to others as well. So I signed up to GitHub. Feelback (didn't know how else to call it, I know it's a bit cringey) makes it fairly easy to get vibrations and haptic feedback, assuming your device has a haptic engine built in.
The oldest supported iPhone is the 6s (mine), and it only works with a little workaround. I don't know which iPads work (my iPad mini 2 is just way too old), or if they have a haptic engine at all.
Does anyone know if there are other SystemSounds than these? Because even this list doesn't include the ids for haptic feedback (1519, 1520, 1521) , so there may be more.
-
@omz used a slightly different code here. What's the advantage of his code over this?
import ctypes import time c = ctypes.CDLL(None) vibrate = c.AudioServicesPlaySystemSound if __name__ == '__main__': for i in range(3): vibrate(4095) time.sleep(0.5)
-
@Drizzel seems nice but my iDevices, iPad Mini 4 and l'iPhone 5s, are like me.....too old 😂
-
@cvp jup, they are too old :) I was so relieved when I found out that at least my phone supports the haptic stuff! But I guess it's not really a feature that will be used often
-
@Drizzel, thanks. Now we know how to do it for that game that really needs it. For example, my draw-in-the-dark game caves sure could use this for that moment when you hit the wall.
-
@Drizzel @omz's code is identical, excep that he specifies the argtypes on the playaudiosystemsound, which you should also do, otherwise you risk crashing (say on a 32 bit vs 64 bit device).
I think ctypes defaults to 32 bit argtypes even on 64 bit devices, so you are safe in this case.