OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_BASE_TOUCH_MULTI_TOUCH_DEVICE_H_ |
| 6 #define UI_BASE_TOUCH_MULTI_TOUCH_DEVICE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <map> |
| 10 #include <string> |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "ui/base/touch/axis.h" |
| 14 |
| 15 namespace ui { |
| 16 // Models a multi-touch capable device and its properties. |
| 17 class MultiTouchDevice { |
| 18 public: |
| 19 typedef std::map<Axis::Type, Axis> Axes; |
| 20 |
| 21 // Models different touch device types. |
| 22 enum Type { |
| 23 // A device with 1:1 mapping to screen coords, e.g., a touchscreen. |
| 24 // In contrast, an indirect touch device would require a coordinate |
| 25 // transformation to map touch coordinates to screen coordinates. |
| 26 DIRECT_TOUCH_DEVICE_TYPE, |
| 27 // Marks an indirect device with cursor movement dependent on touches. |
| 28 // Example: A trackpad. |
| 29 DEPENDENT_TOUCH_DEVICE_TYPE, |
| 30 // Marks an indirect device with cursor movement independent of touches. |
| 31 // Example: A mouse with an additional touch area. |
| 32 INDEPENDENT_TOUCH_DEVICE_TYPE, |
| 33 // Marks a device that provides a bounding-box of some touches. |
| 34 // In contrast, a full-multitouch device provides accurate locations |
| 35 // of individual touches. |
| 36 SEMI_MULTI_TOUCH_DEVICE_TYPE, |
| 37 // Marks the initial and unknown type of a device. |
| 38 UNKNOWN_TOUCH_DEVICE_TYPE |
| 39 }; |
| 40 |
| 41 // Initializes the object to a default, undefined state. |
| 42 MultiTouchDevice(); |
| 43 |
| 44 ~MultiTouchDevice(); |
| 45 |
| 46 // Compiler generated copy-c'tor and assignment operator are fine. |
| 47 |
| 48 // Returns the unique id of the device. |
| 49 int id() const { return id_; } |
| 50 // Adjusts the id of the device to id. |
| 51 void set_id(int id) { id_ = id; } |
| 52 |
| 53 // Returns the human-readable name of the device. |
| 54 const std::string & name() const { return name_; } |
| 55 // Adjusts the human-readable name of the device. |
| 56 void set_name(const std::string& name) { name_ = name; } |
| 57 |
| 58 // Returns the type of the device. |
| 59 Type type() const { return type_; } |
| 60 // Adjusts the type of the device. |
| 61 void set_type(Type type) { type_ = type; } |
| 62 |
| 63 // Returns the maximum number of touches that this device can |
| 64 // report simultaneously. |
| 65 uint32_t max_num_touches() const { return max_num_touches_; } |
| 66 // Adjusts the maximum number of touches that this device can |
| 67 // report simultaneously. |
| 68 void set_max_num_touches(uint32_t num) { max_num_touches_ = num; } |
| 69 |
| 70 // Returns the number of axes that this device supports. |
| 71 // Here, an axis models a property/measurement that is associated |
| 72 // with individual touches. |
| 73 uint32_t num_axes() const { return axes_.size(); } |
| 74 |
| 75 // Returns the map of axis objects supported by this device. |
| 76 const Axes & axes() const { return axes_; } |
| 77 // Adjusts the map of axis. |
| 78 void set_axes(const Axes & axes) { axes_ = axes; } |
| 79 |
| 80 // Returns the resolution of the window coordinates |
| 81 // of the device in the X axis |
| 82 float window_resolution_x() const { return window_resolution_x_; } |
| 83 // Adjusts the resolution of the window coordintaes |
| 84 // of the device in the X axis. |
| 85 void set_window_resolution_x(float res) { window_resolution_x_ = res; } |
| 86 |
| 87 // Returns the resolution of the window coordinates |
| 88 // of the device in the Y axis |
| 89 float window_resolution_y() const { return window_resolution_y_; } |
| 90 // Returns the resolution of the window coordinates |
| 91 // of the device in the Y axis |
| 92 void set_window_resolution_y(float res) { window_resolution_y_ = res; } |
| 93 |
| 94 private: |
| 95 int id_; |
| 96 std::string name_; |
| 97 Type type_; |
| 98 uint32_t max_num_touches_; |
| 99 Axes axes_; |
| 100 float window_resolution_x_; |
| 101 float window_resolution_y_; |
| 102 |
| 103 // REMARK(tvoss): Consider handling of devices to rely on shared ptr's. |
| 104 // A device might be considered unique and non-copyable and non-assignable |
| 105 // in the future. However, at the present moment, it is perfectly fine to |
| 106 // model the device as copyable and assignable as it only wraps up various |
| 107 // device properties. |
| 108 // DISALLOW_COPY_AND_ASSIGN(MultiTouchDevice); |
| 109 }; |
| 110 |
| 111 } // namespace ui |
| 112 |
| 113 #endif // UI_BASE_TOUCH_MULTI_TOUCH_DEVICE_H_ |
| 114 |
OLD | NEW |