Chromium Code Reviews| Index: ui/events/ozone/evdev/input_device_factory_evdev.cc |
| diff --git a/ui/events/ozone/evdev/input_device_factory_evdev.cc b/ui/events/ozone/evdev/input_device_factory_evdev.cc |
| index 6812283e9513478eb2b3c8a3d2d1deca6fa568d2..f6fe5c7ee960ce823fb8ce0baf182dd231dd64d8 100644 |
| --- a/ui/events/ozone/evdev/input_device_factory_evdev.cc |
| +++ b/ui/events/ozone/evdev/input_device_factory_evdev.cc |
| @@ -20,6 +20,7 @@ |
| #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" |
| #include "ui/events/ozone/evdev/event_converter_evdev_impl.h" |
| #include "ui/events/ozone/evdev/event_device_info.h" |
| +#include "ui/events/ozone/evdev/gamepad_event_converter_evdev.h" |
| #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h" |
| #include "ui/events/ozone/evdev/touch_event_converter_evdev.h" |
| @@ -113,6 +114,10 @@ std::unique_ptr<EventConverterEvdev> CreateConverter( |
| std::move(fd), params.path, params.id, params.cursor, devinfo, |
| params.dispatcher)); |
| + if (devinfo.HasGamepad()) |
|
spang
2017/04/13 00:52:20
The body is multiline; please add braces here.
jkwang
2017/04/19 19:42:23
Done.
|
| + return base::WrapUnique<EventConverterEvdev>(new GamepadEventConverterEvdev( |
| + std::move(fd), params.path, params.id, devinfo, params.dispatcher)); |
| + |
| // Everything else: use EventConverterEvdevImpl. |
| return base::WrapUnique<EventConverterEvdevImpl>( |
| new EventConverterEvdevImpl(std::move(fd), params.path, params.id, |
| @@ -367,6 +372,9 @@ void InputDeviceFactoryEvdev::UpdateDirtyFlags( |
| if (converter->HasTouchpad()) |
| touchpad_list_dirty_ = true; |
| + |
| + if (converter->HasGamepad()) |
| + gamepad_list_dirty_ = true; |
| } |
| void InputDeviceFactoryEvdev::NotifyDevicesUpdated() { |
| @@ -380,6 +388,8 @@ void InputDeviceFactoryEvdev::NotifyDevicesUpdated() { |
| NotifyMouseDevicesUpdated(); |
| if (touchpad_list_dirty_) |
| NotifyTouchpadDevicesUpdated(); |
| + if (gamepad_list_dirty_) |
| + NotifyGamepadDevicesUpdated(); |
| if (!startup_devices_opened_) { |
| dispatcher_->DispatchDeviceListsComplete(); |
| startup_devices_opened_ = true; |
| @@ -388,6 +398,7 @@ void InputDeviceFactoryEvdev::NotifyDevicesUpdated() { |
| keyboard_list_dirty_ = false; |
| mouse_list_dirty_ = false; |
| touchpad_list_dirty_ = false; |
| + gamepad_list_dirty_ = false; |
| } |
| void InputDeviceFactoryEvdev::NotifyTouchscreensUpdated() { |
| @@ -438,6 +449,17 @@ void InputDeviceFactoryEvdev::NotifyTouchpadDevicesUpdated() { |
| dispatcher_->DispatchTouchpadDevicesUpdated(touchpads); |
| } |
| +void InputDeviceFactoryEvdev::NotifyGamepadDevicesUpdated() { |
| + std::vector<InputDevice> gamepads; |
| + for (auto it = converters_.begin(); it != converters_.end(); ++it) { |
| + if (it->second->HasGamepad()) { |
| + gamepads.push_back(it->second->input_device()); |
| + } |
| + } |
| + |
| + dispatcher_->DispatchGamepadDevicesUpdated(gamepads); |
| +} |
| + |
| void InputDeviceFactoryEvdev::SetIntPropertyForOneType( |
| const EventDeviceType type, |
| const std::string& name, |