SDL2 Android Activity mixing Android Controls + Game surface


I am looking into the Android, and I would like to have a regular Android/Material control on top, with three dots, which could be use to configure my app preferences and extras at all times, using a regular context menu.

The SDL activity currently grabs the activity surface and then makes the drawing there. Has someone added an extra layer on top just to be able to render native android controls there? Is this possible? Or would I need to refactor the SDL activity to a fragment or a component for this?


(also I wasn’t sure if this goes in SDL Development or Game Development)

I created an activity by extending the SDLActivity. I managed to add a floating button there. Now I want to make hitting this button that is on this activity to send an ESC key press to SDL so I can read this key in my game.

Is it possible to send a key press? Which function I need to call from my extended activity?

I also can’t find a way to draw a context menu or an options menu in front of the Surface.

OK, drawing the context menu in front of the surface requires picking up the view layout and adding the context menu there after the surface so we get things on top.

Sending keyboard keys I managed to send key down and key up events manually after a defined time and after the menu the context menu was closed. I used this to pass some special Ctrl+A-Z keys.

I wanted to also allow showing the default android keyboard from this menu in a separate option…

Now I can’t seem to be able to receive keys from the on screen keyboard. No events appears in the C++ part of my project. I wonder if there’s a difference between toggling the keyboard from C side and from the menu I placed in the activity. :confused:

Edit: turns out there is. I now show keyboard using SDL side functions and it worked.


Does SDL DISPLAY EVENT orientation changed also spawns a WINDOW SIZE CHANGED event? I can’t seem to be able to figure this out…