mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-18 22:52:54 +08:00
Fixing up the accelerometer. Weird issue with where zero is
This commit is contained in:
parent
cd5788c3ce
commit
c1e628f44c
@ -38,21 +38,26 @@ Accelerometer.prototype.getCurrentAcceleration = function(successCallback, error
|
||||
if (typeof successCallback == "function") {
|
||||
if(this.lastAcceleration)
|
||||
successCallback(accel);
|
||||
else
|
||||
{
|
||||
watchAcceleration(this.gotCurrentAcceleration, this.fail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Accelerometer.prototype.gotAccel = function(key, x, y, z)
|
||||
{
|
||||
var a = Acceleration(x,y,z);
|
||||
console.log('we won');
|
||||
var a = new Acceleration(x,y,z);
|
||||
a.x = x;
|
||||
a.y = y;
|
||||
a.x = z;
|
||||
a.win = accelListener[key].win;
|
||||
a.fail = accelListener[key].fail;
|
||||
a.win = accelListeners[key].win;
|
||||
a.fail = accelListeners[key].fail;
|
||||
this.timestamp = new Date().getTime();
|
||||
this.lastAcceleration = a;
|
||||
accelListener[key] = a;
|
||||
accelListeners[key] = a;
|
||||
if (typeof a.win == "function") {
|
||||
a.win(a);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public class AccelBroker {
|
||||
public String start(int freq, String key)
|
||||
{
|
||||
AccelListener listener = new AccelListener(key, freq, mCtx, mAppView);
|
||||
listener.start(freq);
|
||||
accelListeners.put(key, listener);
|
||||
return key;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class AccelListener implements SensorEventListener{
|
||||
if (list.size() > 0)
|
||||
{
|
||||
this.mSensor = list.get(0);
|
||||
this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_NORMAL);
|
||||
this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_FASTEST);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user