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 3fea5ecbf1fa283060b78b29c3d3e870364fd833..508e4fb03111aa2b2fa7e602e953d73a13f8b74e 100644 |
| --- a/ui/events/ozone/evdev/input_device_factory_evdev.cc |
| +++ b/ui/events/ozone/evdev/input_device_factory_evdev.cc |
| @@ -62,6 +62,28 @@ bool UseGesturesLibraryForDevice(const EventDeviceInfo& devinfo) { |
| return false; |
| } |
| + |
| +void SetGestureIntProperty(GesturePropertyProvider* provider, |
| + int id, |
| + const std::string& name, |
| + int value) { |
| + GesturesProp* property = provider->GetProperty(id, name); |
| + if (property) { |
| + std::vector<int> values(1, value); |
| + property->SetIntValue(values); |
| + } |
| +} |
| + |
| +void SetGestureBoolProperty(GesturePropertyProvider* provider, |
| + int id, |
| + const std::string& name, |
| + bool value) { |
| + GesturesProp* property = provider->GetProperty(id, name); |
| + if (property) { |
| + std::vector<bool> values(1, value); |
| + property->SetBoolValue(values); |
| + } |
| +} |
| #endif |
| scoped_ptr<EventConverterEvdev> CreateConverter( |
| @@ -159,9 +181,6 @@ void CloseInputDevice(const base::FilePath& path, |
| InputDeviceFactoryEvdev::InputDeviceFactoryEvdev( |
| DeviceEventDispatcherEvdev* dispatcher, |
| scoped_refptr<base::SingleThreadTaskRunner> dispatch_runner, |
| -#if defined(USE_EVDEV_GESTURES) |
| - GesturePropertyProvider* gesture_property_provider, |
|
alexst (slow to review)
2015/01/27 20:25:28
So this is never used and created anew below, one
|
| -#endif |
| CursorDelegateEvdev* cursor) |
| : ui_task_runner_(dispatch_runner), |
| cursor_(cursor), |
| @@ -185,7 +204,7 @@ void InputDeviceFactoryEvdev::AddInputDevice(int id, |
| params->dispatcher = dispatcher_; |
| #if defined(USE_EVDEV_GESTURES) |
| - params->gesture_property_provider = gesture_property_provider_; |
| + params->gesture_property_provider = gesture_property_provider_.get(); |
| #endif |
| OpenInputDeviceReplyCallback reply_callback = |
| @@ -287,6 +306,45 @@ void InputDeviceFactoryEvdev::EnableInternalKeyboard() { |
| } |
| } |
| +bool InputDeviceFactoryEvdev::HasMouse() { |
| + return GetDeviceIdsByType(DT_MOUSE, NULL); |
| +} |
| + |
| +bool InputDeviceFactoryEvdev::HasTouchpad() { |
| + return GetDeviceIdsByType(DT_TOUCHPAD, NULL); |
| +} |
| + |
| +void InputDeviceFactoryEvdev::SetTouchpadSensitivity(int value) { |
| + SetIntPropertyForOneType(DT_TOUCHPAD, "Pointer Sensitivity", value); |
| + SetIntPropertyForOneType(DT_TOUCHPAD, "Scroll Sensitivity", value); |
| +} |
| + |
| +void InputDeviceFactoryEvdev::SetTapToClick(bool enabled) { |
| + SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Enable", enabled); |
| +} |
| + |
| +void InputDeviceFactoryEvdev::SetThreeFingerClick(bool enabled) { |
| + SetBoolPropertyForOneType(DT_TOUCHPAD, "T5R2 Three Finger Click Enable", |
| + enabled); |
| +} |
| + |
| +void InputDeviceFactoryEvdev::SetTapDragging(bool enabled) { |
| + SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Drag Enable", enabled); |
| +} |
| + |
| +void InputDeviceFactoryEvdev::SetNaturalScroll(bool enabled) { |
| + SetBoolPropertyForOneType(DT_MULTITOUCH, "Australian Scrolling", enabled); |
| +} |
| + |
| +void InputDeviceFactoryEvdev::SetMouseSensitivity(int value) { |
| + SetIntPropertyForOneType(DT_MOUSE, "Pointer Sensitivity", value); |
| + SetIntPropertyForOneType(DT_MOUSE, "Scroll Sensitivity", value); |
| +} |
| + |
| +void InputDeviceFactoryEvdev::SetTapToClickPaused(bool state) { |
| + SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Paused", state); |
| +} |
| + |
| void InputDeviceFactoryEvdev::NotifyDeviceChange( |
| const EventConverterEvdev& converter) { |
| if (converter.HasTouchscreen()) |
| @@ -343,4 +401,35 @@ bool InputDeviceFactoryEvdev::GetDeviceIdsByType(const EventDeviceType type, |
| return !ids.empty(); |
| } |
| +void InputDeviceFactoryEvdev::SetIntPropertyForOneType( |
| + const EventDeviceType type, |
| + const std::string& name, |
| + int value) { |
| +#if defined(USE_EVDEV_GESTURES) |
| + std::vector<int> ids; |
| + gesture_property_provider_->GetDeviceIdsByType(type, &ids); |
| + for (size_t i = 0; i < ids.size(); ++i) { |
| + SetGestureIntProperty(gesture_property_provider_.get(), ids[i], name, |
| + value); |
| + } |
| +#endif |
| + // In the future, we may add property setting codes for other non-gesture |
| + // devices. One example would be keyboard settings. |
| + // TODO(sheckylin): See http://crbug.com/398518 for example. |
| +} |
| + |
| +void InputDeviceFactoryEvdev::SetBoolPropertyForOneType( |
| + const EventDeviceType type, |
| + const std::string& name, |
| + bool value) { |
| +#if defined(USE_EVDEV_GESTURES) |
| + std::vector<int> ids; |
| + gesture_property_provider_->GetDeviceIdsByType(type, &ids); |
| + for (size_t i = 0; i < ids.size(); ++i) { |
| + SetGestureBoolProperty(gesture_property_provider_.get(), ids[i], name, |
| + value); |
| + } |
| +#endif |
| +} |
| + |
| } // namespace ui |