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.


    Reading input from Bluetooth keyboards?

    Pythonista
    3
    4
    1351
    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.
    • GeekOnSkates
      GeekOnSkates last edited by

      Hey, what's up?

      So this past Christmas, I got one of those "Ion iCade" arcade cabinets. I've been playing with building stuff for it using iDOS (which is cool and fun, but requires that I program my graphics sideways cuz it doesn't do portrait), and also building for the web (but IMO Safari is the new IE, and I'd rather not continue down that road if I can help it). But then I remembered that amazing Breakout clone that came with Pythonista, and I could see the light bulb turn on over my head. :D

      Yeah, I totally want to use Pythonista to build an iCade game, but there's a problem: the iCade is recognized as a Bluetooth keyboard. Now I saw there's a keyboard module for creating some kind of custom on-screen keyboard or something, and I saw the scene module has a section about reading from Bluetooth game controllers, but neither one really seem to fit what I'm looking for. I haven't been able to find anything in the docs that does. I'm sure I could dig up something in the objc_util module, but I don't know Objective-C and I'm not familiar with the APIs available on iOS (yet**).

      So when you press or release a button, or move the joystick, the iCade sends a keystroke to the device. So it's not really a controller as far as the device is concerned. It thinks someone just pressed "q" or "j" or some other key. So is there a way to read input from Bluetooth keyboards? I'm sure there's either a way to poll the keyboard state, or some kind of pygame-esque event-driven approach, or something like that. But all I know is what I've seen so far on the docs. Any ideas?

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

        @GeekOnSkates, sounds like a fun project!

        The ui.View.get_key_commands() and ui.View.key_command(sender) are what you are after. Search the forum, there is a sample here for using them with the scene module.

        1 Reply Last reply Reply Quote 0
        • GeekOnSkates
          GeekOnSkates last edited by

          Awesome! I will definitely check it out. Thanks. :)

          1 Reply Last reply Reply Quote 0
          • JonB
            JonB last edited by

            Does the key commands work with regular keypresses?

            It looks like in recent iOS versions, it would be possible to define keyPress events (via objc)
            https://www.swiftbysundell.com/tips/handling-keyup-and-keydown-events/

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