| 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/display/types/display_constants.h" | 10 #include "ui/display/types/display_constants.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 } | 144 } |
| 145 | 145 |
| 146 const std::vector<InputDevice>& DeviceDataManager::GetMouseDevices() const { | 146 const std::vector<InputDevice>& DeviceDataManager::GetMouseDevices() const { |
| 147 return mouse_devices_; | 147 return mouse_devices_; |
| 148 } | 148 } |
| 149 | 149 |
| 150 const std::vector<InputDevice>& DeviceDataManager::GetTouchpadDevices() const { | 150 const std::vector<InputDevice>& DeviceDataManager::GetTouchpadDevices() const { |
| 151 return touchpad_devices_; | 151 return touchpad_devices_; |
| 152 } | 152 } |
| 153 | 153 |
| 154 const std::vector<InputDevice>& DeviceDataManager::GetGamepadDevices() const { |
| 155 return gamepad_devices_; |
| 156 } |
| 157 |
| 154 bool DeviceDataManager::AreDeviceListsComplete() const { | 158 bool DeviceDataManager::AreDeviceListsComplete() const { |
| 155 return device_lists_complete_; | 159 return device_lists_complete_; |
| 156 } | 160 } |
| 157 | 161 |
| 158 int64_t DeviceDataManager::GetTargetDisplayForTouchDevice( | 162 int64_t DeviceDataManager::GetTargetDisplayForTouchDevice( |
| 159 int touch_device_id) const { | 163 int touch_device_id) const { |
| 160 if (IsTouchDeviceIdValid(touch_device_id)) | 164 if (IsTouchDeviceIdValid(touch_device_id)) |
| 161 return touch_map_[touch_device_id].target_display; | 165 return touch_map_[touch_device_id].target_display; |
| 162 return display::kInvalidDisplayId; | 166 return display::kInvalidDisplayId; |
| 163 } | 167 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 std::equal(devices.begin(), | 211 std::equal(devices.begin(), |
| 208 devices.end(), | 212 devices.end(), |
| 209 touchpad_devices_.begin(), | 213 touchpad_devices_.begin(), |
| 210 InputDeviceEquals)) { | 214 InputDeviceEquals)) { |
| 211 return; | 215 return; |
| 212 } | 216 } |
| 213 touchpad_devices_ = devices; | 217 touchpad_devices_ = devices; |
| 214 NotifyObserversTouchpadDeviceConfigurationChanged(); | 218 NotifyObserversTouchpadDeviceConfigurationChanged(); |
| 215 } | 219 } |
| 216 | 220 |
| 221 void DeviceDataManager::OnGamepadDevicesUpdated( |
| 222 const std::vector<InputDevice>& devices) { |
| 223 if (devices.size() == gamepad_devices_.size() && |
| 224 std::equal(devices.begin(), devices.end(), gamepad_devices_.begin(), |
| 225 InputDeviceEquals)) { |
| 226 return; |
| 227 } |
| 228 gamepad_devices_ = devices; |
| 229 NotifyObserversGamepadDeviceConfigurationChanged(); |
| 230 } |
| 231 |
| 217 void DeviceDataManager::OnDeviceListsComplete() { | 232 void DeviceDataManager::OnDeviceListsComplete() { |
| 218 if (!device_lists_complete_) { | 233 if (!device_lists_complete_) { |
| 219 device_lists_complete_ = true; | 234 device_lists_complete_ = true; |
| 220 NotifyObserversDeviceListsComplete(); | 235 NotifyObserversDeviceListsComplete(); |
| 221 } | 236 } |
| 222 } | 237 } |
| 223 | 238 |
| 224 void DeviceDataManager::OnStylusStateChanged(StylusState state) { | 239 void DeviceDataManager::OnStylusStateChanged(StylusState state) { |
| 225 NotifyObserversStylusStateChanged(state); | 240 NotifyObserversStylusStateChanged(state); |
| 226 } | 241 } |
| 227 | 242 |
| 228 NOTIFY_OBSERVERS(NotifyObserversTouchscreenDeviceConfigurationChanged(), | 243 NOTIFY_OBSERVERS(NotifyObserversTouchscreenDeviceConfigurationChanged(), |
| 229 OnTouchscreenDeviceConfigurationChanged()); | 244 OnTouchscreenDeviceConfigurationChanged()); |
| 230 | 245 |
| 231 NOTIFY_OBSERVERS(NotifyObserversKeyboardDeviceConfigurationChanged(), | 246 NOTIFY_OBSERVERS(NotifyObserversKeyboardDeviceConfigurationChanged(), |
| 232 OnKeyboardDeviceConfigurationChanged()); | 247 OnKeyboardDeviceConfigurationChanged()); |
| 233 | 248 |
| 234 NOTIFY_OBSERVERS(NotifyObserversMouseDeviceConfigurationChanged(), | 249 NOTIFY_OBSERVERS(NotifyObserversMouseDeviceConfigurationChanged(), |
| 235 OnMouseDeviceConfigurationChanged()); | 250 OnMouseDeviceConfigurationChanged()); |
| 236 | 251 |
| 237 NOTIFY_OBSERVERS(NotifyObserversTouchpadDeviceConfigurationChanged(), | 252 NOTIFY_OBSERVERS(NotifyObserversTouchpadDeviceConfigurationChanged(), |
| 238 OnTouchpadDeviceConfigurationChanged()); | 253 OnTouchpadDeviceConfigurationChanged()); |
| 239 | 254 |
| 255 NOTIFY_OBSERVERS(NotifyObserversGamepadDeviceConfigurationChanged(), |
| 256 OnGamepadDeviceConfigurationChanged()); |
| 257 |
| 240 NOTIFY_OBSERVERS(NotifyObserversDeviceListsComplete(), OnDeviceListsComplete()); | 258 NOTIFY_OBSERVERS(NotifyObserversDeviceListsComplete(), OnDeviceListsComplete()); |
| 241 | 259 |
| 242 NOTIFY_OBSERVERS(NotifyObserversStylusStateChanged(StylusState state), | 260 NOTIFY_OBSERVERS(NotifyObserversStylusStateChanged(StylusState state), |
| 243 OnStylusStateChanged(state)); | 261 OnStylusStateChanged(state)); |
| 244 | 262 |
| 245 void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) { | 263 void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) { |
| 246 observers_.AddObserver(observer); | 264 observers_.AddObserver(observer); |
| 247 } | 265 } |
| 248 | 266 |
| 249 void DeviceDataManager::RemoveObserver(InputDeviceEventObserver* observer) { | 267 void DeviceDataManager::RemoveObserver(InputDeviceEventObserver* observer) { |
| 250 observers_.RemoveObserver(observer); | 268 observers_.RemoveObserver(observer); |
| 251 } | 269 } |
| 252 | 270 |
| 253 void DeviceDataManager::SetTouchscreensEnabled(bool enabled) { | 271 void DeviceDataManager::SetTouchscreensEnabled(bool enabled) { |
| 254 touch_screens_enabled_ = enabled; | 272 touch_screens_enabled_ = enabled; |
| 255 } | 273 } |
| 256 | 274 |
| 257 bool DeviceDataManager::AreTouchscreensEnabled() const { | 275 bool DeviceDataManager::AreTouchscreensEnabled() const { |
| 258 return touch_screens_enabled_; | 276 return touch_screens_enabled_; |
| 259 } | 277 } |
| 260 | 278 |
| 261 } // namespace ui | 279 } // namespace ui |
| OLD | NEW |