Reading input from Bluetooth keyboards?
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?
@GeekOnSkates, sounds like a fun project!
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.
Awesome! I will definitely check it out. Thanks. :)
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)