OUYA double tap for system menu third party controllers

Thread about finding way and writing down how to close games on OUYA without hard shutdown.

So far with all third party controllers I have never gotten to work ‘OUYA system menu’.
I have some info into how OUYA system menu is activated:

Cleanly shutting down audio

When you exit the app and/or open the system menu, any ongoing game audio should be paused or stopped. Your app is responsible for managing its own audio. Failing to do so may be grounds for review process failure.

When the system overlay menu opens (e.g. when the system button is held or double tapped) the framework broadcasts a sticky intent with the action tv.ouya.intent.action.OUYA_MENU_APPEARING (also defined in OuyaIntent). You can set up a BroadcastReceiver for this either dynamically or statically.

Full link here:

In keylayout files for xbox360 wired, ps3? Controllers have button mapping for HOME and HOME ALT but they never do anything in-game.
For some reason only original OUYA controller is able to show system menu. How is that?

New info 04/01/2025

System Button

The OUYA System button is a special case. Double tapping the System button will open an OUYA menu that lets users exit/pause the game. Your game has no control over this menu and due to the special way the system button is handled, button pressure events for the system button (input.kJoypadButtonXbox360Start) are always positive.

What does all this mean!? It means that you will never receive an nPressure value of 0 for the System button! Ever! So if you actually do anything with the System key, just assume that an nPressure value > 0 means it was pressed. Don’t try to latch or debounce it like you might do with other buttons.
Link here:

New info 04/01/2025

Input

One common issue with Android games is supporting different controller hardware. We’ve created an API which will remap input from various controller manufacturers to the standard OUYA button layout. The remapping logic is provided by the Cortex Framework, and will be constantly updated to add support for more and more controllers.

The easiest way to take advantage of this is by simply extending from the OuyaActivity class in the ODK. This will do a couple things automatically for you:

  • remap controller input to the standard OUYA layout
  • update OuyaController status

This is achieved by:
Link here:

New info 04/01/2025
Android development says HOME is handled by IME framework and never sent to apps.

KEYCODE_HOME

Added in API level 1

public static final int KEYCODE_HOME

Key code constant: Home key. This key is handled by the framework and is never delivered to applications.

Constant Value: 3 (0x00000003)
Link here:

New info 04/01/2025
It is impossible to detect and/or intercept the HOME button from within an Android app. This is built into the system to prevent malicious apps that cannot be exited.
Link here:

New info 04/01/2025
The Home button is a very dangerous button to override and, because of that, Android will not let you override its behavior the same way you do the BACK button.

Take a look at this discussion.

You will notice that the home button seems to be implemented as a intent invocation, so you’ll end up having to add an intent category to your activity. Then, any time the user hits home, your app will show up as an option. You should consider what it is you are looking to accomplish with the home button. If its not to replace the default home screen of the device, I would be wary of overloading the HOME button, but it is possible (per discussion in above thread.)
Link here:

new info 04/01/2025
Managed to show with Android ADB commands SYSTEM MENU in main screen. I am missing INTENT to start it from ADB command, any ideas how to do it?

#shell@android:/ # dumpsys window | grep -E 'mCurrentFocus'
# OUYA main screen when powered on
#  mCurrentFocus=Window{41e8dda0 tv.ouya.console/tv.ouya.console.launcher.home.HomeActivity paused=false}
#shell@android:/ # dumpsys window | grep -E 'mCurrentFocus'
#OUYA play screen to chose game to play
#  mCurrentFocus=Window{41ded2f0 tv.ouya.console/tv.ouya.console.launcher.play.PlayActivity paused=false}
#shell@android:/ # dumpsys window | grep -E 'mCurrentFocus'
# OUYA SYSTEM MENU in PLAY menu out-side game
#  mCurrentFocus=Window{41df9cd8 tv.ouya.console/tv.ouya.console.launcher.guide.GuideActivity paused=false}