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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 const DataType type, | 208 const DataType type, |
209 double* value); | 209 double* value); |
210 | 210 |
211 // Extract the range of the data type. Return true if the range is available | 211 // Extract the range of the data type. Return true if the range is available |
212 // and written into min & max, false if the range is not available. | 212 // and written into min & max, false if the range is not available. |
213 bool GetDataRange(unsigned int deviceid, | 213 bool GetDataRange(unsigned int deviceid, |
214 const DataType type, | 214 const DataType type, |
215 double* min, | 215 double* min, |
216 double* max); | 216 double* max); |
217 | 217 |
218 // Setups relevant valuator informations for device ids in the list |devices|. | 218 // Sets up relevant valuator informations for device ids in the device lists. |
219 // This function is only for test purpose. It does not query the X server for | 219 // This function is only for test purpose. It does not query the X server for |
220 // the actual device info, but rather inits the relevant valuator structures | 220 // the actual device info, but rather inits the relevant valuator structures |
221 // to have safe default values for testing. |cmt_devices| and |touchpads| | 221 // to have safe default values for testing. |
222 // should only contain device ids in |devices|. | 222 void SetDeviceListForTest(const std::vector<unsigned int>& touchscreen, |
223 void SetDeviceListForTest(const std::vector<unsigned int>& devices, | 223 const std::vector<unsigned int>& cmt_devices); |
224 const std::vector<unsigned int>& cmt_devices, | |
225 const std::vector<unsigned int>& touchpads); | |
226 | 224 |
227 // Setups device with |deviceid| to have valuator with type |data_type|, | 225 void SetValuatorDataForTest(XIDeviceEvent* xievent, |
228 // at index |val_index|, and with |min|/|max| values. This is only for test | 226 DataType type, |
229 // purpose. | 227 double value); |
230 void SetDeviceValuatorForTest(int deviceid, | 228 |
231 int val_index, | |
232 DataType data_type, | |
233 double min, | |
234 double max); | |
235 private: | 229 private: |
236 // Requirement for Singleton. | 230 // Requirement for Singleton. |
237 friend struct DefaultSingletonTraits<DeviceDataManager>; | 231 friend struct DefaultSingletonTraits<DeviceDataManager>; |
238 | 232 |
239 DeviceDataManager(); | 233 DeviceDataManager(); |
240 ~DeviceDataManager(); | 234 ~DeviceDataManager(); |
241 | 235 |
242 // Initialize the XInput related system information. | 236 // Initialize the XInput related system information. |
243 bool InitializeXInputInternal(); | 237 bool InitializeXInputInternal(); |
244 | 238 |
245 // Check if an XI event contains data of the specified type. | 239 // Check if an XI event contains data of the specified type. |
246 bool HasEventData(const XIDeviceEvent* xiev, const DataType type) const; | 240 bool HasEventData(const XIDeviceEvent* xiev, const DataType type) const; |
247 | 241 |
| 242 void InitializeValuatorsForTest(int deviceid, |
| 243 int start_valuator, |
| 244 int end_valuator, |
| 245 double min_value, |
| 246 double max_value); |
| 247 |
248 static const int kMaxDeviceNum = 128; | 248 static const int kMaxDeviceNum = 128; |
249 static const int kMaxXIEventType = XI_LASTEVENT + 1; | 249 static const int kMaxXIEventType = XI_LASTEVENT + 1; |
250 static const int kMaxSlotNum = 10; | 250 static const int kMaxSlotNum = 10; |
251 bool natural_scroll_enabled_; | 251 bool natural_scroll_enabled_; |
252 | 252 |
253 // Major opcode for the XInput extension. Used to identify XInput events. | 253 // Major opcode for the XInput extension. Used to identify XInput events. |
254 int xi_opcode_; | 254 int xi_opcode_; |
255 | 255 |
256 // 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. |
257 std::bitset<kMaxXIEventType> xi_device_event_types_; | 257 std::bitset<kMaxXIEventType> xi_device_event_types_; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 291 |
292 unsigned char button_map_[256]; | 292 unsigned char button_map_[256]; |
293 int button_map_count_; | 293 int button_map_count_; |
294 | 294 |
295 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); | 295 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); |
296 }; | 296 }; |
297 | 297 |
298 } // namespace ui | 298 } // namespace ui |
299 | 299 |
300 #endif // UI_EVENTS_X_DEVICE_DATA_MANAGER_H_ | 300 #endif // UI_EVENTS_X_DEVICE_DATA_MANAGER_H_ |
OLD | NEW |