Index: content/browser/renderer_host/input/motion_event_web.cc |
diff --git a/content/browser/renderer_host/input/motion_event_web.cc b/content/browser/renderer_host/input/motion_event_web.cc |
index ddc30372cdad50a5373227cd1bd12117db61d99e..f5866de78a23077b025c262850b61b6a46559307 100644 |
--- a/content/browser/renderer_host/input/motion_event_web.cc |
+++ b/content/browser/renderer_host/input/motion_event_web.cc |
@@ -130,26 +130,58 @@ float MotionEventWeb::GetTouchMinor(size_t pointer_index) const { |
float MotionEventWeb::GetOrientation(size_t pointer_index) const { |
DCHECK_LT(pointer_index, GetPointerCount()); |
- float rotation_angle_rad = event_.touches[pointer_index].rotationAngle |
+ float orientation_rad = event_.touches[pointer_index].rotationAngle |
* M_PI / 180.f; |
- DCHECK(0 <= rotation_angle_rad && rotation_angle_rad <= M_PI_2) |
+ DCHECK(0 <= orientation_rad && orientation_rad <= M_PI_2) |
<< "Unexpected touch rotation angle"; |
- if (event_.touches[pointer_index].radiusX |
- > event_.touches[pointer_index].radiusY) { |
+ if (GetToolType(pointer_index) == TOOL_TYPE_STYLUS) { |
+ const WebPointerProperties& pointer = event_.touches[pointer_index]; |
+ |
+ if (pointer.tiltY < 0) { |
tdresser
2015/11/02 14:44:07
I think this would be easier to read if you explic
e_hakkinen
2015/11/02 16:27:16
Yes, especially because the grouping was not actua
|
+ if (pointer.tiltX < 0) |
+ orientation_rad += static_cast<float>(M_PI_2); |
+ else |
+ orientation_rad -= static_cast<float>(M_PI); |
+ } else { |
+ if (pointer.tiltX > 0) |
+ orientation_rad -= static_cast<float>(M_PI_2); |
+ } |
+ } else if (event_.touches[pointer_index].radiusX |
+ > event_.touches[pointer_index].radiusY) { |
// The case radiusX == radiusY is omitted from here on purpose: for circles, |
// we want to pass the angle (which could be any value in such cases but |
// always seem to be set to zero) unchanged. |
tdresser
2015/11/02 14:44:07
While you're editing this, can you change:
"always
e_hakkinen
2015/11/02 16:27:16
Done.
|
- rotation_angle_rad -= (float) M_PI_2; |
+ orientation_rad -= static_cast<float>(M_PI_2); |
} |
- return rotation_angle_rad; |
+ return orientation_rad; |
} |
float MotionEventWeb::GetPressure(size_t pointer_index) const { |
return 0.f; |
} |
+float MotionEventWeb::GetTilt(size_t pointer_index) const { |
+ DCHECK_LT(pointer_index, GetPointerCount()); |
+ |
+ if (GetToolType(pointer_index) != TOOL_TYPE_STYLUS) |
+ return 0.f; |
+ |
+ const WebPointerProperties& pointer = event_.touches[pointer_index]; |
+ |
+ float tilt_x_r = sin(pointer.tiltX * M_PI / 180.f); |
+ float tilt_x_z = cos(pointer.tiltX * M_PI / 180.f); |
+ float tilt_y_r = sin(pointer.tiltY * M_PI / 180.f); |
+ float tilt_y_z = cos(pointer.tiltY * M_PI / 180.f); |
+ float r_x = tilt_x_r * tilt_y_z; |
+ float r_y = tilt_y_r * tilt_x_z; |
+ float r = sqrt(r_x * r_x + r_y * r_y); |
+ float z = tilt_x_z * tilt_y_z; |
+ |
+ return atan2(r, z); |
+} |
+ |
base::TimeTicks MotionEventWeb::GetEventTime() const { |
return base::TimeTicks() + |
base::TimeDelta::FromMicroseconds(event_.timeStampSeconds * |