| 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_X11_DEVICE_DATA_MANAGER_X11_H_ | 5 #ifndef UI_EVENTS_DEVICES_X11_DEVICE_DATA_MANAGER_X11_H_ |
| 6 #define UI_EVENTS_DEVICES_X11_DEVICE_DATA_MANAGER_X11_H_ | 6 #define UI_EVENTS_DEVICES_X11_DEVICE_DATA_MANAGER_X11_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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 // Updates the list of devices. | 119 // Updates the list of devices. |
| 120 void UpdateDeviceList(Display* display); | 120 void UpdateDeviceList(Display* display); |
| 121 | 121 |
| 122 // For multitouch events we use slot number to distinguish touches from | 122 // For multitouch events we use slot number to distinguish touches from |
| 123 // different fingers. This function returns true if the associated slot | 123 // 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 | 124 // for |xiev| can be found and it is saved in |slot|, returns false if |
| 125 // no slot can be found. | 125 // no slot can be found. |
| 126 bool GetSlotNumber(const XIDeviceEvent* xiev, int* slot); | 126 bool GetSlotNumber(const XIDeviceEvent* xiev, int* slot); |
| 127 | 127 |
| 128 // Check if an XI event contains data of the specified type. |
| 129 bool HasEventData(const XIDeviceEvent* xiev, const DataType type) const; |
| 130 |
| 128 // Get all event data in one pass. We extract only data types that we know | 131 // Get all event data in one pass. We extract only data types that we know |
| 129 // about (defined in enum DataType). The data is not processed (e.g. not | 132 // about (defined in enum DataType). The data is not processed (e.g. not |
| 130 // filled in by cached values) as in GetEventData. | 133 // filled in by cached values) as in GetEventData. |
| 131 void GetEventRawData(const XEvent& xev, EventData* data); | 134 void GetEventRawData(const XEvent& xev, EventData* data); |
| 132 | 135 |
| 133 // Get a datum of the specified type. Return true and the value | 136 // Get a datum of the specified type. Return true and the value |
| 134 // is updated if the data is found, false and value unchanged if the data is | 137 // is updated if the data is found, false and value unchanged if the data is |
| 135 // not found. In the case of MT-B/XI2.2, the value can come from a previously | 138 // not found. In the case of MT-B/XI2.2, the value can come from a previously |
| 136 // cached one (see the comment above last_seen_valuator_). | 139 // cached one (see the comment above last_seen_valuator_). |
| 137 bool GetEventData(const XEvent& xev, const DataType type, double* value); | 140 bool GetEventData(const XEvent& xev, const DataType type, double* value); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 bool GetDataRange(int deviceid, | 216 bool GetDataRange(int deviceid, |
| 214 const DataType type, | 217 const DataType type, |
| 215 double* min, | 218 double* min, |
| 216 double* max); | 219 double* max); |
| 217 | 220 |
| 218 // Sets up relevant valuator informations for device ids in the device lists. | 221 // 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 | 222 // 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 | 223 // the actual device info, but rather inits the relevant valuator structures |
| 221 // to have safe default values for testing. | 224 // to have safe default values for testing. |
| 222 void SetDeviceListForTest(const std::vector<int>& touchscreen, | 225 void SetDeviceListForTest(const std::vector<int>& touchscreen, |
| 223 const std::vector<int>& cmt_devices); | 226 const std::vector<int>& cmt_devices, |
| 227 const std::vector<int>& other_devices); |
| 224 | 228 |
| 225 void SetValuatorDataForTest(XIDeviceEvent* xievent, | 229 void SetValuatorDataForTest(XIDeviceEvent* xievent, |
| 226 DataType type, | 230 DataType type, |
| 227 double value); | 231 double value); |
| 228 | 232 |
| 229 bool TouchEventNeedsCalibrate(int touch_device_id) const; | 233 bool TouchEventNeedsCalibrate(int touch_device_id) const; |
| 230 | 234 |
| 231 // Sets the keys which are still allowed on a disabled keyboard device. | 235 // Sets the keys which are still allowed on a disabled keyboard device. |
| 232 void SetDisabledKeyboardAllowedKeys( | 236 void SetDisabledKeyboardAllowedKeys( |
| 233 scoped_ptr<std::set<KeyboardCode> > excepted_keys); | 237 scoped_ptr<std::set<KeyboardCode> > excepted_keys); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 248 void OnKeyboardDevicesUpdated( | 252 void OnKeyboardDevicesUpdated( |
| 249 const std::vector<KeyboardDevice>& devices) override; | 253 const std::vector<KeyboardDevice>& devices) override; |
| 250 | 254 |
| 251 private: | 255 private: |
| 252 DeviceDataManagerX11(); | 256 DeviceDataManagerX11(); |
| 253 ~DeviceDataManagerX11() override; | 257 ~DeviceDataManagerX11() override; |
| 254 | 258 |
| 255 // Initialize the XInput related system information. | 259 // Initialize the XInput related system information. |
| 256 bool InitializeXInputInternal(); | 260 bool InitializeXInputInternal(); |
| 257 | 261 |
| 258 // Check if an XI event contains data of the specified type. | |
| 259 bool HasEventData(const XIDeviceEvent* xiev, const DataType type) const; | |
| 260 | |
| 261 void InitializeValuatorsForTest(int deviceid, | 262 void InitializeValuatorsForTest(int deviceid, |
| 262 int start_valuator, | 263 int start_valuator, |
| 263 int end_valuator, | 264 int end_valuator, |
| 264 double min_value, | 265 double min_value, |
| 265 double max_value); | 266 double max_value); |
| 266 | 267 |
| 267 static const int kMaxXIEventType = XI_LASTEVENT + 1; | 268 static const int kMaxXIEventType = XI_LASTEVENT + 1; |
| 268 static const int kMaxSlotNum = 10; | 269 static const int kMaxSlotNum = 10; |
| 269 | 270 |
| 270 // Major opcode for the XInput extension. Used to identify XInput events. | 271 // Major opcode for the XInput extension. Used to identify XInput events. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 | 323 |
| 323 unsigned char button_map_[256]; | 324 unsigned char button_map_[256]; |
| 324 int button_map_count_; | 325 int button_map_count_; |
| 325 | 326 |
| 326 DISALLOW_COPY_AND_ASSIGN(DeviceDataManagerX11); | 327 DISALLOW_COPY_AND_ASSIGN(DeviceDataManagerX11); |
| 327 }; | 328 }; |
| 328 | 329 |
| 329 } // namespace ui | 330 } // namespace ui |
| 330 | 331 |
| 331 #endif // UI_EVENTS_DEVICES_X11_DEVICE_DATA_MANAGER_X11_H_ | 332 #endif // UI_EVENTS_DEVICES_X11_DEVICE_DATA_MANAGER_X11_H_ |
| OLD | NEW |