-int HTMLMediaElement::calcRotation(float x, float y, float z)
-{
- double atanV, normZ, rawZ;
- int accTheta, accPitch;
- int rotation;
-
- atanV = atan2(y, x);
- accTheta = static_cast<int>(atanV * (RADIAN_VALUE) + 270) % 360;
- rawZ = static_cast<double>(z / (0.004 * 9.81));
-
- if (rawZ > 250)
- normZ = 1.0;
- else if (rawZ < -250)
- normZ = -1.0;
- else
- normZ = (static_cast<double>(rawZ)) / 250;
-
- accPitch = static_cast<int>(acos(normZ) * (RADIAN_VALUE));
-
- if ((accPitch > 35) && (accPitch < 145)) {
- if ((accTheta >= 315 && accTheta <= 359) || (accTheta >= 0 && accTheta < 45))
- rotation = ROTATE_0;
- else if (accTheta >= 45 && accTheta < 135)
- rotation = ROTATE_90;
- else if (accTheta >= 135 && accTheta < 225)
- rotation = ROTATE_180;
- else if (accTheta >= 225 && accTheta < 315)
- rotation = ROTATE_270;
- else
- rotation = ROTATE_ERROR;
- } else
- rotation = ROTATE_ERROR;
-
- return rotation;
-}
-
-void HTMLMediaElement::onRotationChanged(uint64_t timeStamp, sensor_data_accuracy_e accuracy, float x, float y, float z, void* userData)
-{
- HTMLMediaElement* that = static_cast<HTMLMediaElement*>(userData);
-
- int autoRotation = 0;
- vconf_get_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &autoRotation);
- if (!autoRotation)
- return;
-
- int rotation = that->calcRotation(x, y, z);
- if (rotation == ROTATE_ERROR || rotation == s_rotation)
- return;