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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 const std::vector<TouchscreenDevice>& devices) override; | 75 const std::vector<TouchscreenDevice>& devices) override; |
72 void OnKeyboardDevicesUpdated( | 76 void OnKeyboardDevicesUpdated( |
73 const std::vector<KeyboardDevice>& devices) override; | 77 const std::vector<KeyboardDevice>& devices) override; |
74 void OnMouseDevicesUpdated( | 78 void OnMouseDevicesUpdated( |
75 const std::vector<InputDevice>& devices) override; | 79 const std::vector<InputDevice>& devices) override; |
76 void OnTouchpadDevicesUpdated( | 80 void OnTouchpadDevicesUpdated( |
77 const std::vector<InputDevice>& devices) override; | 81 const std::vector<InputDevice>& devices) override; |
78 void OnDeviceListsComplete() override; | 82 void OnDeviceListsComplete() override; |
79 | 83 |
80 private: | 84 private: |
| 85 friend class test::DeviceDataManagerTestAPI; |
| 86 |
81 static DeviceDataManager* instance_; | 87 static DeviceDataManager* instance_; |
82 | 88 |
83 bool IsTouchDeviceIdValid(int touch_device_id) const; | 89 bool IsTouchDeviceIdValid(int touch_device_id) const; |
84 | 90 |
| 91 void NotifyObserversTouchscreenDeviceConfigurationChanged(); |
| 92 void NotifyObserversKeyboardDeviceConfigurationChanged(); |
| 93 void NotifyObserversMouseDeviceConfigurationChanged(); |
| 94 void NotifyObserversTouchpadDeviceConfigurationChanged(); |
| 95 void NotifyObserversDeviceListsComplete(); |
| 96 |
85 double touch_radius_scale_map_[kMaxDeviceNum]; | 97 double touch_radius_scale_map_[kMaxDeviceNum]; |
86 | 98 |
87 // Index table to find the target display id for a touch device. | 99 // Index table to find the target display id for a touch device. |
88 int64_t touch_device_to_target_display_map_[kMaxDeviceNum]; | 100 int64_t touch_device_to_target_display_map_[kMaxDeviceNum]; |
89 // Index table to find the TouchTransformer for a touch device. | 101 // Index table to find the TouchTransformer for a touch device. |
90 gfx::Transform touch_device_transformer_map_[kMaxDeviceNum]; | 102 gfx::Transform touch_device_transformer_map_[kMaxDeviceNum]; |
91 | 103 |
92 std::vector<TouchscreenDevice> touchscreen_devices_; | 104 std::vector<TouchscreenDevice> touchscreen_devices_; |
93 std::vector<KeyboardDevice> keyboard_devices_; | 105 std::vector<KeyboardDevice> keyboard_devices_; |
94 std::vector<InputDevice> mouse_devices_; | 106 std::vector<InputDevice> mouse_devices_; |
95 std::vector<InputDevice> touchpad_devices_; | 107 std::vector<InputDevice> touchpad_devices_; |
96 bool device_lists_complete_ = false; | 108 bool device_lists_complete_ = false; |
97 | 109 |
98 base::ObserverList<InputDeviceEventObserver> observers_; | 110 base::ObserverList<InputDeviceEventObserver> observers_; |
99 | 111 |
100 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); | 112 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); |
101 }; | 113 }; |
102 | 114 |
103 } // namespace ui | 115 } // namespace ui |
104 | 116 |
105 #endif // UI_EVENTS_DEVICES_DEVICE_DATA_MANAGER_H_ | 117 #endif // UI_EVENTS_DEVICES_DEVICE_DATA_MANAGER_H_ |
OLD | NEW |