mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 12:51:05 +08:00
[iOS] Cosmetic changes in joystick implementation
This commit is contained in:
parent
3f7486323a
commit
00d3bf1e7f
@ -144,41 +144,43 @@ JoystickState JoystickImpl::update()
|
||||
// Always connected
|
||||
state.connected = true;
|
||||
|
||||
CMMotionManager* manager = [SFAppDelegate getInstance].motionManager;
|
||||
|
||||
switch (m_index)
|
||||
{
|
||||
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?)
|
||||
state.axes[Joystick::X] = [SFAppDelegate getInstance].motionManager.accelerometerData.acceleration.x;
|
||||
state.axes[Joystick::Y] = [SFAppDelegate getInstance].motionManager.accelerometerData.acceleration.y;
|
||||
state.axes[Joystick::Z] = [SFAppDelegate getInstance].motionManager.accelerometerData.acceleration.z;
|
||||
state.axes[Joystick::X] = manager.accelerometerData.acceleration.x;
|
||||
state.axes[Joystick::Y] = manager.accelerometerData.acceleration.y;
|
||||
state.axes[Joystick::Z] = manager.accelerometerData.acceleration.z;
|
||||
break;
|
||||
|
||||
case Gyroscope:
|
||||
// Rotation rates are given in rad/s, in range [?, ?]
|
||||
state.axes[Joystick::X] = [SFAppDelegate getInstance].motionManager.gyroData.rotationRate.x;
|
||||
state.axes[Joystick::Y] = [SFAppDelegate getInstance].motionManager.gyroData.rotationRate.y;
|
||||
state.axes[Joystick::Z] = [SFAppDelegate getInstance].motionManager.gyroData.rotationRate.z;
|
||||
state.axes[Joystick::X] = manager.gyroData.rotationRate.x;
|
||||
state.axes[Joystick::Y] = manager.gyroData.rotationRate.y;
|
||||
state.axes[Joystick::Z] = manager.gyroData.rotationRate.z;
|
||||
break;
|
||||
|
||||
case Magnetometer:
|
||||
// Magnetic field is given in microteslas, in range [?, ?]
|
||||
state.axes[Joystick::X] = [SFAppDelegate getInstance].motionManager.magnetometerData.magneticField.x;
|
||||
state.axes[Joystick::Y] = [SFAppDelegate getInstance].motionManager.magnetometerData.magneticField.y;
|
||||
state.axes[Joystick::Z] = [SFAppDelegate getInstance].motionManager.magnetometerData.magneticField.z;
|
||||
state.axes[Joystick::X] = manager.magnetometerData.magneticField.x;
|
||||
state.axes[Joystick::Y] = manager.magnetometerData.magneticField.y;
|
||||
state.axes[Joystick::Z] = manager.magnetometerData.magneticField.z;
|
||||
break;
|
||||
|
||||
case UserAcceleration:
|
||||
// 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::Y] = [SFAppDelegate getInstance].motionManager.deviceMotion.userAcceleration.y;
|
||||
state.axes[Joystick::Z] = [SFAppDelegate getInstance].motionManager.deviceMotion.userAcceleration.z;
|
||||
state.axes[Joystick::X] = manager.deviceMotion.userAcceleration.x;
|
||||
state.axes[Joystick::Y] = manager.deviceMotion.userAcceleration.y;
|
||||
state.axes[Joystick::Z] = manager.deviceMotion.userAcceleration.z;
|
||||
break;
|
||||
|
||||
case AbsoluteOrientation:
|
||||
// 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::Y] = [SFAppDelegate getInstance].motionManager.deviceMotion.attitude.pitch;
|
||||
state.axes[Joystick::Z] = [SFAppDelegate getInstance].motionManager.deviceMotion.attitude.roll;
|
||||
state.axes[Joystick::X] = manager.deviceMotion.attitude.yaw;
|
||||
state.axes[Joystick::Y] = manager.deviceMotion.attitude.pitch;
|
||||
state.axes[Joystick::Z] = manager.deviceMotion.attitude.roll;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user