Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: ui/events/ozone/evdev/input_controller_evdev.cc

Issue 868213002: [PATCH 7/11] ozone: evdev: Move GesturePropertyProvider to InputDeviceFactoryEvdev (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates for events_unittests Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "ui/events/ozone/evdev/input_controller_evdev.h" 5 #include "ui/events/ozone/evdev/input_controller_evdev.h"
6 6
7 #include <linux/input.h> 7 #include <linux/input.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ui/events/ozone/evdev/input_device_factory_evdev.h" 10 #include "ui/events/ozone/evdev/input_device_factory_evdev.h"
11 #include "ui/events/ozone/evdev/keyboard_evdev.h" 11 #include "ui/events/ozone/evdev/keyboard_evdev.h"
12 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h" 12 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h"
13 13
14 #if defined(USE_EVDEV_GESTURES)
15 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h"
16 #endif
17
18 namespace ui { 14 namespace ui {
19 15
20 namespace { 16 InputControllerEvdev::InputControllerEvdev(KeyboardEvdev* keyboard,
21 17 MouseButtonMapEvdev* button_map)
22 #if defined(USE_EVDEV_GESTURES)
23 void SetGestureIntProperty(GesturePropertyProvider* provider,
24 int id,
25 const std::string& name,
26 int value) {
27 GesturesProp* property = provider->GetProperty(id, name);
28 if (property) {
29 std::vector<int> values(1, value);
30 property->SetIntValue(values);
31 }
32 }
33
34 void SetGestureBoolProperty(GesturePropertyProvider* provider,
35 int id,
36 const std::string& name,
37 bool value) {
38 GesturesProp* property = provider->GetProperty(id, name);
39 if (property) {
40 std::vector<bool> values(1, value);
41 property->SetBoolValue(values);
42 }
43 }
44 #endif
45
46 } // namespace
47
48 InputControllerEvdev::InputControllerEvdev(
49 KeyboardEvdev* keyboard,
50 MouseButtonMapEvdev* button_map
51 #if defined(USE_EVDEV_GESTURES)
52 ,
53 GesturePropertyProvider* gesture_property_provider
54 #endif
55 )
56 : input_device_factory_(nullptr), 18 : input_device_factory_(nullptr),
57 keyboard_(keyboard), 19 keyboard_(keyboard),
58 button_map_(button_map) 20 button_map_(button_map) {
59 #if defined(USE_EVDEV_GESTURES)
60 ,
61 gesture_property_provider_(gesture_property_provider)
62 #endif
63 {
64 } 21 }
65 22
66 InputControllerEvdev::~InputControllerEvdev() { 23 InputControllerEvdev::~InputControllerEvdev() {
67 } 24 }
68 25
69 void InputControllerEvdev::SetInputDeviceFactory( 26 void InputControllerEvdev::SetInputDeviceFactory(
70 InputDeviceFactoryEvdev* input_device_factory) { 27 InputDeviceFactoryEvdev* input_device_factory) {
71 input_device_factory_ = input_device_factory; 28 input_device_factory_ = input_device_factory;
72 } 29 }
73 30
74 bool InputControllerEvdev::HasMouse() { 31 bool InputControllerEvdev::HasMouse() {
75 if (!input_device_factory_) 32 if (!input_device_factory_)
76 return false; 33 return false;
77 return input_device_factory_->GetDeviceIdsByType(DT_MOUSE, NULL); 34 return input_device_factory_->HasMouse();
78 } 35 }
79 36
80 bool InputControllerEvdev::HasTouchpad() { 37 bool InputControllerEvdev::HasTouchpad() {
81 if (!input_device_factory_) 38 if (!input_device_factory_)
82 return false; 39 return false;
83 return input_device_factory_->GetDeviceIdsByType(DT_TOUCHPAD, NULL); 40 return input_device_factory_->HasTouchpad();
84 } 41 }
85 42
86 bool InputControllerEvdev::IsCapsLockEnabled() { 43 bool InputControllerEvdev::IsCapsLockEnabled() {
87 return false; 44 return false;
88 } 45 }
89 46
90 void InputControllerEvdev::SetCapsLockEnabled(bool enabled) { 47 void InputControllerEvdev::SetCapsLockEnabled(bool enabled) {
91 NOTIMPLEMENTED(); 48 NOTIMPLEMENTED();
92 } 49 }
93 50
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 if (input_device_factory_) 85 if (input_device_factory_)
129 input_device_factory_->DisableInternalKeyboardExceptKeys( 86 input_device_factory_->DisableInternalKeyboardExceptKeys(
130 excepted_keys.Pass()); 87 excepted_keys.Pass());
131 } 88 }
132 89
133 void InputControllerEvdev::EnableInternalKeyboard() { 90 void InputControllerEvdev::EnableInternalKeyboard() {
134 if (input_device_factory_) 91 if (input_device_factory_)
135 input_device_factory_->EnableInternalKeyboard(); 92 input_device_factory_->EnableInternalKeyboard();
136 } 93 }
137 94
138 void InputControllerEvdev::SetIntPropertyForOneType(const EventDeviceType type,
139 const std::string& name,
140 int value) {
141 if (!input_device_factory_)
142 return;
143 #if defined(USE_EVDEV_GESTURES)
144 std::vector<int> ids;
145 input_device_factory_->GetDeviceIdsByType(type, &ids);
146 for (size_t i = 0; i < ids.size(); ++i) {
147 SetGestureIntProperty(gesture_property_provider_, ids[i], name, value);
148 }
149 #endif
150 // In the future, we may add property setting codes for other non-gesture
151 // devices. One example would be keyboard settings.
152 // TODO(sheckylin): See http://crbug.com/398518 for example.
153 }
154
155 void InputControllerEvdev::SetBoolPropertyForOneType(const EventDeviceType type,
156 const std::string& name,
157 bool value) {
158 if (!input_device_factory_)
159 return;
160 #if defined(USE_EVDEV_GESTURES)
161 std::vector<int> ids;
162 input_device_factory_->GetDeviceIdsByType(type, &ids);
163 for (size_t i = 0; i < ids.size(); ++i) {
164 SetGestureBoolProperty(gesture_property_provider_, ids[i], name, value);
165 }
166 #endif
167 }
168
169 void InputControllerEvdev::SetTouchpadSensitivity(int value) { 95 void InputControllerEvdev::SetTouchpadSensitivity(int value) {
170 SetIntPropertyForOneType(DT_TOUCHPAD, "Pointer Sensitivity", value); 96 if (input_device_factory_)
171 SetIntPropertyForOneType(DT_TOUCHPAD, "Scroll Sensitivity", value); 97 input_device_factory_->SetTouchpadSensitivity(value);
172 } 98 }
173 99
174 void InputControllerEvdev::SetTapToClick(bool enabled) { 100 void InputControllerEvdev::SetTapToClick(bool enabled) {
175 SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Enable", enabled); 101 if (input_device_factory_)
102 input_device_factory_->SetTapToClick(enabled);
176 } 103 }
177 104
178 void InputControllerEvdev::SetThreeFingerClick(bool enabled) { 105 void InputControllerEvdev::SetThreeFingerClick(bool enabled) {
179 SetBoolPropertyForOneType(DT_TOUCHPAD, "T5R2 Three Finger Click Enable", 106 if (input_device_factory_)
180 enabled); 107 input_device_factory_->SetThreeFingerClick(enabled);
181 } 108 }
182 109
183 void InputControllerEvdev::SetTapDragging(bool enabled) { 110 void InputControllerEvdev::SetTapDragging(bool enabled) {
184 SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Drag Enable", enabled); 111 if (input_device_factory_)
112 input_device_factory_->SetTapDragging(enabled);
185 } 113 }
186 114
187 void InputControllerEvdev::SetNaturalScroll(bool enabled) { 115 void InputControllerEvdev::SetNaturalScroll(bool enabled) {
188 SetBoolPropertyForOneType(DT_MULTITOUCH, "Australian Scrolling", enabled); 116 if (input_device_factory_)
117 input_device_factory_->SetNaturalScroll(enabled);
189 } 118 }
190 119
191 void InputControllerEvdev::SetMouseSensitivity(int value) { 120 void InputControllerEvdev::SetMouseSensitivity(int value) {
192 SetIntPropertyForOneType(DT_MOUSE, "Pointer Sensitivity", value); 121 if (input_device_factory_)
193 SetIntPropertyForOneType(DT_MOUSE, "Scroll Sensitivity", value); 122 input_device_factory_->SetMouseSensitivity(value);
194 } 123 }
195 124
196 void InputControllerEvdev::SetPrimaryButtonRight(bool right) { 125 void InputControllerEvdev::SetPrimaryButtonRight(bool right) {
197 button_map_->UpdateButtonMap(BTN_LEFT, right ? BTN_RIGHT : BTN_LEFT); 126 button_map_->UpdateButtonMap(BTN_LEFT, right ? BTN_RIGHT : BTN_LEFT);
198 button_map_->UpdateButtonMap(BTN_RIGHT, right ? BTN_LEFT : BTN_RIGHT); 127 button_map_->UpdateButtonMap(BTN_RIGHT, right ? BTN_LEFT : BTN_RIGHT);
199 } 128 }
200 129
201 void InputControllerEvdev::SetTapToClickPaused(bool state) { 130 void InputControllerEvdev::SetTapToClickPaused(bool state) {
202 SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Paused", state); 131 if (input_device_factory_)
132 input_device_factory_->SetTapToClickPaused(state);
203 } 133 }
204 134
205 } // namespace ui 135 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698