Bug 734324 - implement device motion - rotation rate and acceleration. r=jdm

This commit is contained in:
Doug Turner
2012-03-13 16:57:51 -07:00
parent 8d14d19e31
commit 986e12dd8b
14 changed files with 250 additions and 120 deletions

View File

@@ -96,7 +96,7 @@ nsAppShell::nsAppShell()
mQueueCond(mCondLock, "nsAppShell.mQueueCond"),
mNumDraws(0),
mNumViewports(0),
mPendingOrientationEvents(false)
mPendingSensorEvents(false)
{
gAppShell = this;
}
@@ -336,20 +336,41 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
gDeviceMotionSystem->NeedsCalibration();
break;
case AndroidGeckoEvent::ACCELERATION_EVENT:
gDeviceMotionSystem->DeviceMotionChanged(nsIDeviceMotionData::TYPE_ACCELERATION,
-curEvent->X(),
curEvent->Y(),
curEvent->Z());
break;
case AndroidGeckoEvent::SENSOR_EVENT:
mPendingSensorEvents = false;
switch (curEvent->Flags()) {
case hal::SENSOR_ORIENTATION:
gDeviceMotionSystem->DeviceMotionChanged(nsIDeviceMotionData::TYPE_ORIENTATION,
curEvent->X(),
-curEvent->Y(),
-curEvent->Z());
break;
case AndroidGeckoEvent::ORIENTATION_EVENT:
gDeviceMotionSystem->DeviceMotionChanged(nsIDeviceMotionData::TYPE_ORIENTATION,
curEvent->Alpha(),
-curEvent->Beta(),
-curEvent->Gamma());
mPendingOrientationEvents = false;
break;
case hal::SENSOR_ACCELERATION:
gDeviceMotionSystem->DeviceMotionChanged(nsIDeviceMotionData::TYPE_ACCELERATION,
-curEvent->X(),
curEvent->Y(),
curEvent->Z());
break;
case hal::SENSOR_LINEAR_ACCELERATION:
gDeviceMotionSystem->DeviceMotionChanged(nsIDeviceMotionData::TYPE_LINEAR_ACCELERATION,
-curEvent->X(),
curEvent->Y(),
curEvent->Z());
break;
case hal::SENSOR_GYROSCOPE:
gDeviceMotionSystem->DeviceMotionChanged(nsIDeviceMotionData::TYPE_GYROSCOPE,
-curEvent->X(),
curEvent->Y(),
curEvent->Z());
break;
default:
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### SENSOR_EVENT fired, but type wasn't known %d", curEvent->Flags());
}
break;
case AndroidGeckoEvent::LOCATION_EVENT: {
if (!gLocationCallback)
@@ -603,10 +624,10 @@ nsAppShell::PostEvent(AndroidGeckoEvent *ae)
delete event;
}
}
} else if (ae->Type() == AndroidGeckoEvent::ORIENTATION_EVENT) {
if (!mPendingOrientationEvents)
mEventQueue.AppendElement(ae);
mPendingOrientationEvents = true;
} else if (ae->Type() == AndroidGeckoEvent::SENSOR_EVENT) {
if (!mPendingSensorEvents)
mEventQueue.AppendElement(ae);
mPendingSensorEvents = true;
} else {
mEventQueue.AppendElement(ae);
}