OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_X_DEVICE_DATA_MANAGER_H_ | 5 #ifndef UI_EVENTS_X_DEVICE_DATA_MANAGER_H_ |
6 #define UI_EVENTS_X_DEVICE_DATA_MANAGER_H_ | 6 #define UI_EVENTS_X_DEVICE_DATA_MANAGER_H_ |
7 | 7 |
8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
9 | 9 |
10 #include <bitset> | 10 #include <bitset> |
11 #include <map> | 11 #include <map> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/event_types.h" | 15 #include "base/event_types.h" |
16 #include "ui/events/event_constants.h" | 16 #include "ui/events/event_constants.h" |
17 #include "ui/events/events_export.h" | 17 #include "ui/events/events_base_export.h" |
18 #include "ui/gfx/x/x11_atom_cache.h" | 18 #include "ui/gfx/x/x11_atom_cache.h" |
19 | 19 |
20 template <typename T> struct DefaultSingletonTraits; | 20 template <typename T> struct DefaultSingletonTraits; |
21 | 21 |
22 typedef union _XEvent XEvent; | 22 typedef union _XEvent XEvent; |
23 | 23 |
24 namespace ui { | 24 namespace ui { |
25 | 25 |
26 // CrOS touchpad metrics gesture types | 26 // CrOS touchpad metrics gesture types |
27 enum GestureMetricsType { | 27 enum GestureMetricsType { |
28 kGestureMetricsTypeNoisyGround = 0, | 28 kGestureMetricsTypeNoisyGround = 0, |
29 kGestureMetricsTypeUnknown, | 29 kGestureMetricsTypeUnknown, |
30 }; | 30 }; |
31 | 31 |
32 // A class that extracts and tracks the input events data. It currently handles | 32 // A class that extracts and tracks the input events data. It currently handles |
33 // mouse, touchpad and touchscreen devices. | 33 // mouse, touchpad and touchscreen devices. |
34 class EVENTS_EXPORT DeviceDataManager { | 34 class EVENTS_BASE_EXPORT DeviceDataManager { |
35 public: | 35 public: |
36 // Enumerate additional data that one might be interested on an input event, | 36 // Enumerate additional data that one might be interested on an input event, |
37 // which are usually wrapped in X valuators. If you modify any of this, | 37 // which are usually wrapped in X valuators. If you modify any of this, |
38 // make sure to update the kCachedAtoms data structure in the source file | 38 // make sure to update the kCachedAtoms data structure in the source file |
39 // and the k*Type[Start/End] constants used by IsCMTDataType and | 39 // and the k*Type[Start/End] constants used by IsCMTDataType and |
40 // IsTouchDataType. | 40 // IsTouchDataType. |
41 enum DataType { | 41 enum DataType { |
42 // Define the valuators used the CrOS CMT driver. Used by mice and CrOS | 42 // Define the valuators used the CrOS CMT driver. Used by mice and CrOS |
43 // touchpads. | 43 // touchpads. |
44 DT_CMT_SCROLL_X = 0, // Scroll amount on the X (horizontal) direction. | 44 DT_CMT_SCROLL_X = 0, // Scroll amount on the X (horizontal) direction. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 // Returns the DeviceDataManager singleton. | 97 // Returns the DeviceDataManager singleton. |
98 static DeviceDataManager* GetInstance(); | 98 static DeviceDataManager* GetInstance(); |
99 | 99 |
100 // Natural scroll setter/getter. | 100 // Natural scroll setter/getter. |
101 bool natural_scroll_enabled() const { return natural_scroll_enabled_; } | 101 bool natural_scroll_enabled() const { return natural_scroll_enabled_; } |
102 void set_natural_scroll_enabled(bool enabled) { | 102 void set_natural_scroll_enabled(bool enabled) { |
103 natural_scroll_enabled_ = enabled; | 103 natural_scroll_enabled_ = enabled; |
104 } | 104 } |
105 | 105 |
| 106 // Returns if XInput2 is available on the system. |
| 107 bool IsXInput2Available() const; |
| 108 |
106 // Get the natural scroll direction multiplier (1.0f or -1.0f). | 109 // Get the natural scroll direction multiplier (1.0f or -1.0f). |
107 float GetNaturalScrollFactor(int sourceid) const; | 110 float GetNaturalScrollFactor(int sourceid) const; |
108 | 111 |
109 // Updates the list of devices. | 112 // Updates the list of devices. |
110 void UpdateDeviceList(Display* display); | 113 void UpdateDeviceList(Display* display); |
111 | 114 |
112 // For multitouch events we use slot number to distinguish touches from | 115 // For multitouch events we use slot number to distinguish touches from |
113 // different fingers. This function returns true if the associated slot | 116 // different fingers. This function returns true if the associated slot |
114 // for |xiev| can be found and it is saved in |slot|, returns false if | 117 // for |xiev| can be found and it is saved in |slot|, returns false if |
115 // no slot can be found. | 118 // no slot can be found. |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 281 |
279 unsigned char button_map_[256]; | 282 unsigned char button_map_[256]; |
280 int button_map_count_; | 283 int button_map_count_; |
281 | 284 |
282 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); | 285 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); |
283 }; | 286 }; |
284 | 287 |
285 } // namespace ui | 288 } // namespace ui |
286 | 289 |
287 #endif // UI_EVENTS_X_DEVICE_DATA_MANAGER_H_ | 290 #endif // UI_EVENTS_X_DEVICE_DATA_MANAGER_H_ |
OLD | NEW |