tvOS : Play/Pause button is not working on simulator

On Apple TV developer's kit, Play/Pause button of siri remote is working good.

But on simulator ("Show Apple TV Remote") Play/Pause button is dead, although Menu and Home buttons are both working.

Clicking on the touch surface is not working neither.


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerDidConnect:) name:GCControllerDidConnectNotification object:nil];
     return YES;
}

- (void)controllerDidConnect:(NSNotification *)notification {
     self.myController = notification.object;

     // Touch surface click (not tap)
     GCControllerButtonInput *buttonA = self.myController.microGamepad.buttonA;
     buttonA.pressedChangedHandler =  ^ (GCControllerButtonInput *btn, float a, BOOL b) {

     // Did not come here on tvOS simulator.
     // Came here on real device (AppleTV dev kit)
     };
     buttonA.valueChangedHandler =  ^ (GCControllerButtonInput *btn, float a, BOOL b) {

     // Did not come here on tvOS simulator.
     // Came here on real device (AppleTV dev kit)
     };


     // Play/Pause button click
     GCControllerButtonInput *buttonX = self.myController.microGamepad.buttonX;
     buttonX.pressedChangedHandler =  ^ (GCControllerButtonInput *btn, float a, BOOL b) {

     // Did not come here on tvOS simulator.
     // Came here on real device (AppleTV dev kit)
     };
     buttonX.valueChangedHandler =  ^ (GCControllerButtonInput *btn, float a, BOOL b) {

     // Did not come here on tvOS simulator.
     // Came here on real device (AppleTV dev kit)
     };
}


How can I detect these buttons in simulator ?

Any workaround ?


tvOS beta3 on Xcode7.1 beta 3


Thanks

Yos

Answered by AlohaYos in 72998022

Found just a simple workaround.


if TARGET_IPHONE_SIMULATOR

- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {

     for(UIPress *press in presses) {
          if(press.type == UIPressTypeSelect) {
            // do ButtonA job    
          }
          if(press.type == UIPressTypePlayPause) {
            // do ButtonX job               
          }
     }
}

#endif

I also tried this code below.

"microPad.buttonX.isPressed" was always NO on simulator.


- (void)controllerDidConnect:(NSNotification *)notification {
     self.myController = notification.object;
     self.remoteCheckTimer = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(remoteCheckJob) userInfo:nil repeats:YES];
}

- (void)remoteCheckJob {
     if(self.myController) {
          GCMicroGamepad *microPad = self.myController.microGamepad;
          if(microPad) {
               BOOL isPressedA = microPad.buttonA.isPressed;  // always NO on simulator
               BOOL isPressedX = microPad.buttonX.isPressed;  // always NO on simulator
          }
     }
}
Accepted Answer

Found just a simple workaround.


if TARGET_IPHONE_SIMULATOR

- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {

     for(UIPress *press in presses) {
          if(press.type == UIPressTypeSelect) {
            // do ButtonA job    
          }
          if(press.type == UIPressTypePlayPause) {
            // do ButtonX job               
          }
     }
}

#endif
tvOS : Play/Pause button is not working on simulator
 
 
Q