[iOS] Cosmetic changes in joystick implementation

This commit is contained in:
Laurent Gomila 2013-10-07 22:07:02 +02:00 committed by Jonathan De Wachter
parent 3f7486323a
commit 00d3bf1e7f

View File

@ -144,41 +144,43 @@ JoystickState JoystickImpl::update()
// Always connected // Always connected
state.connected = true; state.connected = true;
CMMotionManager* manager = [SFAppDelegate getInstance].motionManager;
switch (m_index) switch (m_index)
{ {
case Accelerometer: case Accelerometer:
// Acceleration is given in G (reminder: 1G is regular earth gravity, 9.81 m/s^2), in range [-2, 2] (could be more on newer devices?) // Acceleration is given in G (reminder: 1G is regular earth gravity, 9.81 m/s^2), in range [-2, 2] (could be more on newer devices?)
state.axes[Joystick::X] = [SFAppDelegate getInstance].motionManager.accelerometerData.acceleration.x; state.axes[Joystick::X] = manager.accelerometerData.acceleration.x;
state.axes[Joystick::Y] = [SFAppDelegate getInstance].motionManager.accelerometerData.acceleration.y; state.axes[Joystick::Y] = manager.accelerometerData.acceleration.y;
state.axes[Joystick::Z] = [SFAppDelegate getInstance].motionManager.accelerometerData.acceleration.z; state.axes[Joystick::Z] = manager.accelerometerData.acceleration.z;
break; break;
case Gyroscope: case Gyroscope:
// Rotation rates are given in rad/s, in range [?, ?] // Rotation rates are given in rad/s, in range [?, ?]
state.axes[Joystick::X] = [SFAppDelegate getInstance].motionManager.gyroData.rotationRate.x; state.axes[Joystick::X] = manager.gyroData.rotationRate.x;
state.axes[Joystick::Y] = [SFAppDelegate getInstance].motionManager.gyroData.rotationRate.y; state.axes[Joystick::Y] = manager.gyroData.rotationRate.y;
state.axes[Joystick::Z] = [SFAppDelegate getInstance].motionManager.gyroData.rotationRate.z; state.axes[Joystick::Z] = manager.gyroData.rotationRate.z;
break; break;
case Magnetometer: case Magnetometer:
// Magnetic field is given in microteslas, in range [?, ?] // Magnetic field is given in microteslas, in range [?, ?]
state.axes[Joystick::X] = [SFAppDelegate getInstance].motionManager.magnetometerData.magneticField.x; state.axes[Joystick::X] = manager.magnetometerData.magneticField.x;
state.axes[Joystick::Y] = [SFAppDelegate getInstance].motionManager.magnetometerData.magneticField.y; state.axes[Joystick::Y] = manager.magnetometerData.magneticField.y;
state.axes[Joystick::Z] = [SFAppDelegate getInstance].motionManager.magnetometerData.magneticField.z; state.axes[Joystick::Z] = manager.magnetometerData.magneticField.z;
break; break;
case UserAcceleration: case UserAcceleration:
// User acceleration (gravity removed), same unit and range as raw accelerometer values // User acceleration (gravity removed), same unit and range as raw accelerometer values
state.axes[Joystick::X] = [SFAppDelegate getInstance].motionManager.deviceMotion.userAcceleration.x; state.axes[Joystick::X] = manager.deviceMotion.userAcceleration.x;
state.axes[Joystick::Y] = [SFAppDelegate getInstance].motionManager.deviceMotion.userAcceleration.y; state.axes[Joystick::Y] = manager.deviceMotion.userAcceleration.y;
state.axes[Joystick::Z] = [SFAppDelegate getInstance].motionManager.deviceMotion.userAcceleration.z; state.axes[Joystick::Z] = manager.deviceMotion.userAcceleration.z;
break; break;
case AbsoluteOrientation: case AbsoluteOrientation:
// Absolute rotation (Euler) angles are given in radians, in range [-PI, PI] // Absolute rotation (Euler) angles are given in radians, in range [-PI, PI]
state.axes[Joystick::X] = [SFAppDelegate getInstance].motionManager.deviceMotion.attitude.yaw; state.axes[Joystick::X] = manager.deviceMotion.attitude.yaw;
state.axes[Joystick::Y] = [SFAppDelegate getInstance].motionManager.deviceMotion.attitude.pitch; state.axes[Joystick::Y] = manager.deviceMotion.attitude.pitch;
state.axes[Joystick::Z] = [SFAppDelegate getInstance].motionManager.deviceMotion.attitude.roll; state.axes[Joystick::Z] = manager.deviceMotion.attitude.roll;
break; break;
default: default: