[ MONKEYX2 ] Android Back button

About Monkey 2 Forums Monkey 2 Programming Help [ MONKEYX2 ] Android Back button

This topic contains 13 replies, has 4 voices, and was last updated by  Amon 1 year, 4 months ago.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #12252

    Amon
    Participant

    What keyboard or mouse keys are the equivalent to the back button on android?

    I’m using a galaxy s4 for testing.

    #12255

    therevills
    Participant

    No idea sorry! Havent actually done any Android development in Monkey2 yet…

    I’ll investigate, unless you or anyone else knows!

    Edit: Quick Google in pure SDL2 C++:

    #12256

    therevills
    Participant

    In the native keyinfo.cpp within Mojo, Mark has:

    KeyInfo is used in keyboard.monkey2:

    In SDL_keycode.h

    And SDL_keyboard.c

    So we may be able to use it somehow…

    #12257

    therevills
    Participant

    I’ve copied some of the monkey keyboard code and found the scan values for AC_BACK:

    So Amon could you please add this code your project:

    Then when you want to hit the back key:

    I havent tested this so this may or may NOT work! 🙂

    #12259

    Amon
    Participant

    I added the top one to my GameScreen and the second in the GameScreen Update method. It doesn’t work though. Forgive me if I’m placing the code incorrectly.

    Thank you though for helping.

    #12279

    therevills
    Participant

    Nope you put in the right place…

    Damn, KeyHit calls KeyPressed which calls ScanCode… and ScanCode checks Key.Max 🙁

    I tried an Extension and sub classing the KeyboardDevice class both failed due to it uses a lot of private variables so it complains. I think we need Mark to make a change to get it to work – sorry.

    I’ll raise a GitHub ticket and point to this thread. Could you change title of this thread please (edit your first post) as its a Monkey2 issue than a Diddy2 issue 🙂

    Raised: https://github.com/blitz-research/monkey2/issues/293

    #12281

    Amon
    Participant

    Thanks, therevills. Your help is appreciated a lot. Also, an apology is not needed as you’ve done nothing wrong. 🙂

    Thread title has been edited as requested.

     

    Ta!

    #12282

    nerobot
    Participant

    What about Key.Escape? 🙂

    #12284

    Amon
    Participant

    First thing I tried….it doesn’t work though.

    #12289

    Mark Sibly
    Keymaster

    Some fixes for this are now up in the develop branch.

    It was mostly working already except there was an issue with sdl that meant the app wasn’t initally being given focus properly so key events weren’t getting sent to it. If you hit ‘home’ and refocus app, key events started working. I’ve hacked around this a bit and it should work now.

    The other issue is that the back key wasn’t even include in the Key enum. This has been fixed too, so you can now go:

    If Keyboard.KeyHit( Key.ACBack) App.Terminate()

    (Anyone know what the ‘AC’ in ‘ACBack’ stands for?)

    Here’s a little runnable demo which is working fine on my API15 emulator and nvidia shield.

    #12290

    Mark Sibly
    Keymaster

    …also, I should probably mention that I updated the default android studio project for android products to android studio 3.0.1, so android users should probably do the same. Ditto upgrade all installed tools/sdks/ndks etc to the latest versions.

    #12292

    therevills
    Participant

    I thought AC stood for Android Code, but it looks like it stands for Application Control.

    “AC Back” (the Back key (application control keypad))

    https://wiki.libsdl.org/SDL_ScancodeAndKeycode

    Thanks for fixing this.

    #12310

    Mark Sibly
    Keymaster

    Oops, broke non-android builds a bit…fixed now.

    #12324

    Amon
    Participant

    It’s working now. Thank you again, Mark.

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.