Author Topic: Android and keyboards  (Read 6190 times)

chooseusername

  • Rogueliker
  • ***
  • Posts: 329
  • Karma: +0/-0
    • View Profile
    • Email
Android and keyboards
« on: July 27, 2012, 09:00:39 PM »
I've spent quite a bit of time (around a day) trying to get the keyboard support in BrogueX working, and I thought I'd share my results.  At this point, I'm just looking into the support for entering text at prompts, like when you need to provide a filename to save your game recording.  Much of this applies to controlling the game directly though.

If the device has a physical keyboard, then you're almost fine.  It won't have some special keys that are important, like escape though, so if like in Brogue that is used to cancel or skip, then a change is required.

If your device does not have a physical keyboard, then the application can force the soft on-screen keyboard to be displayed.  Ideally, this would be used to send key presses to the application.  In reality, it has predictive input built in and you only get some random key events, like the space key.  Apparently you can bypass this by displaying a formal Android edit field and configuring it in some way, or getting the user to disable the predictive behaviour in their device settings (which is unreasonable).  You can also provide your own keyboard, in several different fashions.

Now there is Nethack for Android.  This supports key presses by providing it's own keyboard, and it does so in a way where the keyboard is always present on screen and does not take overlay half the screen like the system soft keyboards.  Basically, it is a scrollable row of specific key buttons at the bottom of the screen.

There seems to be something strange with the emulator and the default setup, as the initial input setting was Japanese and the soft keyboard just wouldn't display with it.  I know this because when I exited the application, I could see my soft keyboard sitting there open and displayed on the home screen and it was the japanese one.  The soft keyboard just didn't display in my application until I disabled all but the standard  input method.

Unfortunately, the way you have to discover all this is through a combination of trial and error, and haphazardly stumbling over a selection of blog posts and Stack Overflow questions & answers.  Pretty much par for the course in programming land  :D