Chromium Code Reviews| Index: ui/events/ozone/evdev/event_device_info.cc |
| diff --git a/ui/events/ozone/evdev/event_device_info.cc b/ui/events/ozone/evdev/event_device_info.cc |
| index aa877e0b18ae4f955bec42af2fbf167bef1841dc..14a0fa15e46c95565c1078570cb380cf13e83e80 100644 |
| --- a/ui/events/ozone/evdev/event_device_info.cc |
| +++ b/ui/events/ozone/evdev/event_device_info.cc |
| @@ -251,6 +251,11 @@ void EventDeviceInfo::SetDeviceType(InputDeviceType type) { |
| device_type_ = type; |
| } |
| +void EventDeviceInfo::SetId(uint16_t vendor_id, uint16_t product_id) { |
| + vendor_id_ = vendor_id; |
| + product_id_ = product_id; |
| +} |
| + |
| bool EventDeviceInfo::HasEventType(unsigned int type) const { |
| if (type > EV_MAX) |
| return false; |
| @@ -427,6 +432,22 @@ bool EventDeviceInfo::HasTouchscreen() const { |
| return HasAbsXY() && HasDirect(); |
| } |
| +bool EventDeviceInfo::HasGamepad() const { |
| + if (!HasEventType(EV_KEY)) |
| + return false; |
| + |
| + // If the device has gamepad button, and it's not keyboard or tablet, it will |
| + // be considered to be a gamepad. Note: this WILL have false positives and |
| + // false negatives. A concrete solution will use ID_INPUT_JOYSTICK with some |
| + // patch removing false positives. |
| + bool support_gamepad_btn = false; |
| + for (int key = BTN_JOYSTICK; key <= BTN_THUMBR; ++key) |
|
spang
2017/05/03 22:00:37
Please brace all multiline blocks such as the oute
jkwang
2017/05/05 00:07:45
Done.
|
| + if (HasKeyEvent(key)) |
| + support_gamepad_btn = true; |
| + |
| + return support_gamepad_btn && !HasTablet() && !HasKeyboard(); |
| +} |
| + |
| EventDeviceInfo::LegacyAbsoluteDeviceType |
| EventDeviceInfo::ProbeLegacyAbsoluteDevice() const { |
| if (!HasAbsXY()) |