| 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..30f141bebd71b4022fc17c7e995f4972b9e82588 100644
|
| --- a/content/browser/renderer_host/input/motion_event_web.cc
|
| +++ b/content/browser/renderer_host/input/motion_event_web.cc
|
| @@ -130,26 +130,62 @@ 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 && pointer.tiltX < 0) {
|
| + // Stylus is tilted to the left away from the user or straight
|
| + // to the left thus the orientation should be within [pi/2,pi).
|
| + orientation_rad += static_cast<float>(M_PI_2);
|
| + } else if (pointer.tiltY < 0 && pointer.tiltX >= 0) {
|
| + // Stylus is tilted to the right away from the user or straight away
|
| + // from the user thus the orientation should be within [-pi,-pi/2).
|
| + orientation_rad -= static_cast<float>(M_PI);
|
| + } else if (pointer.tiltY >= 0 && pointer.tiltX > 0) {
|
| + // Stylus is tilted to the right towards the user or straight
|
| + // to the right thus the orientation should be within [-pi/2,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.
|
| - rotation_angle_rad -= (float) M_PI_2;
|
| + // always seems to be set to zero) unchanged.
|
| + 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 *
|
|
|