| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // Extract the start/end timestamps from CMT events. User must first verify | 197 // Extract the start/end timestamps from CMT events. User must first verify |
| 198 // the event with HasGestureTimes. Pointers shouldn't be NULL. | 198 // the event with HasGestureTimes. Pointers shouldn't be NULL. |
| 199 void GetGestureTimes(const base::NativeEvent& native_event, | 199 void GetGestureTimes(const base::NativeEvent& native_event, |
| 200 double* start_time, | 200 double* start_time, |
| 201 double* end_time); | 201 double* end_time); |
| 202 | 202 |
| 203 // Normalize the data value on deviceid to fall into [0, 1]. | 203 // Normalize the data value on deviceid to fall into [0, 1]. |
| 204 // *value = (*value - min_value_of_tp) / (max_value_of_tp - min_value_of_tp) | 204 // *value = (*value - min_value_of_tp) / (max_value_of_tp - min_value_of_tp) |
| 205 // Returns true and sets the normalized value in|value| if normalization is | 205 // Returns true and sets the normalized value in|value| if normalization is |
| 206 // successful. Returns false and |value| is unchanged otherwise. | 206 // successful. Returns false and |value| is unchanged otherwise. |
| 207 bool NormalizeData(unsigned int deviceid, | 207 bool NormalizeData(int deviceid, |
| 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(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 // Sets up relevant valuator informations for device ids in the device lists. | 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. | 221 // to have safe default values for testing. |
| 222 void SetDeviceListForTest(const std::vector<unsigned int>& touchscreen, | 222 void SetDeviceListForTest(const std::vector<int>& touchscreen, |
| 223 const std::vector<unsigned int>& cmt_devices); | 223 const std::vector<int>& cmt_devices); |
| 224 | 224 |
| 225 void SetValuatorDataForTest(XIDeviceEvent* xievent, | 225 void SetValuatorDataForTest(XIDeviceEvent* xievent, |
| 226 DataType type, | 226 DataType type, |
| 227 double value); | 227 double value); |
| 228 | 228 |
| 229 bool TouchEventNeedsCalibrate(unsigned int touch_device_id) const; | 229 bool TouchEventNeedsCalibrate(int touch_device_id) const; |
| 230 | 230 |
| 231 // Sets the keys which are still allowed on a disabled keyboard device. | 231 // Sets the keys which are still allowed on a disabled keyboard device. |
| 232 void SetDisabledKeyboardAllowedKeys( | 232 void SetDisabledKeyboardAllowedKeys( |
| 233 scoped_ptr<std::set<KeyboardCode> > excepted_keys); | 233 scoped_ptr<std::set<KeyboardCode> > excepted_keys); |
| 234 | 234 |
| 235 // Disables and enables events from devices by device id. | 235 // Disables and enables events from devices by device id. |
| 236 void DisableDevice(unsigned int deviceid); | 236 void DisableDevice(int deviceid); |
| 237 void EnableDevice(unsigned int deviceid); | 237 void EnableDevice(int deviceid); |
| 238 | 238 |
| 239 // Returns true if |native_event| should be blocked. | 239 // Returns true if |native_event| should be blocked. |
| 240 bool IsEventBlocked(const base::NativeEvent& native_event); | 240 bool IsEventBlocked(const base::NativeEvent& native_event); |
| 241 | 241 |
| 242 const std::vector<int>& master_pointers() const { | 242 const std::vector<int>& master_pointers() const { |
| 243 return master_pointers_; | 243 return master_pointers_; |
| 244 } | 244 } |
| 245 | 245 |
| 246 protected: | 246 protected: |
| 247 // DeviceHotplugEventObserver: | 247 // DeviceHotplugEventObserver: |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 // a specified slot of a device. Defaults to 0 if the valuator for that slot | 308 // a specified slot of a device. Defaults to 0 if the valuator for that slot |
| 309 // was not specified in an earlier event. With MT-B/XI2.2, valuators in an | 309 // was not specified in an earlier event. With MT-B/XI2.2, valuators in an |
| 310 // XEvent are not reported if the values haven't changed from the previous | 310 // XEvent are not reported if the values haven't changed from the previous |
| 311 // event. So it is necessary to remember these valuators so that chrome | 311 // event. So it is necessary to remember these valuators so that chrome |
| 312 // doesn't think X/device doesn't know about the valuators. We currently | 312 // doesn't think X/device doesn't know about the valuators. We currently |
| 313 // use this only on touchscreen devices. | 313 // use this only on touchscreen devices. |
| 314 std::vector<double> last_seen_valuator_[kMaxDeviceNum][kMaxSlotNum]; | 314 std::vector<double> last_seen_valuator_[kMaxDeviceNum][kMaxSlotNum]; |
| 315 | 315 |
| 316 // Map that stores meta-data for blocked keyboards. This is needed to restore | 316 // Map that stores meta-data for blocked keyboards. This is needed to restore |
| 317 // devices when they are re-enabled. | 317 // devices when they are re-enabled. |
| 318 std::map<unsigned int, ui::KeyboardDevice> blocked_keyboards_; | 318 std::map<int, ui::KeyboardDevice> blocked_keyboards_; |
| 319 | 319 |
| 320 // X11 atoms cache. | 320 // X11 atoms cache. |
| 321 X11AtomCache atom_cache_; | 321 X11AtomCache atom_cache_; |
| 322 | 322 |
| 323 unsigned char button_map_[256]; | 323 unsigned char button_map_[256]; |
| 324 int button_map_count_; | 324 int button_map_count_; |
| 325 | 325 |
| 326 DISALLOW_COPY_AND_ASSIGN(DeviceDataManagerX11); | 326 DISALLOW_COPY_AND_ASSIGN(DeviceDataManagerX11); |
| 327 }; | 327 }; |
| 328 | 328 |
| 329 } // namespace ui | 329 } // namespace ui |
| 330 | 330 |
| 331 #endif // UI_EVENTS_DEVICES_X11_DEVICE_DATA_MANAGER_X11_H_ | 331 #endif // UI_EVENTS_DEVICES_X11_DEVICE_DATA_MANAGER_X11_H_ |
| OLD | NEW |