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_X_DEVICE_DATA_MANAGER_X11_H_ | 5 #ifndef UI_EVENTS_X_DEVICE_DATA_MANAGER_X11_H_ |
6 #define UI_EVENTS_X_DEVICE_DATA_MANAGER_X11_H_ | 6 #define UI_EVENTS_X_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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 bool IsXIDeviceEvent(const base::NativeEvent& native_event) const; | 142 bool IsXIDeviceEvent(const base::NativeEvent& native_event) const; |
143 | 143 |
144 // Check if the event comes from touchpad devices. | 144 // Check if the event comes from touchpad devices. |
145 bool IsTouchpadXInputEvent(const base::NativeEvent& native_event) const; | 145 bool IsTouchpadXInputEvent(const base::NativeEvent& native_event) const; |
146 | 146 |
147 // Check if the event comes from devices running CMT driver or using | 147 // Check if the event comes from devices running CMT driver or using |
148 // CMT valuators (e.g. mouses). Note that doesn't necessarily mean the event | 148 // CMT valuators (e.g. mouses). Note that doesn't necessarily mean the event |
149 // is a CMT event (e.g. it could be a mouse pointer move). | 149 // is a CMT event (e.g. it could be a mouse pointer move). |
150 bool IsCMTDeviceEvent(const base::NativeEvent& native_event) const; | 150 bool IsCMTDeviceEvent(const base::NativeEvent& native_event) const; |
151 | 151 |
152 // Check if the event comes from devices that have a ScrollClass (ie. support | |
153 // smooth scrolling). | |
154 bool IsScrollClassEvent(const base::NativeEvent& native_event) const; | |
155 | |
156 // Check if the device has a vertical ScrollClass | |
157 bool IsScrollClassVerticalDevice(const base::NativeEvent& native_event) const; | |
158 | |
159 // Check if the device has a horizontal ScrollClass | |
160 bool IsScrollClassHorizontalDevice( | |
161 const base::NativeEvent& native_event) const; | |
162 | |
sadrul
2014/12/22 17:11:12
Instead of these three, let's have a single
Scr
| |
152 // Check if the event is one of the CMT gesture events (scroll, fling, | 163 // Check if the event is one of the CMT gesture events (scroll, fling, |
153 // metrics etc.). | 164 // metrics etc.). |
154 bool IsCMTGestureEvent(const base::NativeEvent& native_event) const; | 165 bool IsCMTGestureEvent(const base::NativeEvent& native_event) const; |
155 | 166 |
156 // Returns true if the event is of the specific type, false if not. | 167 // Returns true if the event is of the specific type, false if not. |
157 bool IsScrollEvent(const base::NativeEvent& native_event) const; | 168 bool IsScrollEvent(const base::NativeEvent& native_event) const; |
158 bool IsFlingEvent(const base::NativeEvent& native_event) const; | 169 bool IsFlingEvent(const base::NativeEvent& native_event) const; |
159 bool IsCMTMetricsEvent(const base::NativeEvent& native_event) const; | 170 bool IsCMTMetricsEvent(const base::NativeEvent& native_event) const; |
160 | 171 |
161 // Returns true if the event has CMT start/end timestamps. | 172 // Returns true if the event has CMT start/end timestamps. |
162 bool HasGestureTimes(const base::NativeEvent& native_event) const; | 173 bool HasGestureTimes(const base::NativeEvent& native_event) const; |
163 | 174 |
164 // Extract data from a scroll event (a motion event with the necessary | 175 // Extract data from a scroll event (a motion event with the necessary |
165 // valuators). User must first verify the event type with IsScrollEvent. | 176 // valuators). User must first verify the event type with IsScrollEvent. |
166 // Pointers shouldn't be NULL. | 177 // Pointers shouldn't be NULL. |
167 void GetScrollOffsets(const base::NativeEvent& native_event, | 178 void GetScrollOffsets(const base::NativeEvent& native_event, |
168 float* x_offset, | 179 float* x_offset, |
169 float* y_offset, | 180 float* y_offset, |
170 float* x_offset_ordinal, | 181 float* x_offset_ordinal, |
171 float* y_offset_ordinal, | 182 float* y_offset_ordinal, |
172 int* finger_count); | 183 int* finger_count); |
173 | 184 |
185 // Extract data from a scroll class event (smooth scrolling). User must | |
186 // first verify the event type with IsScrollClassEvent. | |
187 // Pointers shouldn't be NULL. | |
188 void GetScrollClassOffsets(const base::NativeEvent& native_event, | |
189 double* x_offset, | |
190 double* y_offset); | |
sadrul
2014/12/22 17:11:12
indenting is off
| |
191 | |
192 // Invalidate stored scroll class counters, since they can change when | |
193 // pointing at other windows. | |
194 void InvalidateScrollClasses(); | |
195 | |
174 // Extract data from a fling event. User must first verify the event type | 196 // Extract data from a fling event. User must first verify the event type |
175 // with IsFlingEvent. Pointers shouldn't be NULL. | 197 // with IsFlingEvent. Pointers shouldn't be NULL. |
176 void GetFlingData(const base::NativeEvent& native_event, | 198 void GetFlingData(const base::NativeEvent& native_event, |
177 float* vx, | 199 float* vx, |
178 float* vy, | 200 float* vy, |
179 float* vx_ordinal, | 201 float* vx_ordinal, |
180 float* vy_ordinal, | 202 float* vy_ordinal, |
181 bool* is_cancel); | 203 bool* is_cancel); |
182 | 204 |
183 // Extract data from a CrOS metrics gesture event. User must first verify | 205 // Extract data from a CrOS metrics gesture event. User must first verify |
(...skipping 17 matching lines...) Expand all Loading... | |
201 double* end_time); | 223 double* end_time); |
202 | 224 |
203 // Normalize the data value on deviceid to fall into [0, 1]. | 225 // 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) | 226 // *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 | 227 // Returns true and sets the normalized value in|value| if normalization is |
206 // successful. Returns false and |value| is unchanged otherwise. | 228 // successful. Returns false and |value| is unchanged otherwise. |
207 bool NormalizeData(unsigned int deviceid, | 229 bool NormalizeData(unsigned int deviceid, |
208 const DataType type, | 230 const DataType type, |
209 double* value); | 231 double* value); |
210 | 232 |
233 // Normalize the scroll amount according to the increment size. | |
234 // *value /= increment | |
235 // *value is expected to be 1 or -1. | |
236 // Returns true and sets the normalized value in |value| if normalization is | |
237 // successful. Returns false and |value| is unchanged otherwise. | |
238 bool NormalizeScrollData(unsigned int deviceid, | |
239 bool horizontal, | |
240 double* value); | |
sadrul
2014/12/22 17:11:12
indent
| |
241 | |
211 // Extract the range of the data type. Return true if the range is available | 242 // 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. | 243 // and written into min & max, false if the range is not available. |
213 bool GetDataRange(unsigned int deviceid, | 244 bool GetDataRange(unsigned int deviceid, |
214 const DataType type, | 245 const DataType type, |
215 double* min, | 246 double* min, |
216 double* max); | 247 double* max); |
217 | 248 |
218 // Sets up relevant valuator informations for device ids in the device lists. | 249 // 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 | 250 // 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 | 251 // the actual device info, but rather inits the relevant valuator structures |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 // Major opcode for the XInput extension. Used to identify XInput events. | 297 // Major opcode for the XInput extension. Used to identify XInput events. |
267 int xi_opcode_; | 298 int xi_opcode_; |
268 | 299 |
269 // A quick lookup table for determining if the XI event is an XIDeviceEvent. | 300 // A quick lookup table for determining if the XI event is an XIDeviceEvent. |
270 std::bitset<kMaxXIEventType> xi_device_event_types_; | 301 std::bitset<kMaxXIEventType> xi_device_event_types_; |
271 | 302 |
272 // A quick lookup table for determining if events from the pointer device | 303 // A quick lookup table for determining if events from the pointer device |
273 // should be processed. | 304 // should be processed. |
274 std::bitset<kMaxDeviceNum> cmt_devices_; | 305 std::bitset<kMaxDeviceNum> cmt_devices_; |
275 std::bitset<kMaxDeviceNum> touchpads_; | 306 std::bitset<kMaxDeviceNum> touchpads_; |
307 std::bitset<kMaxDeviceNum> scrollclass_devices_; | |
276 | 308 |
277 // A quick lookup table for determining if events from the XI device | 309 // A quick lookup table for determining if events from the XI device |
278 // should be blocked. | 310 // should be blocked. |
279 std::bitset<kMaxDeviceNum> blocked_devices_; | 311 std::bitset<kMaxDeviceNum> blocked_devices_; |
280 | 312 |
281 // The set of keys allowed while the keyboard is blocked. | 313 // The set of keys allowed while the keyboard is blocked. |
282 scoped_ptr<std::set<KeyboardCode> > blocked_keyboard_allowed_keys_; | 314 scoped_ptr<std::set<KeyboardCode> > blocked_keyboard_allowed_keys_; |
283 | 315 |
284 // Number of valuators on the specific device. | 316 // Number of valuators on the specific device. |
285 int valuator_count_[kMaxDeviceNum]; | 317 int valuator_count_[kMaxDeviceNum]; |
286 | 318 |
287 // Index table to find the valuator for DataType on the specific device | 319 // Index table to find the valuator for DataType on the specific device |
288 // by valuator_lookup_[device_id][data_type]. | 320 // by valuator_lookup_[device_id][data_type]. |
289 std::vector<int> valuator_lookup_[kMaxDeviceNum]; | 321 std::vector<int> valuator_lookup_[kMaxDeviceNum]; |
290 | 322 |
323 // Index table to find the horizontal scroll valuator number from the device | |
324 // ID. | |
325 int scroll_horizontal_number_[kMaxDeviceNum]; | |
326 | |
327 // Index table to find the vertical scroll valuator number from the device | |
328 // ID. | |
329 int scroll_vertical_number_[kMaxDeviceNum]; | |
330 | |
331 // Index table to find the horizontal scroll increment from the device ID. | |
332 double scroll_horizontal_increment_[kMaxDeviceNum]; | |
333 | |
334 // Index table to find the vertical scroll increment from the device ID. | |
335 double scroll_vertical_increment_[kMaxDeviceNum]; | |
336 | |
337 // Current horizontal scroll position; used to find the difference between | |
338 // events. | |
339 double scroll_horizontal_position_[kMaxDeviceNum]; | |
340 | |
341 // Current vertical scroll position; used to find the difference between | |
342 // events. | |
343 double scroll_vertical_position_[kMaxDeviceNum]; | |
344 | |
345 // If true, then a horizontal scroll has been seen on this device. | |
346 bool scroll_horizontal_seen_[kMaxDeviceNum]; | |
347 | |
348 // If true, then a vertical scroll has been seen on this device. | |
349 bool scroll_vertical_seen_[kMaxDeviceNum]; | |
350 | |
sadrul
2014/12/22 17:11:12
Having to maintain all these scroll specific info
| |
291 // Index table to find the DataType for valuator on the specific device | 351 // Index table to find the DataType for valuator on the specific device |
292 // by data_type_lookup_[device_id][valuator]. | 352 // by data_type_lookup_[device_id][valuator]. |
293 std::vector<int> data_type_lookup_[kMaxDeviceNum]; | 353 std::vector<int> data_type_lookup_[kMaxDeviceNum]; |
294 | 354 |
295 // Index table to find the min & max value of the Valuator on a specific | 355 // Index table to find the min & max value of the Valuator on a specific |
296 // device. | 356 // device. |
297 std::vector<double> valuator_min_[kMaxDeviceNum]; | 357 std::vector<double> valuator_min_[kMaxDeviceNum]; |
298 std::vector<double> valuator_max_[kMaxDeviceNum]; | 358 std::vector<double> valuator_max_[kMaxDeviceNum]; |
299 | 359 |
300 // Table to keep track of the last seen value for the specified valuator for | 360 // Table to keep track of the last seen value for the specified valuator for |
(...skipping 14 matching lines...) Expand all Loading... | |
315 | 375 |
316 unsigned char button_map_[256]; | 376 unsigned char button_map_[256]; |
317 int button_map_count_; | 377 int button_map_count_; |
318 | 378 |
319 DISALLOW_COPY_AND_ASSIGN(DeviceDataManagerX11); | 379 DISALLOW_COPY_AND_ASSIGN(DeviceDataManagerX11); |
320 }; | 380 }; |
321 | 381 |
322 } // namespace ui | 382 } // namespace ui |
323 | 383 |
324 #endif // UI_EVENTS_X_DEVICE_DATA_MANAGER_X11_H_ | 384 #endif // UI_EVENTS_X_DEVICE_DATA_MANAGER_X11_H_ |
OLD | NEW |