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
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