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

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

Issue 1147083005: Separate motion event touch geometry orientation from stylus orientation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Aura Created 5 years, 7 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 8d36c812cc0084dc9ba3d5cb2d9fa0459ff23832..15a2aca39c547d4dac1f3f12742db61450dcaf57 100644
--- a/content/browser/renderer_host/input/motion_event_android.cc
+++ b/content/browser/renderer_host/input/motion_event_android.cc
@@ -258,6 +258,21 @@ float MotionEventAndroid::GetOrientation(size_t pointer_index) const {
AttachCurrentThread(), event_.obj(), pointer_index));
}
+float MotionEventAndroid::GetTouchOrientation(size_t pointer_index) const {
+ float orientation = GetOrientation(pointer_index);
+ // The meaning of the motion event orientation is overloaded on Android.
+ // * For a touch screen or pad, it's the orientation of the touch major axis
+ // clockwise from vertical. The value lies in [-PI/1, PI/2].
+ // * For a stylus, it indicates the direction in which the stylus is pointing
+ // clockwise from top. The value lies in [-PI, PI].
+ // Map to touch major axis orientation.
+ if (orientation <= -M_PI_2)
+ return orientation + M_PI;
+ if (orientation >= M_PI_2)
+ return orientation - M_PI;
+ return orientation;
+}
+
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

Powered by Google App Engine
This is Rietveld 408576698