Chromium Code Reviews| Index: ui/events/blink/blink_event_util.cc |
| diff --git a/ui/events/blink/blink_event_util.cc b/ui/events/blink/blink_event_util.cc |
| index ce800817c74070e2e5776ca8334a1323ade9ecd8..adbe11b67eeedb44efd8c4260642d1a791c10c08 100644 |
| --- a/ui/events/blink/blink_event_util.cc |
| +++ b/ui/events/blink/blink_event_util.cc |
| @@ -119,21 +119,28 @@ WebTouchPoint CreateWebTouchPoint(const MotionEvent& event, |
| DCHECK_LE(minor_radius, major_radius); |
| DCHECK_IMPLIES(major_radius, minor_radius); |
| - float orientation_deg = event.GetOrientation(pointer_index) * 180.f / M_PI; |
| + float orientation_rad = event.GetOrientation(pointer_index); |
| + float orientation_deg = orientation_rad * 180.f / M_PI; |
| DCHECK_GE(major_radius, 0); |
| DCHECK_GE(minor_radius, 0); |
| DCHECK_GE(major_radius, minor_radius); |
| if (event.GetToolType(pointer_index) == MotionEvent::TOOL_TYPE_STYLUS) { |
| // Orientation lies in [-180, 180] for a stylus. Normalise to [-90, 90). |
| // Allow a small bound tolerance to account for floating point conversion. |
| - // TODO(e_hakkinen): crbug.com/493728: Pass also unaltered orientation |
| - // to touch in order not to lose quadrant information. |
| DCHECK_GT(orientation_deg, -180.01f); |
| DCHECK_LT(orientation_deg, 180.01f); |
| if (orientation_deg >= 90.f) |
| orientation_deg -= 180.f; |
| else if (orientation_deg < -90.f) |
| orientation_deg += 180.f; |
| + |
| + // A stylus points to a direction specified by orientation and tilts to |
|
jdduke (slow)
2015/08/12 17:00:13
Same here, I think we want some basic smoke test c
|
| + // the opposite direction. Coordinate system is left-handed. |
| + float tilt_rad = event.GetTilt(pointer_index); |
| + float r = sin(tilt_rad); |
| + float z = cos(tilt_rad); |
| + touch.tiltX = atan2(sin(-orientation_rad) * r, z) * 180.f / M_PI; |
| + touch.tiltY = atan2(cos(-orientation_rad) * r, z) * 180.f / M_PI; |
| } else { |
| // Orientation lies in [-90, 90] for a touch. Normalise to [-90, 90). |
| // Allow a small bound tolerance to account for floating point conversion. |
| @@ -141,6 +148,8 @@ WebTouchPoint CreateWebTouchPoint(const MotionEvent& event, |
| DCHECK_LT(orientation_deg, 90.01f); |
| if (orientation_deg >= 90.f) |
| orientation_deg -= 180.f; |
| + |
| + touch.tiltX = touch.tiltY = 0; |
| } |
| if (orientation_deg >= 0) { |
| // The case orientation_deg == 0 is handled here on purpose: although the |