зеркало из https://github.com/mozilla/pjs.git
Bug 697641, part 4: Pass sensor events from Android to Gecko. r=cjones
This commit is contained in:
Родитель
3c5cd3c1e0
Коммит
aa4252fb48
|
@ -79,6 +79,7 @@ public class GeckoEvent {
|
||||||
public static final int VIEWPORT = 20;
|
public static final int VIEWPORT = 20;
|
||||||
public static final int VISITED = 21;
|
public static final int VISITED = 21;
|
||||||
public static final int NETWORK_CHANGED = 22;
|
public static final int NETWORK_CHANGED = 22;
|
||||||
|
public static final int PROXIMITY_EVENT = 23;
|
||||||
|
|
||||||
public static final int IME_COMPOSITION_END = 0;
|
public static final int IME_COMPOSITION_END = 0;
|
||||||
public static final int IME_COMPOSITION_BEGIN = 1;
|
public static final int IME_COMPOSITION_BEGIN = 1;
|
||||||
|
@ -111,6 +112,7 @@ public class GeckoEvent {
|
||||||
public Rect mRect;
|
public Rect mRect;
|
||||||
public double mX, mY, mZ;
|
public double mX, mY, mZ;
|
||||||
public double mAlpha, mBeta, mGamma;
|
public double mAlpha, mBeta, mGamma;
|
||||||
|
public double mDistance;
|
||||||
|
|
||||||
public int mMetaState, mFlags;
|
public int mMetaState, mFlags;
|
||||||
public int mKeyCode, mUnicodeChar;
|
public int mKeyCode, mUnicodeChar;
|
||||||
|
@ -223,19 +225,30 @@ public class GeckoEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeckoEvent(SensorEvent s) {
|
public GeckoEvent(SensorEvent s) {
|
||||||
|
int sensor_type = s.sensor.getType();
|
||||||
|
|
||||||
if (s.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
|
switch(sensor_type) {
|
||||||
|
case Sensor.TYPE_ACCELEROMETER:
|
||||||
mType = ACCELERATION_EVENT;
|
mType = ACCELERATION_EVENT;
|
||||||
mX = s.values[0];
|
mX = s.values[0];
|
||||||
mY = s.values[1];
|
mY = s.values[1];
|
||||||
mZ = s.values[2];
|
mZ = s.values[2];
|
||||||
}
|
break;
|
||||||
else {
|
|
||||||
|
case Sensor.TYPE_ORIENTATION:
|
||||||
mType = ORIENTATION_EVENT;
|
mType = ORIENTATION_EVENT;
|
||||||
mAlpha = -s.values[0];
|
mAlpha = -s.values[0];
|
||||||
mBeta = -s.values[1];
|
mBeta = -s.values[1];
|
||||||
mGamma = -s.values[2];
|
mGamma = -s.values[2];
|
||||||
Log.i("GeckoEvent", "SensorEvent type = " + s.sensor.getType() + " " + s.sensor.getName() + " " + mAlpha + " " + mBeta + " " + mGamma );
|
Log.i("GeckoEvent", "SensorEvent type = " + s.sensor.getType() + " " + s.sensor.getName() + " " + mAlpha + " " + mBeta + " " + mGamma );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Sensor.TYPE_PROXIMITY:
|
||||||
|
mType = PROXIMITY_EVENT;
|
||||||
|
mDistance = s.values[0];
|
||||||
|
Log.i("GeckoEvent", "SensorEvent type = " + s.sensor.getType() +
|
||||||
|
" " + s.sensor.getName() + " " + mDistance);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ jfieldID AndroidGeckoEvent::jGammaField = 0;
|
||||||
jfieldID AndroidGeckoEvent::jXField = 0;
|
jfieldID AndroidGeckoEvent::jXField = 0;
|
||||||
jfieldID AndroidGeckoEvent::jYField = 0;
|
jfieldID AndroidGeckoEvent::jYField = 0;
|
||||||
jfieldID AndroidGeckoEvent::jZField = 0;
|
jfieldID AndroidGeckoEvent::jZField = 0;
|
||||||
|
jfieldID AndroidGeckoEvent::jDistanceField = 0;
|
||||||
jfieldID AndroidGeckoEvent::jRectField = 0;
|
jfieldID AndroidGeckoEvent::jRectField = 0;
|
||||||
jfieldID AndroidGeckoEvent::jNativeWindowField = 0;
|
jfieldID AndroidGeckoEvent::jNativeWindowField = 0;
|
||||||
|
|
||||||
|
@ -168,6 +169,7 @@ AndroidGeckoEvent::InitGeckoEventClass(JNIEnv *jEnv)
|
||||||
jXField = getField("mX", "D");
|
jXField = getField("mX", "D");
|
||||||
jYField = getField("mY", "D");
|
jYField = getField("mY", "D");
|
||||||
jZField = getField("mZ", "D");
|
jZField = getField("mZ", "D");
|
||||||
|
jDistanceField = getField("mDistance", "D");
|
||||||
jRectField = getField("mRect", "Landroid/graphics/Rect;");
|
jRectField = getField("mRect", "Landroid/graphics/Rect;");
|
||||||
|
|
||||||
jCharactersField = getField("mCharacters", "Ljava/lang/String;");
|
jCharactersField = getField("mCharacters", "Ljava/lang/String;");
|
||||||
|
@ -540,6 +542,11 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case PROXIMITY_EVENT: {
|
||||||
|
mDistance = jenv->GetDoubleField(jobj, jDistanceField);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -443,6 +443,7 @@ public:
|
||||||
double X() { return mX; }
|
double X() { return mX; }
|
||||||
double Y() { return mY; }
|
double Y() { return mY; }
|
||||||
double Z() { return mZ; }
|
double Z() { return mZ; }
|
||||||
|
double Distance() { return mDistance; }
|
||||||
const nsIntRect& Rect() { return mRect; }
|
const nsIntRect& Rect() { return mRect; }
|
||||||
nsAString& Characters() { return mCharacters; }
|
nsAString& Characters() { return mCharacters; }
|
||||||
nsAString& CharactersExtra() { return mCharactersExtra; }
|
nsAString& CharactersExtra() { return mCharactersExtra; }
|
||||||
|
@ -479,6 +480,7 @@ protected:
|
||||||
int mRangeForeColor, mRangeBackColor;
|
int mRangeForeColor, mRangeBackColor;
|
||||||
double mAlpha, mBeta, mGamma;
|
double mAlpha, mBeta, mGamma;
|
||||||
double mX, mY, mZ;
|
double mX, mY, mZ;
|
||||||
|
double mDistance;
|
||||||
int mPointerIndex;
|
int mPointerIndex;
|
||||||
nsString mCharacters, mCharactersExtra;
|
nsString mCharacters, mCharactersExtra;
|
||||||
nsRefPtr<nsGeoPosition> mGeoPosition;
|
nsRefPtr<nsGeoPosition> mGeoPosition;
|
||||||
|
@ -517,6 +519,7 @@ protected:
|
||||||
static jfieldID jXField;
|
static jfieldID jXField;
|
||||||
static jfieldID jYField;
|
static jfieldID jYField;
|
||||||
static jfieldID jZField;
|
static jfieldID jZField;
|
||||||
|
static jfieldID jDistanceField;
|
||||||
static jfieldID jRectField;
|
static jfieldID jRectField;
|
||||||
static jfieldID jNativeWindowField;
|
static jfieldID jNativeWindowField;
|
||||||
|
|
||||||
|
@ -563,6 +566,7 @@ public:
|
||||||
VIEWPORT = 20,
|
VIEWPORT = 20,
|
||||||
VISITED = 21,
|
VISITED = 21,
|
||||||
NETWORK_CHANGED = 22,
|
NETWORK_CHANGED = 22,
|
||||||
|
PROXIMITY_EVENT = 23,
|
||||||
dummy_java_enum_list_end
|
dummy_java_enum_list_end
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,10 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
// Make sure the order of included headers
|
||||||
|
#include "base/basictypes.h"
|
||||||
|
#include "nspr/prtypes.h"
|
||||||
|
|
||||||
#include "mozilla/Hal.h"
|
#include "mozilla/Hal.h"
|
||||||
#include "nsAppShell.h"
|
#include "nsAppShell.h"
|
||||||
#include "nsWindow.h"
|
#include "nsWindow.h"
|
||||||
|
@ -48,6 +52,7 @@
|
||||||
#include "mozilla/Services.h"
|
#include "mozilla/Services.h"
|
||||||
#include "mozilla/unused.h"
|
#include "mozilla/unused.h"
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
|
#include "mozilla/Hal.h"
|
||||||
#include "prenv.h"
|
#include "prenv.h"
|
||||||
|
|
||||||
#include "AndroidBridge.h"
|
#include "AndroidBridge.h"
|
||||||
|
@ -355,6 +360,15 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case AndroidGeckoEvent::PROXIMITY_EVENT: {
|
||||||
|
InfallibleTArray<float> values;
|
||||||
|
values.AppendElement(curEvent->Distance());
|
||||||
|
|
||||||
|
hal::SensorData sdata(hal::SENSOR_PROXIMITY, PR_Now(), values);
|
||||||
|
hal::NotifySensorChange(sdata);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case AndroidGeckoEvent::ACTIVITY_STOPPING: {
|
case AndroidGeckoEvent::ACTIVITY_STOPPING: {
|
||||||
nsCOMPtr<nsIObserverService> obsServ =
|
nsCOMPtr<nsIObserverService> obsServ =
|
||||||
mozilla::services::GetObserverService();
|
mozilla::services::GetObserverService();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче