omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    haptic and vibration feedback

    Pythonista
    4
    6
    2065
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Drizzel
      Drizzel last edited by Drizzel

      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.

      cvp mikael 2 Replies Last reply Reply Quote 1
      • Drizzel
        Drizzel last edited by Drizzel

        @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)
        
        JonB 1 Reply Last reply Reply Quote 0
        • cvp
          cvp @Drizzel last edited by cvp

          @Drizzel seems nice but my iDevices, iPad Mini 4 and l'iPhone 5s, are like me.....too old 😂

          Drizzel 1 Reply Last reply Reply Quote 0
          • Drizzel
            Drizzel @cvp last edited by

            @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

            1 Reply Last reply Reply Quote 0
            • mikael
              mikael @Drizzel last edited by

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

              1 Reply Last reply Reply Quote 1
              • JonB
                JonB @Drizzel last edited by

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

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post
                Powered by NodeBB Forums | Contributors