15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef PPAPI_CPP_TOUCH_POINT_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PPAPI_CPP_TOUCH_POINT_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_input_event.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/cpp/input_event.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/cpp/point.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace pp {
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// Wrapper class for PP_TouchPoint.
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TouchPoint {
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  TouchPoint() : touch_point_(PP_MakeTouchPoint()) {}
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  TouchPoint(const PP_TouchPoint& point) : touch_point_(point) {}
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// @return The identifier for this TouchPoint. This corresponds to the order
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// in which the points were pressed. For example, the first point to be
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// pressed has an id of 0, the second has an id of 1, and so on. An id can be
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// reused when a touch point is released.  For example, if two fingers are
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// down, with id 0 and 1, and finger 0 releases, the next finger to be
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// pressed can be assigned to id 0.
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  uint32_t id() const { return touch_point_.id; }
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// @return The x-y coordinates of this TouchPoint, in DOM coordinate space.
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FloatPoint position() const {
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return pp::FloatPoint(touch_point_.position);
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// @return The elliptical radii, in screen pixels, in the x and y direction
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// of this TouchPoint.
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FloatPoint radii() const { return pp::FloatPoint(touch_point_.radius); }
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// @return The angle of rotation of the elliptical model of this TouchPoint
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// from the y-axis.
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  float rotation_angle() const { return touch_point_.rotation_angle; }
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// @return The pressure applied to this TouchPoint.  This is typically a
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// value between 0 and 1, with 0 indicating no pressure and 1 indicating
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// some maximum pressure, but scaling differs depending on the hardware and
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// the value is not guaranteed to stay within that range.
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  float pressure() const { return touch_point_.pressure; }
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PP_TouchPoint touch_point_;
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace pp
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  /* PPAPI_CPP_TOUCH_POINT_H_ */
55