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 |
107 // Returns if XInput2 is available on the system. | 113 // Returns if XInput2 is available on the system. |
108 bool IsXInput2Available() const; | 114 bool IsXInput2Available() const; |
109 | 115 |
| 116 // Get the natural scroll direction multiplier (1.0f or -1.0f). |
| 117 float GetNaturalScrollFactor(int sourceid) const; |
| 118 |
110 // Updates the list of devices. | 119 // Updates the list of devices. |
111 void UpdateDeviceList(Display* display); | 120 void UpdateDeviceList(Display* display); |
112 | 121 |
113 // For multitouch events we use slot number to distinguish touches from | 122 // For multitouch events we use slot number to distinguish touches from |
114 // different fingers. This function returns true if the associated slot | 123 // different fingers. This function returns true if the associated slot |
115 // for |xiev| can be found and it is saved in |slot|, returns false if | 124 // for |xiev| can be found and it is saved in |slot|, returns false if |
116 // no slot can be found. | 125 // no slot can be found. |
117 bool GetSlotNumber(const XIDeviceEvent* xiev, int* slot); | 126 bool GetSlotNumber(const XIDeviceEvent* xiev, int* slot); |
118 | 127 |
119 // Get all event data in one pass. We extract only data types that we know | 128 // 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... |
232 | 241 |
233 void InitializeValuatorsForTest(int deviceid, | 242 void InitializeValuatorsForTest(int deviceid, |
234 int start_valuator, | 243 int start_valuator, |
235 int end_valuator, | 244 int end_valuator, |
236 double min_value, | 245 double min_value, |
237 double max_value); | 246 double max_value); |
238 | 247 |
239 static const int kMaxDeviceNum = 128; | 248 static const int kMaxDeviceNum = 128; |
240 static const int kMaxXIEventType = XI_LASTEVENT + 1; | 249 static const int kMaxXIEventType = XI_LASTEVENT + 1; |
241 static const int kMaxSlotNum = 10; | 250 static const int kMaxSlotNum = 10; |
| 251 bool natural_scroll_enabled_; |
242 | 252 |
243 // Major opcode for the XInput extension. Used to identify XInput events. | 253 // Major opcode for the XInput extension. Used to identify XInput events. |
244 int xi_opcode_; | 254 int xi_opcode_; |
245 | 255 |
246 // A quick lookup table for determining if the XI event is an XIDeviceEvent. | 256 // A quick lookup table for determining if the XI event is an XIDeviceEvent. |
247 std::bitset<kMaxXIEventType> xi_device_event_types_; | 257 std::bitset<kMaxXIEventType> xi_device_event_types_; |
248 | 258 |
249 // A quick lookup table for determining if events from the pointer device | 259 // A quick lookup table for determining if events from the pointer device |
250 // should be processed. | 260 // should be processed. |
251 std::bitset<kMaxDeviceNum> cmt_devices_; | 261 std::bitset<kMaxDeviceNum> cmt_devices_; |
(...skipping 29 matching lines...) Expand all Loading... |
281 | 291 |
282 unsigned char button_map_[256]; | 292 unsigned char button_map_[256]; |
283 int button_map_count_; | 293 int button_map_count_; |
284 | 294 |
285 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); | 295 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); |
286 }; | 296 }; |
287 | 297 |
288 } // namespace ui | 298 } // namespace ui |
289 | 299 |
290 #endif // UI_EVENTS_X_DEVICE_DATA_MANAGER_H_ | 300 #endif // UI_EVENTS_X_DEVICE_DATA_MANAGER_H_ |
OLD | NEW |