| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "ui/events/devices/device_data_manager.h" | 5 #include "ui/events/devices/device_data_manager.h" |
| 6 | 6 |
| 7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ui/events/devices/input_device_event_observer.h" | 10 #include "ui/events/devices/input_device_event_observer.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 void DeviceDataManager::ClearTouchDeviceAssociations() { | 64 void DeviceDataManager::ClearTouchDeviceAssociations() { |
| 65 for (int i = 0; i < kMaxDeviceNum; i++) { | 65 for (int i = 0; i < kMaxDeviceNum; i++) { |
| 66 touch_device_transformer_map_[i] = gfx::Transform(); | 66 touch_device_transformer_map_[i] = gfx::Transform(); |
| 67 touch_device_to_target_display_map_[i] = gfx::Display::kInvalidDisplayID; | 67 touch_device_to_target_display_map_[i] = gfx::Display::kInvalidDisplayID; |
| 68 touch_radius_scale_map_[i] = 1.0; | 68 touch_radius_scale_map_[i] = 1.0; |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool DeviceDataManager::IsTouchDeviceIdValid( | 72 bool DeviceDataManager::IsTouchDeviceIdValid( |
| 73 unsigned int touch_device_id) const { | 73 int touch_device_id) const { |
| 74 return (touch_device_id > 0 && touch_device_id < kMaxDeviceNum); | 74 return (touch_device_id > 0 && touch_device_id < kMaxDeviceNum); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void DeviceDataManager::UpdateTouchInfoForDisplay( | 77 void DeviceDataManager::UpdateTouchInfoForDisplay( |
| 78 int64_t target_display_id, | 78 int64_t target_display_id, |
| 79 unsigned int touch_device_id, | 79 int touch_device_id, |
| 80 const gfx::Transform& touch_transformer) { | 80 const gfx::Transform& touch_transformer) { |
| 81 if (IsTouchDeviceIdValid(touch_device_id)) { | 81 if (IsTouchDeviceIdValid(touch_device_id)) { |
| 82 touch_device_to_target_display_map_[touch_device_id] = target_display_id; | 82 touch_device_to_target_display_map_[touch_device_id] = target_display_id; |
| 83 touch_device_transformer_map_[touch_device_id] = touch_transformer; | 83 touch_device_transformer_map_[touch_device_id] = touch_transformer; |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 void DeviceDataManager::UpdateTouchRadiusScale(unsigned int touch_device_id, | 87 void DeviceDataManager::UpdateTouchRadiusScale(int touch_device_id, |
| 88 double scale) { | 88 double scale) { |
| 89 if (IsTouchDeviceIdValid(touch_device_id)) | 89 if (IsTouchDeviceIdValid(touch_device_id)) |
| 90 touch_radius_scale_map_[touch_device_id] = scale; | 90 touch_radius_scale_map_[touch_device_id] = scale; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void DeviceDataManager::ApplyTouchRadiusScale(unsigned int touch_device_id, | 93 void DeviceDataManager::ApplyTouchRadiusScale(int touch_device_id, |
| 94 double* radius) { | 94 double* radius) { |
| 95 if (IsTouchDeviceIdValid(touch_device_id)) | 95 if (IsTouchDeviceIdValid(touch_device_id)) |
| 96 *radius = (*radius) * touch_radius_scale_map_[touch_device_id]; | 96 *radius = (*radius) * touch_radius_scale_map_[touch_device_id]; |
| 97 } | 97 } |
| 98 | 98 |
| 99 void DeviceDataManager::ApplyTouchTransformer(unsigned int touch_device_id, | 99 void DeviceDataManager::ApplyTouchTransformer(int touch_device_id, |
| 100 float* x, | 100 float* x, |
| 101 float* y) { | 101 float* y) { |
| 102 if (IsTouchDeviceIdValid(touch_device_id)) { | 102 if (IsTouchDeviceIdValid(touch_device_id)) { |
| 103 gfx::Point3F point(*x, *y, 0.0); | 103 gfx::Point3F point(*x, *y, 0.0); |
| 104 const gfx::Transform& trans = | 104 const gfx::Transform& trans = |
| 105 touch_device_transformer_map_[touch_device_id]; | 105 touch_device_transformer_map_[touch_device_id]; |
| 106 trans.TransformPoint(&point); | 106 trans.TransformPoint(&point); |
| 107 *x = point.x(); | 107 *x = point.x(); |
| 108 *y = point.y(); | 108 *y = point.y(); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 int64_t DeviceDataManager::GetTargetDisplayForTouchDevice( | 112 int64_t DeviceDataManager::GetTargetDisplayForTouchDevice( |
| 113 unsigned int touch_device_id) const { | 113 int touch_device_id) const { |
| 114 if (IsTouchDeviceIdValid(touch_device_id)) | 114 if (IsTouchDeviceIdValid(touch_device_id)) |
| 115 return touch_device_to_target_display_map_[touch_device_id]; | 115 return touch_device_to_target_display_map_[touch_device_id]; |
| 116 return gfx::Display::kInvalidDisplayID; | 116 return gfx::Display::kInvalidDisplayID; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void DeviceDataManager::OnTouchscreenDevicesUpdated( | 119 void DeviceDataManager::OnTouchscreenDevicesUpdated( |
| 120 const std::vector<TouchscreenDevice>& devices) { | 120 const std::vector<TouchscreenDevice>& devices) { |
| 121 if (devices.size() == touchscreen_devices_.size() && | 121 if (devices.size() == touchscreen_devices_.size() && |
| 122 std::equal(devices.begin(), | 122 std::equal(devices.begin(), |
| 123 devices.end(), | 123 devices.end(), |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 178 |
| 179 void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) { | 179 void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) { |
| 180 observers_.AddObserver(observer); | 180 observers_.AddObserver(observer); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void DeviceDataManager::RemoveObserver(InputDeviceEventObserver* observer) { | 183 void DeviceDataManager::RemoveObserver(InputDeviceEventObserver* observer) { |
| 184 observers_.RemoveObserver(observer); | 184 observers_.RemoveObserver(observer); |
| 185 } | 185 } |
| 186 | 186 |
| 187 } // namespace ui | 187 } // namespace ui |
| OLD | NEW |