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 #ifndef UI_EVENTS_DEVICES_DEVICE_DATA_MANAGER_H_ | 5 #ifndef UI_EVENTS_DEVICES_DEVICE_DATA_MANAGER_H_ |
6 #define UI_EVENTS_DEVICES_DEVICE_DATA_MANAGER_H_ | 6 #define UI_EVENTS_DEVICES_DEVICE_DATA_MANAGER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "ui/events/devices/device_hotplug_event_observer.h" | 15 #include "ui/events/devices/device_hotplug_event_observer.h" |
16 #include "ui/events/devices/events_devices_export.h" | 16 #include "ui/events/devices/events_devices_export.h" |
17 #include "ui/events/devices/keyboard_device.h" | 17 #include "ui/events/devices/keyboard_device.h" |
18 #include "ui/events/devices/touchscreen_device.h" | 18 #include "ui/events/devices/touchscreen_device.h" |
19 #include "ui/gfx/transform.h" | 19 #include "ui/gfx/transform.h" |
20 | 20 |
21 namespace ui { | 21 namespace ui { |
22 | 22 |
| 23 namespace test { |
| 24 class DeviceDataManagerTestAPI; |
| 25 } // namespace test |
| 26 |
23 class InputDeviceEventObserver; | 27 class InputDeviceEventObserver; |
24 | 28 |
25 // Keeps track of device mappings and event transformations. | 29 // Keeps track of device mappings and event transformations. |
26 class EVENTS_DEVICES_EXPORT DeviceDataManager | 30 class EVENTS_DEVICES_EXPORT DeviceDataManager |
27 : public DeviceHotplugEventObserver { | 31 : public DeviceHotplugEventObserver { |
28 public: | 32 public: |
29 static const int kMaxDeviceNum = 128; | 33 static const int kMaxDeviceNum = 128; |
30 ~DeviceDataManager() override; | 34 ~DeviceDataManager() override; |
31 | 35 |
32 static void CreateInstance(); | 36 static void CreateInstance(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 const std::vector<TouchscreenDevice>& devices) override; | 72 const std::vector<TouchscreenDevice>& devices) override; |
69 void OnKeyboardDevicesUpdated( | 73 void OnKeyboardDevicesUpdated( |
70 const std::vector<KeyboardDevice>& devices) override; | 74 const std::vector<KeyboardDevice>& devices) override; |
71 void OnMouseDevicesUpdated( | 75 void OnMouseDevicesUpdated( |
72 const std::vector<InputDevice>& devices) override; | 76 const std::vector<InputDevice>& devices) override; |
73 void OnTouchpadDevicesUpdated( | 77 void OnTouchpadDevicesUpdated( |
74 const std::vector<InputDevice>& devices) override; | 78 const std::vector<InputDevice>& devices) override; |
75 void OnDeviceListsComplete() override; | 79 void OnDeviceListsComplete() override; |
76 | 80 |
77 private: | 81 private: |
| 82 friend class test::DeviceDataManagerTestAPI; |
| 83 |
78 static DeviceDataManager* instance_; | 84 static DeviceDataManager* instance_; |
79 | 85 |
80 bool IsTouchDeviceIdValid(int touch_device_id) const; | 86 bool IsTouchDeviceIdValid(int touch_device_id) const; |
81 | 87 |
| 88 void NotifyObserversTouchscreenDeviceConfigurationChanged(); |
| 89 void NotifyObserversKeyboardDeviceConfigurationChanged(); |
| 90 void NotifyObserversMouseDeviceConfigurationChanged(); |
| 91 void NotifyObserversTouchpadDeviceConfigurationChanged(); |
| 92 void NotifyObserversDeviceListsComplete(); |
| 93 |
82 double touch_radius_scale_map_[kMaxDeviceNum]; | 94 double touch_radius_scale_map_[kMaxDeviceNum]; |
83 | 95 |
84 // Index table to find the target display id for a touch device. | 96 // Index table to find the target display id for a touch device. |
85 int64_t touch_device_to_target_display_map_[kMaxDeviceNum]; | 97 int64_t touch_device_to_target_display_map_[kMaxDeviceNum]; |
86 // Index table to find the TouchTransformer for a touch device. | 98 // Index table to find the TouchTransformer for a touch device. |
87 gfx::Transform touch_device_transformer_map_[kMaxDeviceNum]; | 99 gfx::Transform touch_device_transformer_map_[kMaxDeviceNum]; |
88 | 100 |
89 std::vector<TouchscreenDevice> touchscreen_devices_; | 101 std::vector<TouchscreenDevice> touchscreen_devices_; |
90 std::vector<KeyboardDevice> keyboard_devices_; | 102 std::vector<KeyboardDevice> keyboard_devices_; |
91 std::vector<InputDevice> mouse_devices_; | 103 std::vector<InputDevice> mouse_devices_; |
92 std::vector<InputDevice> touchpad_devices_; | 104 std::vector<InputDevice> touchpad_devices_; |
93 bool device_lists_complete_ = false; | 105 bool device_lists_complete_ = false; |
94 | 106 |
95 base::ObserverList<InputDeviceEventObserver> observers_; | 107 base::ObserverList<InputDeviceEventObserver> observers_; |
96 | 108 |
97 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); | 109 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); |
98 }; | 110 }; |
99 | 111 |
100 } // namespace ui | 112 } // namespace ui |
101 | 113 |
102 #endif // UI_EVENTS_DEVICES_DEVICE_DATA_MANAGER_H_ | 114 #endif // UI_EVENTS_DEVICES_DEVICE_DATA_MANAGER_H_ |
OLD | NEW |