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 // Generically-named #defines from Xlib is conflicting with symbols in GTest. | 8 // Generically-named #defines from Xlib is conflicting with symbols in GTest. |
9 // So many tests .cc file #undef Bool before including device_data_manager.h, | 9 // So many tests .cc file #undef Bool before including device_data_manager.h, |
10 // which makes Bool unrecognized in XInput2.h. | 10 // which makes Bool unrecognized in XInput2.h. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // Data struct to store extracted data from an input event. | 97 // Data struct to store extracted data from an input event. |
98 typedef std::map<int, double> EventData; | 98 typedef std::map<int, double> EventData; |
99 | 99 |
100 // We use int because enums can be casted to ints but not vice versa. | 100 // We use int because enums can be casted to ints but not vice versa. |
101 static bool IsCMTDataType(const int type); | 101 static bool IsCMTDataType(const int type); |
102 static bool IsTouchDataType(const int type); | 102 static bool IsTouchDataType(const int type); |
103 | 103 |
104 // Returns the DeviceDataManager singleton. | 104 // Returns the DeviceDataManager singleton. |
105 static DeviceDataManager* GetInstance(); | 105 static DeviceDataManager* GetInstance(); |
106 | 106 |
107 // Natural scroll setter/getter. | |
108 bool natural_scroll_enabled() const { return natural_scroll_enabled_; } | |
109 void set_natural_scroll_enabled(bool enabled) { | |
110 natural_scroll_enabled_ = enabled; | |
111 } | |
112 | |
113 // Returns if XInput2 is available on the system. | 107 // Returns if XInput2 is available on the system. |
114 bool IsXInput2Available() const; | 108 bool IsXInput2Available() const; |
115 | 109 |
116 // Get the natural scroll direction multiplier (1.0f or -1.0f). | |
117 float GetNaturalScrollFactor(int sourceid) const; | |
118 | |
119 // Updates the list of devices. | 110 // Updates the list of devices. |
120 void UpdateDeviceList(Display* display); | 111 void UpdateDeviceList(Display* display); |
121 | 112 |
122 // For multitouch events we use slot number to distinguish touches from | 113 // For multitouch events we use slot number to distinguish touches from |
123 // different fingers. This function returns true if the associated slot | 114 // different fingers. This function returns true if the associated slot |
124 // for |xiev| can be found and it is saved in |slot|, returns false if | 115 // for |xiev| can be found and it is saved in |slot|, returns false if |
125 // no slot can be found. | 116 // no slot can be found. |
126 bool GetSlotNumber(const XIDeviceEvent* xiev, int* slot); | 117 bool GetSlotNumber(const XIDeviceEvent* xiev, int* slot); |
127 | 118 |
128 // Get all event data in one pass. We extract only data types that we know | 119 // Get all event data in one pass. We extract only data types that we know |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 232 |
242 void InitializeValuatorsForTest(int deviceid, | 233 void InitializeValuatorsForTest(int deviceid, |
243 int start_valuator, | 234 int start_valuator, |
244 int end_valuator, | 235 int end_valuator, |
245 double min_value, | 236 double min_value, |
246 double max_value); | 237 double max_value); |
247 | 238 |
248 static const int kMaxDeviceNum = 128; | 239 static const int kMaxDeviceNum = 128; |
249 static const int kMaxXIEventType = XI_LASTEVENT + 1; | 240 static const int kMaxXIEventType = XI_LASTEVENT + 1; |
250 static const int kMaxSlotNum = 10; | 241 static const int kMaxSlotNum = 10; |
251 bool natural_scroll_enabled_; | |
252 | 242 |
253 // Major opcode for the XInput extension. Used to identify XInput events. | 243 // Major opcode for the XInput extension. Used to identify XInput events. |
254 int xi_opcode_; | 244 int xi_opcode_; |
255 | 245 |
256 // A quick lookup table for determining if the XI event is an XIDeviceEvent. | 246 // A quick lookup table for determining if the XI event is an XIDeviceEvent. |
257 std::bitset<kMaxXIEventType> xi_device_event_types_; | 247 std::bitset<kMaxXIEventType> xi_device_event_types_; |
258 | 248 |
259 // A quick lookup table for determining if events from the pointer device | 249 // A quick lookup table for determining if events from the pointer device |
260 // should be processed. | 250 // should be processed. |
261 std::bitset<kMaxDeviceNum> cmt_devices_; | 251 std::bitset<kMaxDeviceNum> cmt_devices_; |
(...skipping 29 matching lines...) Expand all Loading... |
291 | 281 |
292 unsigned char button_map_[256]; | 282 unsigned char button_map_[256]; |
293 int button_map_count_; | 283 int button_map_count_; |
294 | 284 |
295 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); | 285 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); |
296 }; | 286 }; |
297 | 287 |
298 } // namespace ui | 288 } // namespace ui |
299 | 289 |
300 #endif // UI_EVENTS_X_DEVICE_DATA_MANAGER_H_ | 290 #endif // UI_EVENTS_X_DEVICE_DATA_MANAGER_H_ |
OLD | NEW |