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 <array> | 10 #include <array> |
11 #include <memory> | 11 #include <memory> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "ui/events/devices/device_hotplug_event_observer.h" | 16 #include "ui/events/devices/device_hotplug_event_observer.h" |
17 #include "ui/events/devices/events_devices_export.h" | 17 #include "ui/events/devices/events_devices_export.h" |
| 18 #include "ui/events/devices/input_device_manager.h" |
18 #include "ui/events/devices/touchscreen_device.h" | 19 #include "ui/events/devices/touchscreen_device.h" |
19 #include "ui/gfx/transform.h" | 20 #include "ui/gfx/transform.h" |
20 | 21 |
21 namespace ui { | 22 namespace ui { |
22 | 23 |
23 namespace test { | 24 namespace test { |
24 class DeviceDataManagerTestAPI; | 25 class DeviceDataManagerTestAPI; |
25 } // namespace test | 26 } // namespace test |
26 | 27 |
27 class InputDeviceEventObserver; | 28 class InputDeviceEventObserver; |
28 | 29 |
29 // Keeps track of device mappings and event transformations. | 30 // Keeps track of device mappings and event transformations. |
30 class EVENTS_DEVICES_EXPORT DeviceDataManager | 31 class EVENTS_DEVICES_EXPORT DeviceDataManager |
31 : public DeviceHotplugEventObserver { | 32 : public InputDeviceManager, |
| 33 public DeviceHotplugEventObserver { |
32 public: | 34 public: |
33 static const int kMaxDeviceNum = 128; | 35 static const int kMaxDeviceNum = 128; |
34 ~DeviceDataManager() override; | 36 ~DeviceDataManager() override; |
35 | 37 |
36 static void CreateInstance(); | 38 static void CreateInstance(); |
37 static void DeleteInstance(); | 39 static void DeleteInstance(); |
38 static DeviceDataManager* GetInstance(); | 40 static DeviceDataManager* GetInstance(); |
39 static bool HasInstance(); | 41 static bool HasInstance(); |
40 | 42 |
41 void ClearTouchDeviceAssociations(); | 43 void ClearTouchDeviceAssociations(); |
42 void UpdateTouchInfoForDisplay(int64_t target_display_id, | 44 void UpdateTouchInfoForDisplay(int64_t target_display_id, |
43 int touch_device_id, | 45 int touch_device_id, |
44 const gfx::Transform& touch_transformer); | 46 const gfx::Transform& touch_transformer); |
45 void ApplyTouchTransformer(int touch_device_id, float* x, float* y); | 47 void ApplyTouchTransformer(int touch_device_id, float* x, float* y); |
46 | 48 |
47 // Gets the display that touches from |touch_device_id| should be sent to. | 49 // Gets the display that touches from |touch_device_id| should be sent to. |
48 int64_t GetTargetDisplayForTouchDevice(int touch_device_id) const; | 50 int64_t GetTargetDisplayForTouchDevice(int touch_device_id) const; |
49 | 51 |
50 void UpdateTouchRadiusScale(int touch_device_id, double scale); | 52 void UpdateTouchRadiusScale(int touch_device_id, double scale); |
51 void ApplyTouchRadiusScale(int touch_device_id, double* radius); | 53 void ApplyTouchRadiusScale(int touch_device_id, double* radius); |
52 | 54 |
53 const std::vector<TouchscreenDevice>& touchscreen_devices() const { | 55 void SetTouchscreensEnabled(bool enabled); |
54 return touchscreen_devices_; | |
55 } | |
56 | 56 |
57 const std::vector<InputDevice>& keyboard_devices() const { | 57 // InputDeviceManager: |
58 return keyboard_devices_; | 58 const std::vector<TouchscreenDevice>& GetTouchscreenDevices() const override; |
59 } | 59 const std::vector<InputDevice>& GetKeyboardDevices() const override; |
| 60 const std::vector<InputDevice>& GetMouseDevices() const override; |
| 61 const std::vector<InputDevice>& GetTouchpadDevices() const override; |
| 62 bool AreDeviceListsComplete() const override; |
| 63 bool AreTouchscreensEnabled() const override; |
60 | 64 |
61 const std::vector<InputDevice>& mouse_devices() const { | 65 void AddObserver(InputDeviceEventObserver* observer) override; |
62 return mouse_devices_; | 66 void RemoveObserver(InputDeviceEventObserver* observer) override; |
63 } | |
64 | |
65 const std::vector<InputDevice>& touchpad_devices() const { | |
66 return touchpad_devices_; | |
67 } | |
68 | |
69 bool device_lists_complete() const { return device_lists_complete_; } | |
70 | |
71 void AddObserver(InputDeviceEventObserver* observer); | |
72 void RemoveObserver(InputDeviceEventObserver* observer); | |
73 | |
74 void SetTouchscreensEnabled(bool enabled); | |
75 bool AreTouchscreensEnabled() const; | |
76 | 67 |
77 protected: | 68 protected: |
78 DeviceDataManager(); | 69 DeviceDataManager(); |
79 | 70 |
80 static DeviceDataManager* instance(); | 71 static DeviceDataManager* instance(); |
81 | 72 |
82 static void set_instance(DeviceDataManager* instance); | 73 static void set_instance(DeviceDataManager* instance); |
83 | 74 |
84 // DeviceHotplugEventObserver: | 75 // DeviceHotplugEventObserver: |
85 void OnTouchscreenDevicesUpdated( | 76 void OnTouchscreenDevicesUpdated( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // have default values if the device with corresponding ID isn't a touchscreen | 120 // have default values if the device with corresponding ID isn't a touchscreen |
130 // or doesn't exist. | 121 // or doesn't exist. |
131 std::array<TouchscreenInfo, kMaxDeviceNum> touch_map_; | 122 std::array<TouchscreenInfo, kMaxDeviceNum> touch_map_; |
132 | 123 |
133 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); | 124 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); |
134 }; | 125 }; |
135 | 126 |
136 } // namespace ui | 127 } // namespace ui |
137 | 128 |
138 #endif // UI_EVENTS_DEVICES_DEVICE_DATA_MANAGER_H_ | 129 #endif // UI_EVENTS_DEVICES_DEVICE_DATA_MANAGER_H_ |
OLD | NEW |