mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +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 (typeof successCallback == "function") {
|
||||||
if(this.lastAcceleration)
|
if(this.lastAcceleration)
|
||||||
successCallback(accel);
|
successCallback(accel);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
watchAcceleration(this.gotCurrentAcceleration, this.fail);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Accelerometer.prototype.gotAccel = function(key, x, y, z)
|
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.x = x;
|
||||||
a.y = y;
|
a.y = y;
|
||||||
a.x = z;
|
a.x = z;
|
||||||
a.win = accelListener[key].win;
|
a.win = accelListeners[key].win;
|
||||||
a.fail = accelListener[key].fail;
|
a.fail = accelListeners[key].fail;
|
||||||
this.timestamp = new Date().getTime();
|
this.timestamp = new Date().getTime();
|
||||||
this.lastAcceleration = a;
|
this.lastAcceleration = a;
|
||||||
accelListener[key] = a;
|
accelListeners[key] = a;
|
||||||
if (typeof a.win == "function") {
|
if (typeof a.win == "function") {
|
||||||
a.win(a);
|
a.win(a);
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ public class AccelBroker {
|
|||||||
public String start(int freq, String key)
|
public String start(int freq, String key)
|
||||||
{
|
{
|
||||||
AccelListener listener = new AccelListener(key, freq, mCtx, mAppView);
|
AccelListener listener = new AccelListener(key, freq, mCtx, mAppView);
|
||||||
|
listener.start(freq);
|
||||||
accelListeners.put(key, listener);
|
accelListeners.put(key, listener);
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class AccelListener implements SensorEventListener{
|
|||||||
if (list.size() > 0)
|
if (list.size() > 0)
|
||||||
{
|
{
|
||||||
this.mSensor = list.get(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
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user