Use Menu & Play/Pause Buttons for Gaming?

Is it possible/allowed to use the Menu and Play/Pause buttons to interact in a game?

Replies

pressesBegan is the method for handling these buttons. I'd guess Apple doesn't want you using those as game buttons, just play/pause or menu functionality. Like start/select on a Playstation controller.


SEE also: UIPressTypeSelect, UIPressTypeMenu. The press type determines the button on the remote that was pressed.

Use the Menu & Play/Pause buttons inside game

Based on this documentation page: https://developer.apple.com/tvos/human-interface-guidelines/remote-and-interaction/ you are allowed to use the Menu and Play/Pause buttons for interacting with elements inside your game. From the docs, the play/pause button "Performs secondary button behavior." when inside a game. This would be equivalent to the b button on a game controller.

The menu button "

Pauses/resumes gameplay.

Returns to previous screen, exits to main game menu, and/or exits to Apple TV Home screen."


Implementation:

Use a UITapGestureRecognizer to get notified about the buttons being pressed.


UITapGestureRecognizer *pausePlayButtonPressedGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pausePlayPressed)];



    pausePlayButtonPressedGestureRecognizer.allowedPressTypes = @[[NSNumber numberWithInteger:UIPressTypePlayPause]];



    [self.view addGestureRecognizer:pausePlayButtonPressedGestureRecognizer];

Yes, if you use the GCMicroGamepad the play/pause button acts as "Button X" (along with "Button A" being the touchpad click). This is better than listening for taps, because you can get the exact state of the button (pressed or not) at every update tick.


You can use the menu button, but not for regular gameplay stuff, only as a pause/back button.


But this doesn't make any sense. This is a screenshot of this page: https://developer.apple.com/library/prerelease/tvos/documentation/General/Conceptual/AppleTV_PG/WorkingwithGameControllers.html


"You must support the pause button. All controllers include a Pause button. When gameplay is active, pressing the Pause button should pause gameplay."

OR


"The menu button on the remote is used to pause gameplay, calling the controller object’s pause handler."


So which is it? Is menu pause or is play/pause pause? Or can we just program our own **** buttons?

I appreciate that wording appears contradictory. MFi Game Controllers include a pause button, which maps to the Menu button on tvOS. There is no "Menu" button on an MFi Game Controller.


On the Siri Remote, the Menu button exists and should function as the Menu button, thus pausing gameplay and backing out of levels of the hierarchy as it does in other apps. The play/pause button functions as an X button, and therefore can be used as required in gameplay.

Is there an approved or recommended "flow" for this behavior? For example, you press Menu to pause the game. Then if you press Menu again, should it un-pause the game or should it back out of the app? Should you have to do something else to resume, like select a "resume" button and click the remote?

From the Human Interface Guidelines:

Give people a way back to the previous screen and out of your app or game. Users expect to press the Menu button on the remote or game controller and return to a previous screen or the main Apple TV Home screen. Pressing Menu at the top level of an app or game should always exit to the Apple TV Home screen. During gameplay, pressing Menu should show or hide an in-game pause menu that includes an option to navigate back to the game’s main menu.

Getting erros when adding the code to my project. Main error is Use of undelclared Identifier "self"

Thanks,


To be honest, I think this mapping has been a big mistake.

Mfi pause should have been mapped to Siri Remote play/pause.

MENU should consistently be for moving up hierarchy, never for pausing.

Play/Pause should have been reserved for pausing game, not as a generic game play button.


It is confusing devs now, but coming launch time, it is going to confuse customers just as much.


i will file a bug.


bram

filed as radar 23276357