| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 132 |
| 133 // Get a datum of the specified type. Return true and the value | 133 // 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 | 134 // 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 | 135 // 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_). | 136 // cached one (see the comment above last_seen_valuator_). |
| 137 bool GetEventData(const XEvent& xev, const DataType type, double* value); | 137 bool GetEventData(const XEvent& xev, const DataType type, double* value); |
| 138 | 138 |
| 139 // Check if the event is an XI input event in the strict sense | 139 // Check if the event is an XI input event in the strict sense |
| 140 // (i.e. XIDeviceEvent). This rules out things like hierarchy changes, | 140 // (i.e. XIDeviceEvent). This rules out things like hierarchy changes, |
| 141 /// device changes, property changes and so on. | 141 /// device changes, property changes and so on. |
| 142 bool IsXIDeviceEvent(const base::NativeEvent& native_event) const; | 142 bool IsXIDeviceEvent(const XEvent* 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 XEvent* 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 XEvent* native_event) const; |
| 151 | 151 |
| 152 // Check if the event is one of the CMT gesture events (scroll, fling, | 152 // Check if the event is one of the CMT gesture events (scroll, fling, |
| 153 // metrics etc.). | 153 // metrics etc.). |
| 154 bool IsCMTGestureEvent(const base::NativeEvent& native_event) const; | 154 bool IsCMTGestureEvent(const XEvent* native_event) const; |
| 155 | 155 |
| 156 // Returns true if the event is of the specific type, false if not. | 156 // Returns true if the event is of the specific type, false if not. |
| 157 bool IsScrollEvent(const base::NativeEvent& native_event) const; | 157 bool IsScrollEvent(const XEvent* native_event) const; |
| 158 bool IsFlingEvent(const base::NativeEvent& native_event) const; | 158 bool IsFlingEvent(const XEvent* native_event) const; |
| 159 bool IsCMTMetricsEvent(const base::NativeEvent& native_event) const; | 159 bool IsCMTMetricsEvent(const XEvent* native_event) const; |
| 160 | 160 |
| 161 // Returns true if the event has CMT start/end timestamps. | 161 // Returns true if the event has CMT start/end timestamps. |
| 162 bool HasGestureTimes(const base::NativeEvent& native_event) const; | 162 bool HasGestureTimes(const XEvent* native_event) const; |
| 163 | 163 |
| 164 // Extract data from a scroll event (a motion event with the necessary | 164 // Extract data from a scroll event (a motion event with the necessary |
| 165 // valuators). User must first verify the event type with IsScrollEvent. | 165 // valuators). User must first verify the event type with IsScrollEvent. |
| 166 // Pointers shouldn't be NULL. | 166 // Pointers shouldn't be NULL. |
| 167 void GetScrollOffsets(const base::NativeEvent& native_event, | 167 void GetScrollOffsets(const XEvent* native_event, |
| 168 float* x_offset, | 168 float* x_offset, |
| 169 float* y_offset, | 169 float* y_offset, |
| 170 float* x_offset_ordinal, | 170 float* x_offset_ordinal, |
| 171 float* y_offset_ordinal, | 171 float* y_offset_ordinal, |
| 172 int* finger_count); | 172 int* finger_count); |
| 173 | 173 |
| 174 // Extract data from a fling event. User must first verify the event type | 174 // Extract data from a fling event. User must first verify the event type |
| 175 // with IsFlingEvent. Pointers shouldn't be NULL. | 175 // with IsFlingEvent. Pointers shouldn't be NULL. |
| 176 void GetFlingData(const base::NativeEvent& native_event, | 176 void GetFlingData(const XEvent* native_event, |
| 177 float* vx, | 177 float* vx, |
| 178 float* vy, | 178 float* vy, |
| 179 float* vx_ordinal, | 179 float* vx_ordinal, |
| 180 float* vy_ordinal, | 180 float* vy_ordinal, |
| 181 bool* is_cancel); | 181 bool* is_cancel); |
| 182 | 182 |
| 183 // Extract data from a CrOS metrics gesture event. User must first verify | 183 // Extract data from a CrOS metrics gesture event. User must first verify |
| 184 // the event type with IsCMTMetricsEvent. Pointers shouldn't be NULL. | 184 // the event type with IsCMTMetricsEvent. Pointers shouldn't be NULL. |
| 185 void GetMetricsData(const base::NativeEvent& native_event, | 185 void GetMetricsData(const XEvent* native_event, |
| 186 GestureMetricsType* type, | 186 GestureMetricsType* type, |
| 187 float* data1, | 187 float* data1, |
| 188 float* data2); | 188 float* data2); |
| 189 | 189 |
| 190 // Returns the mapped button. | 190 // Returns the mapped button. |
| 191 int GetMappedButton(int button); | 191 int GetMappedButton(int button); |
| 192 | 192 |
| 193 // Updates button mapping. This is usually called when a MappingNotify event | 193 // Updates button mapping. This is usually called when a MappingNotify event |
| 194 // is received. | 194 // is received. |
| 195 void UpdateButtonMap(); | 195 void UpdateButtonMap(); |
| 196 | 196 |
| 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 XEvent* 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(unsigned int deviceid, |
| 208 const DataType type, | 208 const DataType type, |
| 209 double* value); | 209 double* value); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 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(unsigned int deviceid); |
| 237 void EnableDevice(unsigned int deviceid); | 237 void EnableDevice(unsigned 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 XEvent* native_event); |
| 241 | 241 |
| 242 protected: | 242 protected: |
| 243 // DeviceHotplugEventObserver: | 243 // DeviceHotplugEventObserver: |
| 244 void OnKeyboardDevicesUpdated( | 244 void OnKeyboardDevicesUpdated( |
| 245 const std::vector<KeyboardDevice>& devices) override; | 245 const std::vector<KeyboardDevice>& devices) override; |
| 246 | 246 |
| 247 private: | 247 private: |
| 248 DeviceDataManagerX11(); | 248 DeviceDataManagerX11(); |
| 249 ~DeviceDataManagerX11() override; | 249 ~DeviceDataManagerX11() override; |
| 250 | 250 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 | 315 |
| 316 unsigned char button_map_[256]; | 316 unsigned char button_map_[256]; |
| 317 int button_map_count_; | 317 int button_map_count_; |
| 318 | 318 |
| 319 DISALLOW_COPY_AND_ASSIGN(DeviceDataManagerX11); | 319 DISALLOW_COPY_AND_ASSIGN(DeviceDataManagerX11); |
| 320 }; | 320 }; |
| 321 | 321 |
| 322 } // namespace ui | 322 } // namespace ui |
| 323 | 323 |
| 324 #endif // UI_EVENTS_DEVICES_X11_DEVICE_DATA_MANAGER_X11_H_ | 324 #endif // UI_EVENTS_DEVICES_X11_DEVICE_DATA_MANAGER_X11_H_ |
| OLD | NEW |