GameController button B and menu

Using XCode and SpriteKit and connecting and using the extendedGamePad.

There seems to be the problem that when ever i use the B of Menu button, my program stops and tvOS returns to it’s menu.

So the menu button will be great to pause the game, and the B button to “jump” or “activate item”, but i can’t use these buttons right now, all the other buttons and thrumbstick are working fine.

Anybody who knows why this happens ? The ‘print(button)’ is called before the returning to the menu.
(see code below)

JW Sipkes

enum ExtendedGamePadButton {
    case A, B, X, Y, menu

func behandelenExtendedGamePadButtons(button: ExtendedGamePadButton) {

func behandelenExtendedGamePad(controller: GCController) {
    controller.extendedGamepad?.valueChangedHandler = {
        (gamepad: GCExtendedGamepad, element: GCControllerElement) in
       if gamepad.buttonA.isPressed {
            self.behandelenExtendedGamePadButtons(button: ExtendedGamePadButton.A)
        if gamepad.buttonB.isPressed {
            self.behandelenExtendedGamePadButtons(button: ExtendedGamePadButton.B)
        if gamepad.buttonX.isPressed {
            self.behandelenExtendedGamePadButtons(button: ExtendedGamePadButton.X)
        if gamepad.buttonY.isPressed {
            self.behandelenExtendedGamePadButtons(button: ExtendedGamePadButton.Y)
        if gamepad.buttonMenu.isPressed {

On tvOS, to make the B-button normal again, make sure the viewcontroller that controls your SKView is of class GCEventViewController and not UIViewController. Then set the controllerUserInteractionEnabled property to NO. This will make sure you can catch the B-button, menu and select.

Please note that the buttonMenu is only available on iOS 13 / tvOS 13, and I can only get it working on a real device, not in the simulator.

O yes, thanks ! This solves the problem.

This topic was automatically closed after 166 days. New replies are no longer allowed.