2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-06-19 22:36:17 -07:00
|
|
|
|
2012-03-20 23:36:17 -07:00
|
|
|
#include "mozilla/Hal.h"
|
|
|
|
#include "mozilla/HalSensor.h"
|
|
|
|
|
2012-03-24 17:29:57 -07:00
|
|
|
#include "nsDeviceSensors.h"
|
2011-06-19 22:36:17 -07:00
|
|
|
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsIDOMEvent.h"
|
|
|
|
#include "nsIDOMWindow.h"
|
2011-08-31 19:39:49 -07:00
|
|
|
#include "nsPIDOMWindow.h"
|
2011-06-19 22:36:17 -07:00
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsIDOMEventTarget.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIServiceManager.h"
|
2012-04-03 21:09:20 -07:00
|
|
|
|
|
|
|
#include "mozilla/Preferences.h"
|
2012-06-14 19:31:55 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-03-09 10:40:43 -08:00
|
|
|
|
2012-03-20 23:36:17 -07:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace hal;
|
2012-03-13 09:59:24 -07:00
|
|
|
|
2012-05-16 13:27:54 -07:00
|
|
|
#undef near
|
|
|
|
|
2012-03-13 16:57:09 -07:00
|
|
|
// also see sDefaultSensorHint in mobile/android/base/GeckoAppShell.java
|
|
|
|
#define DEFAULT_SENSOR_POLL 100
|
|
|
|
|
2011-08-09 22:36:00 -07:00
|
|
|
static const nsTArray<nsIDOMWindow*>::index_type NoIndex =
|
2012-03-24 17:29:49 -07:00
|
|
|
nsTArray<nsIDOMWindow*>::NoIndex;
|
2011-07-26 09:27:11 -07:00
|
|
|
|
2012-06-14 19:31:55 -07:00
|
|
|
class nsDeviceSensorData MOZ_FINAL : public nsIDeviceSensorData
|
2011-06-19 22:36:17 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
2012-03-24 17:29:57 -07:00
|
|
|
NS_DECL_NSIDEVICESENSORDATA
|
2011-06-19 22:36:17 -07:00
|
|
|
|
2012-03-24 17:29:57 -07:00
|
|
|
nsDeviceSensorData(unsigned long type, double x, double y, double z);
|
2011-06-19 22:36:17 -07:00
|
|
|
|
|
|
|
private:
|
2012-03-24 17:29:57 -07:00
|
|
|
~nsDeviceSensorData();
|
2011-06-19 22:36:17 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
unsigned long mType;
|
|
|
|
double mX, mY, mZ;
|
|
|
|
};
|
|
|
|
|
2012-03-24 17:29:57 -07:00
|
|
|
nsDeviceSensorData::nsDeviceSensorData(unsigned long type, double x, double y, double z)
|
2011-06-19 22:36:17 -07:00
|
|
|
: mType(type), mX(x), mY(y), mZ(z)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-03-24 17:29:57 -07:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsDeviceSensorData)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDeviceSensorData)
|
2011-06-19 22:36:17 -07:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2012-03-24 17:29:57 -07:00
|
|
|
NS_IMPL_ADDREF(nsDeviceSensorData)
|
|
|
|
NS_IMPL_RELEASE(nsDeviceSensorData)
|
2011-06-19 22:36:17 -07:00
|
|
|
|
2012-03-24 17:29:57 -07:00
|
|
|
nsDeviceSensorData::~nsDeviceSensorData()
|
2011-06-19 22:36:17 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-03-24 17:29:57 -07:00
|
|
|
NS_IMETHODIMP nsDeviceSensorData::GetType(PRUint32 *aType)
|
2011-06-19 22:36:17 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aType);
|
|
|
|
*aType = mType;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-24 17:29:57 -07:00
|
|
|
NS_IMETHODIMP nsDeviceSensorData::GetX(double *aX)
|
2011-06-19 22:36:17 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aX);
|
|
|
|
*aX = mX;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-24 17:29:57 -07:00
|
|
|
NS_IMETHODIMP nsDeviceSensorData::GetY(double *aY)
|
2011-06-19 22:36:17 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aY);
|
|
|
|
*aY = mY;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-24 17:29:57 -07:00
|
|
|
NS_IMETHODIMP nsDeviceSensorData::GetZ(double *aZ)
|
2011-06-19 22:36:17 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aZ);
|
|
|
|
*aZ = mZ;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-24 17:29:57 -07:00
|
|
|
NS_IMPL_ISUPPORTS1(nsDeviceSensors, nsIDeviceSensors)
|
2011-06-19 22:36:17 -07:00
|
|
|
|
2012-03-24 17:29:57 -07:00
|
|
|
nsDeviceSensors::nsDeviceSensors()
|
2011-06-19 22:36:17 -07:00
|
|
|
{
|
2012-05-16 13:27:54 -07:00
|
|
|
mIsUserProximityNear = false;
|
2012-03-20 23:36:17 -07:00
|
|
|
mLastDOMMotionEventTime = TimeStamp::Now();
|
2012-05-02 09:43:45 -07:00
|
|
|
mEnabled = Preferences::GetBool("device.sensors.enabled", true);
|
2012-03-20 23:36:17 -07:00
|
|
|
|
2012-03-24 17:29:49 -07:00
|
|
|
for (int i = 0; i < NUM_SENSOR_TYPE; i++) {
|
|
|
|
nsTArray<nsIDOMWindow*> *windows = new nsTArray<nsIDOMWindow*>();
|
|
|
|
mWindowListeners.AppendElement(windows);
|
|
|
|
}
|
2011-06-19 22:36:17 -07:00
|
|
|
|
2012-03-24 17:29:49 -07:00
|
|
|
mLastDOMMotionEventTime = TimeStamp::Now();
|
2011-06-19 22:36:17 -07:00
|
|
|
}
|
|
|
|
|
2012-03-24 17:29:57 -07:00
|
|
|
nsDeviceSensors::~nsDeviceSensors()
|
2011-06-19 22:36:17 -07:00
|
|
|
{
|
2012-03-24 17:29:49 -07:00
|
|
|
for (int i = 0; i < NUM_SENSOR_TYPE; i++) {
|
|
|
|
if (IsSensorEnabled(i))
|
|
|
|
UnregisterSensorObserver((SensorType)i, this);
|
2011-06-19 22:36:17 -07:00
|
|
|
}
|
2012-03-24 17:29:49 -07:00
|
|
|
|
|
|
|
for (int i = 0; i < NUM_SENSOR_TYPE; i++) {
|
|
|
|
delete mWindowListeners[i];
|
2011-06-19 22:36:17 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
NS_IMETHODIMP nsDeviceSensors::ListenerCount(PRUint32 aType, PRInt32 *aRetVal)
|
|
|
|
{
|
|
|
|
if (!mEnabled) {
|
|
|
|
*aRetVal = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aRetVal = mWindowListeners[aType]->Length();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-24 17:29:57 -07:00
|
|
|
NS_IMETHODIMP nsDeviceSensors::AddWindowListener(PRUint32 aType, nsIDOMWindow *aWindow)
|
2011-06-19 22:36:17 -07:00
|
|
|
{
|
2012-05-02 09:43:45 -07:00
|
|
|
if (!mEnabled)
|
|
|
|
return NS_OK;
|
|
|
|
|
2012-03-24 17:29:49 -07:00
|
|
|
if (mWindowListeners[aType]->IndexOf(aWindow) != NoIndex)
|
|
|
|
return NS_OK;
|
2011-06-19 22:36:17 -07:00
|
|
|
|
2012-03-24 17:29:49 -07:00
|
|
|
if (!IsSensorEnabled(aType)) {
|
|
|
|
RegisterSensorObserver((SensorType)aType, this);
|
2011-06-19 22:36:17 -07:00
|
|
|
}
|
|
|
|
|
2012-03-24 17:29:49 -07:00
|
|
|
mWindowListeners[aType]->AppendElement(aWindow);
|
2011-06-19 22:36:17 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-24 17:29:57 -07:00
|
|
|
NS_IMETHODIMP nsDeviceSensors::RemoveWindowListener(PRUint32 aType, nsIDOMWindow *aWindow)
|
2011-06-19 22:36:17 -07:00
|
|
|
{
|
2012-03-24 17:29:49 -07:00
|
|
|
if (mWindowListeners[aType]->IndexOf(aWindow) == NoIndex)
|
|
|
|
return NS_OK;
|
2011-06-19 22:36:17 -07:00
|
|
|
|
2012-03-24 17:29:49 -07:00
|
|
|
mWindowListeners[aType]->RemoveElement(aWindow);
|
2012-03-24 17:30:03 -07:00
|
|
|
|
|
|
|
if (mWindowListeners[aType]->Length() == 0)
|
|
|
|
UnregisterSensorObserver((SensorType)aType, this);
|
|
|
|
|
2011-06-19 22:36:17 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-24 17:29:57 -07:00
|
|
|
NS_IMETHODIMP nsDeviceSensors::RemoveWindowAsListener(nsIDOMWindow *aWindow)
|
2011-06-19 22:36:17 -07:00
|
|
|
{
|
2012-03-24 17:29:49 -07:00
|
|
|
for (int i = 0; i < NUM_SENSOR_TYPE; i++) {
|
2012-03-24 17:30:03 -07:00
|
|
|
RemoveWindowListener((SensorType)i, aWindow);
|
2011-06-19 22:36:17 -07:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-20 23:36:17 -07:00
|
|
|
void
|
2012-03-24 17:29:57 -07:00
|
|
|
nsDeviceSensors::Notify(const mozilla::hal::SensorData& aSensorData)
|
2011-06-19 22:36:17 -07:00
|
|
|
{
|
2012-03-20 23:36:17 -07:00
|
|
|
PRUint32 type = aSensorData.sensor();
|
|
|
|
|
2012-06-05 14:41:22 -07:00
|
|
|
const InfallibleTArray<float>& values = aSensorData.values();
|
|
|
|
size_t len = values.Length();
|
|
|
|
double x = len > 0 ? values[0] : 0.0;
|
|
|
|
double y = len > 1 ? values[1] : 0.0;
|
|
|
|
double z = len > 2 ? values[2] : 0.0;
|
2012-03-20 23:36:17 -07:00
|
|
|
|
2012-03-09 08:41:25 -08:00
|
|
|
nsCOMArray<nsIDOMWindow> windowListeners;
|
2012-03-24 17:29:49 -07:00
|
|
|
for (PRUint32 i = 0; i < mWindowListeners[type]->Length(); i++) {
|
|
|
|
windowListeners.AppendObject(mWindowListeners[type]->SafeElementAt(i));
|
2011-06-19 22:36:17 -07:00
|
|
|
}
|
|
|
|
|
2012-03-09 08:41:25 -08:00
|
|
|
for (PRUint32 i = windowListeners.Count(); i > 0 ; ) {
|
2011-06-19 22:36:17 -07:00
|
|
|
--i;
|
|
|
|
|
2011-08-31 19:39:49 -07:00
|
|
|
// check to see if this window is in the background. if
|
|
|
|
// it is, don't send any device motion to it.
|
2012-03-09 08:41:25 -08:00
|
|
|
nsCOMPtr<nsPIDOMWindow> pwindow = do_QueryInterface(windowListeners[i]);
|
2011-09-04 11:53:39 -07:00
|
|
|
if (!pwindow ||
|
|
|
|
!pwindow->GetOuterWindow() ||
|
|
|
|
pwindow->GetOuterWindow()->IsBackground())
|
2011-08-31 19:39:49 -07:00
|
|
|
continue;
|
|
|
|
|
2011-06-19 22:36:17 -07:00
|
|
|
nsCOMPtr<nsIDOMDocument> domdoc;
|
2012-03-09 08:41:25 -08:00
|
|
|
windowListeners[i]->GetDocument(getter_AddRefs(domdoc));
|
2011-06-19 22:36:17 -07:00
|
|
|
|
|
|
|
if (domdoc) {
|
2012-03-09 08:41:25 -08:00
|
|
|
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(windowListeners[i]);
|
2012-03-24 17:29:57 -07:00
|
|
|
if (type == nsIDeviceSensorData::TYPE_ACCELERATION ||
|
|
|
|
type == nsIDeviceSensorData::TYPE_LINEAR_ACCELERATION ||
|
|
|
|
type == nsIDeviceSensorData::TYPE_GYROSCOPE)
|
2012-03-13 16:57:51 -07:00
|
|
|
FireDOMMotionEvent(domdoc, target, type, x, y, z);
|
2012-03-24 17:29:57 -07:00
|
|
|
else if (type == nsIDeviceSensorData::TYPE_ORIENTATION)
|
2011-06-19 22:36:17 -07:00
|
|
|
FireDOMOrientationEvent(domdoc, target, x, y, z);
|
2012-05-02 09:43:45 -07:00
|
|
|
else if (type == nsIDeviceSensorData::TYPE_PROXIMITY)
|
|
|
|
FireDOMProximityEvent(target, x, y, z);
|
2012-05-02 09:43:45 -07:00
|
|
|
else if (type == nsIDeviceSensorData::TYPE_LIGHT)
|
|
|
|
FireDOMLightEvent(target, x);
|
|
|
|
|
2011-06-19 22:36:17 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-02 09:43:45 -07:00
|
|
|
void
|
|
|
|
nsDeviceSensors::FireDOMLightEvent(nsIDOMEventTarget *aTarget,
|
|
|
|
double aValue)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMEvent> event;
|
|
|
|
NS_NewDOMDeviceLightEvent(getter_AddRefs(event), nsnull, nsnull);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMDeviceLightEvent> oe = do_QueryInterface(event);
|
|
|
|
oe->InitDeviceLightEvent(NS_LITERAL_STRING("devicelight"),
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
aValue);
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
event->SetTrusted(true);
|
2012-05-02 09:43:45 -07:00
|
|
|
|
|
|
|
bool defaultActionEnabled;
|
|
|
|
aTarget->DispatchEvent(event, &defaultActionEnabled);
|
|
|
|
}
|
|
|
|
|
2012-05-02 09:43:45 -07:00
|
|
|
void
|
|
|
|
nsDeviceSensors::FireDOMProximityEvent(nsIDOMEventTarget *aTarget,
|
|
|
|
double aValue,
|
|
|
|
double aMin,
|
|
|
|
double aMax)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMEvent> event;
|
|
|
|
NS_NewDOMDeviceProximityEvent(getter_AddRefs(event), nsnull, nsnull);
|
|
|
|
nsCOMPtr<nsIDOMDeviceProximityEvent> oe = do_QueryInterface(event);
|
|
|
|
|
|
|
|
oe->InitDeviceProximityEvent(NS_LITERAL_STRING("deviceproximity"),
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
aValue,
|
|
|
|
aMin,
|
|
|
|
aMax);
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
event->SetTrusted(true);
|
|
|
|
|
2012-05-02 09:43:45 -07:00
|
|
|
bool defaultActionEnabled;
|
|
|
|
aTarget->DispatchEvent(event, &defaultActionEnabled);
|
2012-05-16 13:27:54 -07:00
|
|
|
|
|
|
|
// Some proximity sensors only support a binary near or
|
|
|
|
// far measurement. In this case, the sensor should report
|
|
|
|
// its maximum range value in the far state and a lesser
|
|
|
|
// value in the near state.
|
|
|
|
|
|
|
|
bool near = (aValue < aMax);
|
|
|
|
if (mIsUserProximityNear != near) {
|
|
|
|
mIsUserProximityNear = near;
|
|
|
|
FireDOMUserProximityEvent(aTarget, mIsUserProximityNear);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsDeviceSensors::FireDOMUserProximityEvent(nsIDOMEventTarget *aTarget, bool aNear)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMEvent> event;
|
|
|
|
NS_NewDOMUserProximityEvent(getter_AddRefs(event), nsnull, nsnull);
|
|
|
|
nsCOMPtr<nsIDOMUserProximityEvent> pe = do_QueryInterface(event);
|
|
|
|
|
|
|
|
pe->InitUserProximityEvent(NS_LITERAL_STRING("userproximity"),
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
aNear);
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
event->SetTrusted(true);
|
|
|
|
|
2012-05-16 13:27:54 -07:00
|
|
|
bool defaultActionEnabled;
|
|
|
|
aTarget->DispatchEvent(event, &defaultActionEnabled);
|
2012-05-02 09:43:45 -07:00
|
|
|
}
|
|
|
|
|
2011-06-19 22:36:17 -07:00
|
|
|
void
|
2012-03-24 17:29:57 -07:00
|
|
|
nsDeviceSensors::FireDOMOrientationEvent(nsIDOMDocument *domdoc,
|
2012-05-16 13:27:54 -07:00
|
|
|
nsIDOMEventTarget *target,
|
|
|
|
double alpha,
|
|
|
|
double beta,
|
|
|
|
double gamma)
|
2011-06-19 22:36:17 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMEvent> event;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool defaultActionEnabled = true;
|
2011-06-19 22:36:17 -07:00
|
|
|
domdoc->CreateEvent(NS_LITERAL_STRING("DeviceOrientationEvent"), getter_AddRefs(event));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMDeviceOrientationEvent> oe = do_QueryInterface(event);
|
|
|
|
|
|
|
|
if (!oe) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
oe->InitDeviceOrientationEvent(NS_LITERAL_STRING("deviceorientation"),
|
2011-10-17 07:59:28 -07:00
|
|
|
true,
|
|
|
|
false,
|
2011-06-19 22:36:17 -07:00
|
|
|
alpha,
|
|
|
|
beta,
|
|
|
|
gamma,
|
2011-10-17 07:59:28 -07:00
|
|
|
true);
|
2011-06-19 22:36:17 -07:00
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
event->SetTrusted(true);
|
2011-06-19 22:36:17 -07:00
|
|
|
|
|
|
|
target->DispatchEvent(event, &defaultActionEnabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2012-03-24 17:29:57 -07:00
|
|
|
nsDeviceSensors::FireDOMMotionEvent(nsIDOMDocument *domdoc,
|
2011-06-19 22:36:17 -07:00
|
|
|
nsIDOMEventTarget *target,
|
2012-03-13 16:57:51 -07:00
|
|
|
PRUint32 type,
|
2011-06-19 22:36:17 -07:00
|
|
|
double x,
|
|
|
|
double y,
|
|
|
|
double z) {
|
2012-03-09 10:40:43 -08:00
|
|
|
// Attempt to coalesce events
|
|
|
|
bool fireEvent = TimeStamp::Now() > mLastDOMMotionEventTime + TimeDuration::FromMilliseconds(DEFAULT_SENSOR_POLL);
|
2012-03-13 16:57:51 -07:00
|
|
|
|
|
|
|
switch (type) {
|
2012-03-24 17:29:57 -07:00
|
|
|
case nsIDeviceSensorData::TYPE_LINEAR_ACCELERATION:
|
2012-03-24 17:29:49 -07:00
|
|
|
mLastAcceleration = new nsDOMDeviceAcceleration(x, y, z);
|
|
|
|
break;
|
2012-03-24 17:29:57 -07:00
|
|
|
case nsIDeviceSensorData::TYPE_ACCELERATION:
|
2012-03-24 17:29:49 -07:00
|
|
|
mLastAccelerationIncluduingGravity = new nsDOMDeviceAcceleration(x, y, z);
|
|
|
|
break;
|
2012-03-24 17:29:57 -07:00
|
|
|
case nsIDeviceSensorData::TYPE_GYROSCOPE:
|
2012-03-24 17:29:49 -07:00
|
|
|
mLastRotationRate = new nsDOMDeviceRotationRate(x, y, z);
|
|
|
|
break;
|
2012-03-13 16:57:51 -07:00
|
|
|
}
|
|
|
|
|
2012-03-09 10:40:43 -08:00
|
|
|
if (!fireEvent && (!mLastAcceleration || !mLastAccelerationIncluduingGravity || !mLastRotationRate)) {
|
2012-03-24 17:29:49 -07:00
|
|
|
return;
|
2012-03-09 10:40:43 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMEvent> event;
|
|
|
|
domdoc->CreateEvent(NS_LITERAL_STRING("DeviceMotionEvent"), getter_AddRefs(event));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMDeviceMotionEvent> me = do_QueryInterface(event);
|
|
|
|
|
2012-03-24 17:29:49 -07:00
|
|
|
if (!me)
|
2012-03-09 10:40:43 -08:00
|
|
|
return;
|
2011-06-19 22:36:17 -07:00
|
|
|
|
|
|
|
me->InitDeviceMotionEvent(NS_LITERAL_STRING("devicemotion"),
|
2011-10-17 07:59:28 -07:00
|
|
|
true,
|
|
|
|
false,
|
2012-03-09 10:40:43 -08:00
|
|
|
mLastAcceleration,
|
|
|
|
mLastAccelerationIncluduingGravity,
|
|
|
|
mLastRotationRate,
|
2012-03-13 16:57:09 -07:00
|
|
|
DEFAULT_SENSOR_POLL);
|
2011-06-19 22:36:17 -07:00
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
event->SetTrusted(true);
|
2012-03-24 17:29:49 -07:00
|
|
|
|
2012-03-09 10:40:43 -08:00
|
|
|
bool defaultActionEnabled = true;
|
2011-06-19 22:36:17 -07:00
|
|
|
target->DispatchEvent(event, &defaultActionEnabled);
|
2012-03-09 10:40:43 -08:00
|
|
|
|
|
|
|
mLastRotationRate = nsnull;
|
|
|
|
mLastAccelerationIncluduingGravity = nsnull;
|
|
|
|
mLastAcceleration = nsnull;
|
|
|
|
mLastDOMMotionEventTime = TimeStamp::Now();
|
2012-03-20 23:36:17 -07:00
|
|
|
}
|