OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PPAPI_CPP_TOUCH_POINT_H_ | 5 #ifndef PPAPI_CPP_TOUCH_POINT_H_ |
6 #define PPAPI_CPP_TOUCH_POINT_H_ | 6 #define PPAPI_CPP_TOUCH_POINT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "ppapi/c/ppb_input_event.h" | 10 #include "ppapi/c/ppb_input_event.h" |
11 #include "ppapi/cpp/input_event.h" | 11 #include "ppapi/cpp/input_event.h" |
12 #include "ppapi/cpp/point.h" | 12 #include "ppapi/cpp/point.h" |
13 | 13 |
14 namespace pp { | 14 namespace pp { |
15 | 15 |
16 /// Wrapper class for PP_TouchPoint. | 16 /// Wrapper class for PP_TouchPoint. |
17 class TouchPoint { | 17 class TouchPoint { |
18 public: | 18 public: |
19 TouchPoint() : touch_point_(PP_MakeTouchPoint()) {} | 19 TouchPoint() : touch_point_(PP_MakeTouchPoint()) {} |
20 | 20 |
21 TouchPoint(const PP_TouchPoint& point) : touch_point_(point) {} | 21 TouchPoint(const PP_TouchPoint& point) |
| 22 : touch_point_(point), tilt_(PP_MakeFloatPoint(0, 0)) {} |
| 23 |
| 24 TouchPoint(const PP_TouchPoint& point, const PP_FloatPoint& tilt) |
| 25 : touch_point_(point), tilt_(tilt) {} |
22 | 26 |
23 /// @return The identifier for this TouchPoint. This corresponds to the order | 27 /// @return The identifier for this TouchPoint. This corresponds to the order |
24 /// in which the points were pressed. For example, the first point to be | 28 /// in which the points were pressed. For example, the first point to be |
25 /// pressed has an id of 0, the second has an id of 1, and so on. An id can be | 29 /// pressed has an id of 0, the second has an id of 1, and so on. An id can be |
26 /// reused when a touch point is released. For example, if two fingers are | 30 /// reused when a touch point is released. For example, if two fingers are |
27 /// down, with id 0 and 1, and finger 0 releases, the next finger to be | 31 /// down, with id 0 and 1, and finger 0 releases, the next finger to be |
28 /// pressed can be assigned to id 0. | 32 /// pressed can be assigned to id 0. |
29 uint32_t id() const { return touch_point_.id; } | 33 uint32_t id() const { return touch_point_.id; } |
30 | 34 |
31 /// @return The x-y coordinates of this TouchPoint, in DOM coordinate space. | 35 /// @return The x-y coordinates of this TouchPoint, in DOM coordinate space. |
32 FloatPoint position() const { | 36 FloatPoint position() const { |
33 return pp::FloatPoint(touch_point_.position); | 37 return pp::FloatPoint(touch_point_.position); |
34 } | 38 } |
35 | 39 |
36 /// @return The elliptical radii, in screen pixels, in the x and y direction | 40 /// @return The elliptical radii, in screen pixels, in the x and y direction |
37 /// of this TouchPoint. | 41 /// of this TouchPoint. |
38 FloatPoint radii() const { return pp::FloatPoint(touch_point_.radius); } | 42 FloatPoint radii() const { return pp::FloatPoint(touch_point_.radius); } |
39 | 43 |
40 /// @return The angle of rotation of the elliptical model of this TouchPoint | 44 /// @return The angle of rotation of the elliptical model of this TouchPoint |
41 /// from the y-axis. | 45 /// from the y-axis. |
42 float rotation_angle() const { return touch_point_.rotation_angle; } | 46 float rotation_angle() const { return touch_point_.rotation_angle; } |
43 | 47 |
44 /// @return The pressure applied to this TouchPoint. This is typically a | 48 /// @return The pressure applied to this TouchPoint. This is typically a |
45 /// value between 0 and 1, with 0 indicating no pressure and 1 indicating | 49 /// value between 0 and 1, with 0 indicating no pressure and 1 indicating |
46 /// some maximum pressure, but scaling differs depending on the hardware and | 50 /// some maximum pressure, but scaling differs depending on the hardware and |
47 /// the value is not guaranteed to stay within that range. | 51 /// the value is not guaranteed to stay within that range. |
48 float pressure() const { return touch_point_.pressure; } | 52 float pressure() const { return touch_point_.pressure; } |
49 | 53 |
| 54 /// @return The tilt of this touchpoint. This is a float point. Values of x |
| 55 /// and y are between 0 and 90, with 0 indicating 0 degrees and 90 indicating |
| 56 // 90 degrees. |
| 57 PP_FloatPoint tilt() const { return tilt_; } |
| 58 |
50 private: | 59 private: |
51 PP_TouchPoint touch_point_; | 60 PP_TouchPoint touch_point_; |
| 61 PP_FloatPoint tilt_; |
52 }; | 62 }; |
53 | 63 |
54 } // namespace pp | 64 } // namespace pp |
55 | 65 |
56 #endif /* PPAPI_CPP_TOUCH_POINT_H_ */ | 66 #endif /* PPAPI_CPP_TOUCH_POINT_H_ */ |
OLD | NEW |