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) {
print(button)
}
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 {
self.behandelenExtendedGamePadButtons(button: ExtendedGamePadButton.menu)
}
}
}