Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(937)

Unified Diff: content/browser/renderer_host/input/motion_event_android.cc

Issue 755403006: Added experimental Touch.tilt, Touch.tiltDirection support for Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused code (event_sender.cc) Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/motion_event_android.cc
diff --git a/content/browser/renderer_host/input/motion_event_android.cc b/content/browser/renderer_host/input/motion_event_android.cc
index 3f18f95561b3d650ccc3b3d36bd040f6f12f587f..c152d413a0ca5189cb32e6ce608766faea652a65 100644
--- a/content/browser/renderer_host/input/motion_event_android.cc
+++ b/content/browser/renderer_host/input/motion_event_android.cc
@@ -8,11 +8,13 @@
#include "base/android/jni_android.h"
#include "base/float_util.h"
+#include "jni/MotionEventUtil_jni.h"
#include "jni/MotionEvent_jni.h"
#include "ui/events/event_constants.h"
using base::android::AttachCurrentThread;
using namespace JNI_MotionEvent;
+using namespace JNI_MotionEventUtil;
namespace content {
namespace {
@@ -255,6 +257,22 @@ float MotionEventAndroid::GetOrientation(size_t pointer_index) const {
AttachCurrentThread(), event_.obj(), pointer_index));
}
+float MotionEventAndroid::GetTilt(size_t pointer_index) const {
+ if (!event_.obj())
+ return std::numeric_limits<float>::quiet_NaN();
+
+ return Java_MotionEventUtil_getAxisValueOrNaN(
+ AttachCurrentThread(), event_.obj(), AXIS_TILT, pointer_index);
+}
+
+float MotionEventAndroid::GetTiltDirection(size_t pointer_index) const {
+ if (!event_.obj())
+ return std::numeric_limits<float>::quiet_NaN();
+
+ return Java_MotionEventUtil_getAxisValueOrNaN(
+ AttachCurrentThread(), event_.obj(), AXIS_ORIENTATION, pointer_index);
+}
+
float MotionEventAndroid::GetPressure(size_t pointer_index) const {
DCHECK_LT(pointer_index, cached_pointer_count_);
// Note that this early return is a special case exercised only in testing, as
@@ -335,7 +353,8 @@ MotionEventAndroid::CachedPointer MotionEventAndroid::FromAndroidPointer(
// static
bool MotionEventAndroid::RegisterMotionEventAndroid(JNIEnv* env) {
- return JNI_MotionEvent::RegisterNativesImpl(env);
+ return JNI_MotionEvent::RegisterNativesImpl(env)
+ && JNI_MotionEventUtil::RegisterNativesImpl(env);
}
} // namespace content
« no previous file with comments | « content/browser/renderer_host/input/motion_event_android.h ('k') | content/browser/renderer_host/input/motion_event_web.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698