Via How to access motion & orientation information of remote:
First of all, one needs to use NSNotificationCenter
to find the controllers. Probably best to do this when app launches. Something like this:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerDidConnect:) name:GCControllerDidConnectNotification object:nil];
We can then use the following code after connecting to store the device info in a property:
- (void)controllerDidConnect:(NSNotification *)notification {
self.myController = notification.object;
}
The remote profile is a subclass of the micro gamepad profile. Motion and other data can be tracked by adding a value changed event handler:
GCMicroGamepad *profile = self.myController.microGamepad
profile.valueChangedHandler= ^ (GCMicroGamepad *gamepad, GCControllerElement *element) {
if (self.myController.motion) {
NSLog(@"motion supported");
NSLog(@"gravity: %f %f %f", self.myController.motion.gravity.x, self.myController.motion.gravity.y, self.myController.motion.gravity.z);
NSLog(@"userAcc: %f %f %f", self.myController.motion.userAcceleration.x, self.myController.motion.userAcceleration.y, self.myController.motion.userAcceleration.z);
NSLog(@"rotationRate: %f %f %f", self.myController.motion.rotationRate.x, self.myController.motion.rotationRate.y, self.myController.motion.rotationRate.z);
NSLog(@"attitude: %f %f %f %f", self.myController.motion.attitude.x, self.myController.motion.attitude.y, self.myController.motion.attitude.z, self.myController.motion.attitude.w);
}
};