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

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

Issue 863353003: [PATCH 6/11] ozone: evdev: Factor device I/O out of EventFactoryOzone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile with USE_EVDEV_GESTURES Created 5 years, 10 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
« no previous file with comments | « ui/events/ozone/evdev/input_device_factory_evdev.h ('k') | ui/events/ozone/events_ozone.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/event_factory_evdev.h" 5 #include "ui/events/ozone/evdev/input_device_factory_evdev.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <linux/input.h> 8 #include <linux/input.h>
9 9
10 #include "base/bind.h" 10 #include "base/debug/trace_event.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/task_runner.h"
13 #include "base/thread_task_runner_handle.h"
14 #include "base/threading/worker_pool.h" 12 #include "base/threading/worker_pool.h"
15 #include "base/time/time.h" 13 #include "base/time/time.h"
16 #include "base/trace_event/trace_event.h"
17 #include "ui/events/devices/device_data_manager.h" 14 #include "ui/events/devices/device_data_manager.h"
18 #include "ui/events/devices/device_util_linux.h" 15 #include "ui/events/devices/device_util_linux.h"
19 #include "ui/events/devices/input_device.h"
20 #include "ui/events/ozone/device/device_event.h"
21 #include "ui/events/ozone/device/device_manager.h"
22 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
23 #include "ui/events/ozone/evdev/event_converter_evdev_impl.h" 16 #include "ui/events/ozone/evdev/event_converter_evdev_impl.h"
24 #include "ui/events/ozone/evdev/input_injector_evdev.h" 17 #include "ui/events/ozone/evdev/event_device_info.h"
25 #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h" 18 #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h"
26 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h" 19 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h"
27 20
28 #if defined(USE_EVDEV_GESTURES) 21 #if defined(USE_EVDEV_GESTURES)
29 #include "ui/events/ozone/evdev/libgestures_glue/event_reader_libevdev_cros.h" 22 #include "ui/events/ozone/evdev/libgestures_glue/event_reader_libevdev_cros.h"
30 #include "ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cr os.h" 23 #include "ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cr os.h"
31 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h" 24 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h"
32 #endif 25 #endif
33 26
34 #ifndef EVIOCSCLOCKID 27 #ifndef EVIOCSCLOCKID
35 #define EVIOCSCLOCKID _IOW('E', 0xa0, int) 28 #define EVIOCSCLOCKID _IOW('E', 0xa0, int)
36 #endif 29 #endif
37 30
38 namespace ui { 31 namespace ui {
39 32
40 namespace { 33 namespace {
41 34
42 typedef base::Callback<void(scoped_ptr<EventConverterEvdev>)> 35 typedef base::Callback<void(scoped_ptr<EventConverterEvdev>)>
43 OpenInputDeviceReplyCallback; 36 OpenInputDeviceReplyCallback;
44 37
45 struct OpenInputDeviceParams { 38 struct OpenInputDeviceParams {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // therefore should be run on a thread where latency is not critical. We 149 // therefore should be run on a thread where latency is not critical. We
157 // run it on the FILE thread. 150 // run it on the FILE thread.
158 void CloseInputDevice(const base::FilePath& path, 151 void CloseInputDevice(const base::FilePath& path,
159 scoped_ptr<EventConverterEvdev> converter) { 152 scoped_ptr<EventConverterEvdev> converter) {
160 TRACE_EVENT1("ozone", "CloseInputDevice", "path", path.value()); 153 TRACE_EVENT1("ozone", "CloseInputDevice", "path", path.value());
161 converter.reset(); 154 converter.reset();
162 } 155 }
163 156
164 } // namespace 157 } // namespace
165 158
166 EventFactoryEvdev::EventFactoryEvdev(CursorDelegateEvdev* cursor, 159 InputDeviceFactoryEvdev::InputDeviceFactoryEvdev(
167 DeviceManager* device_manager, 160 DeviceEventDispatcherEvdev* dispatcher,
168 KeyboardLayoutEngine* keyboard_layout) 161 scoped_refptr<base::SingleThreadTaskRunner> dispatch_runner,
169 : last_device_id_(0), 162 #if defined(USE_EVDEV_GESTURES)
170 device_manager_(device_manager), 163 GesturePropertyProvider* gesture_property_provider,
171 dispatch_callback_( 164 #endif
172 base::Bind(&EventFactoryEvdev::PostUiEvent, base::Unretained(this))), 165 CursorDelegateEvdev* cursor)
173 keyboard_(&modifiers_, keyboard_layout, dispatch_callback_), 166 : ui_task_runner_(dispatch_runner),
174 cursor_(cursor), 167 cursor_(cursor),
175 #if defined(USE_EVDEV_GESTURES) 168 #if defined(USE_EVDEV_GESTURES)
176 gesture_property_provider_(new GesturePropertyProvider), 169 gesture_property_provider_(gesture_property_provider),
177 #endif 170 #endif
178 input_controller_(this, 171 dispatcher_(dispatcher),
179 &keyboard_,
180 &button_map_
181 #if defined(USE_EVDEV_GESTURES)
182 ,
183 gesture_property_provider_.get()
184 #endif
185 ),
186 initialized_(false),
187 weak_ptr_factory_(this) { 172 weak_ptr_factory_(this) {
188 DCHECK(device_manager_);
189 } 173 }
190 174
191 EventFactoryEvdev::~EventFactoryEvdev() { STLDeleteValues(&converters_); } 175 InputDeviceFactoryEvdev::~InputDeviceFactoryEvdev() {
192 176 STLDeleteValues(&converters_);
193 void EventFactoryEvdev::Init() {
194 DCHECK(!initialized_);
195 ui_task_runner_ = base::ThreadTaskRunnerHandle::Get();
196
197 // Scan & monitor devices.
198 device_manager_->AddObserver(this);
199 device_manager_->ScanDevices(this);
200
201 initialized_ = true;
202 } 177 }
203 178
204 scoped_ptr<SystemInputInjector> EventFactoryEvdev::CreateSystemInputInjector() { 179 void InputDeviceFactoryEvdev::AddInputDevice(int id,
205 return make_scoped_ptr(new InputInjectorEvdev( 180 const base::FilePath& path) {
206 &modifiers_, cursor_, &keyboard_, dispatch_callback_)); 181 scoped_ptr<OpenInputDeviceParams> params(new OpenInputDeviceParams);
182 params->id = id;
183 params->path = path;
184 params->cursor = cursor_;
185 params->dispatcher = dispatcher_;
186
187 #if defined(USE_EVDEV_GESTURES)
188 params->gesture_property_provider = gesture_property_provider_;
189 #endif
190
191 OpenInputDeviceReplyCallback reply_callback =
192 base::Bind(&InputDeviceFactoryEvdev::AttachInputDevice,
193 weak_ptr_factory_.GetWeakPtr());
194
195 // Dispatch task to open from the worker pool, since open may block.
196 base::WorkerPool::PostTask(FROM_HERE,
197 base::Bind(&OpenInputDevice, base::Passed(&params),
198 ui_task_runner_, reply_callback),
199 true /* task_is_slow */);
207 } 200 }
208 201
209 void EventFactoryEvdev::DispatchKeyEvent(const KeyEventParams& params) { 202 void InputDeviceFactoryEvdev::RemoveInputDevice(const base::FilePath& path) {
210 keyboard_.OnKeyChange(params.code, params.down); 203 DetachInputDevice(path);
211 } 204 }
212 205
213 void EventFactoryEvdev::DispatchMouseMoveEvent( 206 void InputDeviceFactoryEvdev::AttachInputDevice(
214 const MouseMoveEventParams& params) {
215 scoped_ptr<MouseEvent> event(new MouseEvent(ui::ET_MOUSE_MOVED,
216 params.location, params.location,
217 modifiers_.GetModifierFlags(),
218 /* changed_button_flags */ 0));
219 event->set_source_device_id(params.device_id);
220 PostUiEvent(event.Pass());
221 }
222
223 void EventFactoryEvdev::DispatchMouseButtonEvent(
224 const MouseButtonEventParams& params) {
225 // Mouse buttons can be remapped, touchpad taps & clicks cannot.
226 unsigned int button = params.button;
227 if (params.allow_remap)
228 button = button_map_.GetMappedButton(button);
229
230 int modifier = EVDEV_MODIFIER_NONE;
231 switch (button) {
232 case BTN_LEFT:
233 modifier = EVDEV_MODIFIER_LEFT_MOUSE_BUTTON;
234 break;
235 case BTN_RIGHT:
236 modifier = EVDEV_MODIFIER_RIGHT_MOUSE_BUTTON;
237 break;
238 case BTN_MIDDLE:
239 modifier = EVDEV_MODIFIER_MIDDLE_MOUSE_BUTTON;
240 break;
241 default:
242 return;
243 }
244
245 int flag = modifiers_.GetEventFlagFromModifier(modifier);
246 modifiers_.UpdateModifier(modifier, params.down);
247
248 scoped_ptr<MouseEvent> event(new MouseEvent(
249 params.down ? ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED,
250 params.location, params.location, modifiers_.GetModifierFlags() | flag,
251 /* changed_button_flags */ flag));
252 event->set_source_device_id(params.device_id);
253 PostUiEvent(event.Pass());
254 }
255
256 void EventFactoryEvdev::DispatchMouseWheelEvent(
257 const MouseWheelEventParams& params) {
258 scoped_ptr<MouseWheelEvent> event(new MouseWheelEvent(
259 params.delta, params.location, params.location,
260 modifiers_.GetModifierFlags(), 0 /* changed_button_flags */));
261 event->set_source_device_id(params.device_id);
262 PostUiEvent(event.Pass());
263 }
264
265 void EventFactoryEvdev::DispatchScrollEvent(const ScrollEventParams& params) {
266 scoped_ptr<ScrollEvent> event(new ScrollEvent(
267 params.type, params.location, params.timestamp,
268 modifiers_.GetModifierFlags(), params.delta.x(), params.delta.y(),
269 params.ordinal_delta.x(), params.ordinal_delta.y(), params.finger_count));
270 event->set_source_device_id(params.device_id);
271 PostUiEvent(event.Pass());
272 }
273
274 void EventFactoryEvdev::DispatchTouchEvent(const TouchEventParams& params) {
275 float x = params.location.x();
276 float y = params.location.y();
277 double radius_x = params.radii.x();
278 double radius_y = params.radii.y();
279
280 // Transform the event to align touches to the image based on display mode.
281 DeviceDataManager::GetInstance()->ApplyTouchTransformer(params.device_id, &x,
282 &y);
283 DeviceDataManager::GetInstance()->ApplyTouchRadiusScale(params.device_id,
284 &radius_x);
285 DeviceDataManager::GetInstance()->ApplyTouchRadiusScale(params.device_id,
286 &radius_y);
287
288 scoped_ptr<TouchEvent> touch_event(new TouchEvent(
289 params.type, gfx::PointF(x, y),
290 /* flags */ 0, params.touch_id, params.timestamp, radius_x, radius_y,
291 /* angle */ 0., params.pressure));
292 touch_event->set_source_device_id(params.device_id);
293 PostUiEvent(touch_event.Pass());
294 }
295
296 void EventFactoryEvdev::PostUiEvent(scoped_ptr<Event> event) {
297 base::ThreadTaskRunnerHandle::Get()->PostTask(
298 FROM_HERE,
299 base::Bind(&EventFactoryEvdev::DispatchUiEventTask,
300 weak_ptr_factory_.GetWeakPtr(),
301 base::Passed(&event)));
302 }
303
304 void EventFactoryEvdev::DispatchUiEventTask(scoped_ptr<Event> event) {
305 DispatchEvent(event.get());
306 }
307
308 void EventFactoryEvdev::AttachInputDevice(
309 scoped_ptr<EventConverterEvdev> converter) { 207 scoped_ptr<EventConverterEvdev> converter) {
310 const base::FilePath& path = converter->path(); 208 const base::FilePath& path = converter->path();
311 209
312 TRACE_EVENT1("ozone", "AttachInputDevice", "path", path.value()); 210 TRACE_EVENT1("ozone", "AttachInputDevice", "path", path.value());
313 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); 211 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
314 212
315 // If we have an existing device, detach it. We don't want two 213 // If we have an existing device, detach it. We don't want two
316 // devices with the same name open at the same time. 214 // devices with the same name open at the same time.
317 if (converters_[path]) 215 if (converters_[path])
318 DetachInputDevice(path); 216 DetachInputDevice(path);
319 217
320 // Add initialized device to map. 218 // Add initialized device to map.
321 converters_[path] = converter.release(); 219 converters_[path] = converter.release();
322 converters_[path]->Start(); 220 converters_[path]->Start();
323 221
324 NotifyDeviceChange(*converters_[path]); 222 NotifyDeviceChange(*converters_[path]);
325 } 223 }
326 224
327 void EventFactoryEvdev::OnDeviceEvent(const DeviceEvent& event) { 225 void InputDeviceFactoryEvdev::DetachInputDevice(const base::FilePath& path) {
328 if (event.device_type() != DeviceEvent::INPUT)
329 return;
330
331 switch (event.action_type()) {
332 case DeviceEvent::ADD:
333 case DeviceEvent::CHANGE: {
334 TRACE_EVENT1("ozone", "OnDeviceAdded", "path", event.path().value());
335
336 scoped_ptr<OpenInputDeviceParams> params(new OpenInputDeviceParams);
337 params->id = NextDeviceId();
338 params->path = event.path();
339 params->cursor = cursor_;
340 params->dispatcher = this;
341
342 #if defined(USE_EVDEV_GESTURES)
343 params->gesture_property_provider = gesture_property_provider_.get();
344 #endif
345
346 OpenInputDeviceReplyCallback reply_callback =
347 base::Bind(&EventFactoryEvdev::AttachInputDevice,
348 weak_ptr_factory_.GetWeakPtr());
349
350 // Dispatch task to open from the worker pool, since open may block.
351 base::WorkerPool::PostTask(FROM_HERE,
352 base::Bind(&OpenInputDevice,
353 base::Passed(&params),
354 ui_task_runner_,
355 reply_callback),
356 true /* task_is_slow */);
357 }
358 break;
359 case DeviceEvent::REMOVE: {
360 TRACE_EVENT1("ozone", "OnDeviceRemoved", "path", event.path().value());
361 DetachInputDevice(event.path());
362 }
363 break;
364 }
365 }
366
367 void EventFactoryEvdev::OnDispatcherListChanged() {
368 if (!initialized_)
369 Init();
370 }
371
372 void EventFactoryEvdev::DetachInputDevice(const base::FilePath& path) {
373 TRACE_EVENT1("ozone", "DetachInputDevice", "path", path.value()); 226 TRACE_EVENT1("ozone", "DetachInputDevice", "path", path.value());
374 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); 227 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
375 228
376 // Remove device from map. 229 // Remove device from map.
377 scoped_ptr<EventConverterEvdev> converter(converters_[path]); 230 scoped_ptr<EventConverterEvdev> converter(converters_[path]);
378 converters_.erase(path); 231 converters_.erase(path);
379 232
380 if (converter) { 233 if (converter) {
381 // Cancel libevent notifications from this converter. This part must be 234 // Cancel libevent notifications from this converter. This part must be
382 // on UI since the polling happens on UI. 235 // on UI since the polling happens on UI.
383 converter->Stop(); 236 converter->Stop();
384 237
385 NotifyDeviceChange(*converter); 238 NotifyDeviceChange(*converter);
386 239
387 // Dispatch task to close from the worker pool, since close may block. 240 // Dispatch task to close from the worker pool, since close may block.
388 base::WorkerPool::PostTask( 241 base::WorkerPool::PostTask(
389 FROM_HERE, 242 FROM_HERE,
390 base::Bind(&CloseInputDevice, path, base::Passed(&converter)), 243 base::Bind(&CloseInputDevice, path, base::Passed(&converter)), true);
391 true);
392 } 244 }
393 } 245 }
394 246
395 void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget, 247 void InputDeviceFactoryEvdev::DisableInternalTouchpad() {
396 const gfx::PointF& location) {
397 if (cursor_) {
398 cursor_->MoveCursorTo(widget, location);
399 PostUiEvent(make_scoped_ptr(new MouseEvent(ET_MOUSE_MOVED,
400 cursor_->GetLocation(),
401 cursor_->GetLocation(),
402 modifiers_.GetModifierFlags(),
403 /* changed_button_flags */ 0)));
404 }
405 }
406
407 void EventFactoryEvdev::DisableInternalTouchpad() {
408 for (const auto& it : converters_) { 248 for (const auto& it : converters_) {
409 EventConverterEvdev* converter = it.second; 249 EventConverterEvdev* converter = it.second;
410 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && 250 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL &&
411 converter->HasTouchpad()) { 251 converter->HasTouchpad()) {
412 DCHECK(!converter->HasKeyboard()); 252 DCHECK(!converter->HasKeyboard());
413 converter->set_ignore_events(true); 253 converter->set_ignore_events(true);
414 } 254 }
415 } 255 }
416 } 256 }
417 257
418 void EventFactoryEvdev::EnableInternalTouchpad() { 258 void InputDeviceFactoryEvdev::EnableInternalTouchpad() {
419 for (const auto& it : converters_) { 259 for (const auto& it : converters_) {
420 EventConverterEvdev* converter = it.second; 260 EventConverterEvdev* converter = it.second;
421 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && 261 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL &&
422 converter->HasTouchpad()) { 262 converter->HasTouchpad()) {
423 DCHECK(!converter->HasKeyboard()); 263 DCHECK(!converter->HasKeyboard());
424 converter->set_ignore_events(false); 264 converter->set_ignore_events(false);
425 } 265 }
426 } 266 }
427 } 267 }
428 268
429 void EventFactoryEvdev::DisableInternalKeyboardExceptKeys( 269 void InputDeviceFactoryEvdev::DisableInternalKeyboardExceptKeys(
430 scoped_ptr<std::set<DomCode>> excepted_keys) { 270 scoped_ptr<std::set<DomCode>> excepted_keys) {
431 for (const auto& it : converters_) { 271 for (const auto& it : converters_) {
432 EventConverterEvdev* converter = it.second; 272 EventConverterEvdev* converter = it.second;
433 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && 273 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL &&
434 converter->HasKeyboard()) { 274 converter->HasKeyboard()) {
435 converter->SetAllowedKeys(excepted_keys.Pass()); 275 converter->SetAllowedKeys(excepted_keys.Pass());
436 } 276 }
437 } 277 }
438 } 278 }
439 279
440 void EventFactoryEvdev::EnableInternalKeyboard() { 280 void InputDeviceFactoryEvdev::EnableInternalKeyboard() {
441 for (const auto& it : converters_) { 281 for (const auto& it : converters_) {
442 EventConverterEvdev* converter = it.second; 282 EventConverterEvdev* converter = it.second;
443 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && 283 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL &&
444 converter->HasKeyboard()) { 284 converter->HasKeyboard()) {
445 converter->AllowAllKeys(); 285 converter->AllowAllKeys();
446 } 286 }
447 } 287 }
448 } 288 }
449 289
450 void EventFactoryEvdev::NotifyDeviceChange( 290 void InputDeviceFactoryEvdev::NotifyDeviceChange(
451 const EventConverterEvdev& converter) { 291 const EventConverterEvdev& converter) {
452 if (converter.HasTouchscreen()) 292 if (converter.HasTouchscreen())
453 NotifyTouchscreensUpdated(); 293 NotifyTouchscreensUpdated();
454 294
455 if (converter.HasKeyboard()) 295 if (converter.HasKeyboard())
456 NotifyKeyboardsUpdated(); 296 NotifyKeyboardsUpdated();
457 } 297 }
458 298
459 void EventFactoryEvdev::NotifyTouchscreensUpdated() { 299 void InputDeviceFactoryEvdev::NotifyTouchscreensUpdated() {
460 DeviceHotplugEventObserver* observer = DeviceDataManager::GetInstance(); 300 DeviceHotplugEventObserver* observer = DeviceDataManager::GetInstance();
461 std::vector<TouchscreenDevice> touchscreens; 301 std::vector<TouchscreenDevice> touchscreens;
462 for (auto it = converters_.begin(); it != converters_.end(); ++it) { 302 for (auto it = converters_.begin(); it != converters_.end(); ++it) {
463 if (it->second->HasTouchscreen()) { 303 if (it->second->HasTouchscreen()) {
464 // TODO(spang): Extract the number of touch-points supported by the 304 // TODO(spang): Extract the number of touch-points supported by the
465 // device. 305 // device.
466 const int touch_points = 11; 306 const int touch_points = 11;
467 touchscreens.push_back(TouchscreenDevice( 307 touchscreens.push_back(TouchscreenDevice(
468 it->second->id(), it->second->type(), std::string() /* Device name */, 308 it->second->id(), it->second->type(), std::string() /* Device name */,
469 it->second->GetTouchscreenSize(), touch_points)); 309 it->second->GetTouchscreenSize(), touch_points));
470 } 310 }
471 } 311 }
472 312
473 observer->OnTouchscreenDevicesUpdated(touchscreens); 313 observer->OnTouchscreenDevicesUpdated(touchscreens);
474 } 314 }
475 315
476 void EventFactoryEvdev::NotifyKeyboardsUpdated() { 316 void InputDeviceFactoryEvdev::NotifyKeyboardsUpdated() {
477 DeviceHotplugEventObserver* observer = DeviceDataManager::GetInstance(); 317 DeviceHotplugEventObserver* observer = DeviceDataManager::GetInstance();
478 std::vector<KeyboardDevice> keyboards; 318 std::vector<KeyboardDevice> keyboards;
479 for (auto it = converters_.begin(); it != converters_.end(); ++it) { 319 for (auto it = converters_.begin(); it != converters_.end(); ++it) {
480 if (it->second->HasKeyboard()) { 320 if (it->second->HasKeyboard()) {
481 keyboards.push_back(KeyboardDevice(it->second->id(), it->second->type(), 321 keyboards.push_back(KeyboardDevice(it->second->id(), it->second->type(),
482 std::string() /* Device name */)); 322 std::string() /* Device name */));
483 } 323 }
484 } 324 }
485 325
486 observer->OnKeyboardDevicesUpdated(keyboards); 326 observer->OnKeyboardDevicesUpdated(keyboards);
487 } 327 }
488 328
489 int EventFactoryEvdev::NextDeviceId() { 329 bool InputDeviceFactoryEvdev::GetDeviceIdsByType(const EventDeviceType type,
490 return ++last_device_id_; 330 std::vector<int>* device_ids) {
491 }
492
493 bool EventFactoryEvdev::GetDeviceIdsByType(const EventDeviceType type,
494 std::vector<int>* device_ids) {
495 if (device_ids) 331 if (device_ids)
496 device_ids->clear(); 332 device_ids->clear();
497 std::vector<int> ids; 333 std::vector<int> ids;
498 334
499 #if defined(USE_EVDEV_GESTURES) 335 #if defined(USE_EVDEV_GESTURES)
500 // Ask GesturePropertyProvider for matching devices. 336 // Ask GesturePropertyProvider for matching devices.
501 gesture_property_provider_->GetDeviceIdsByType(type, &ids); 337 gesture_property_provider_->GetDeviceIdsByType(type, &ids);
502 #endif 338 #endif
503 // In the future we can add other device matching logics here. 339 // In the future we can add other device matching logics here.
504 340
505 if (device_ids) 341 if (device_ids)
506 device_ids->assign(ids.begin(), ids.end()); 342 device_ids->assign(ids.begin(), ids.end());
507 return !ids.empty(); 343 return !ids.empty();
508 } 344 }
509 345
510 } // namespace ui 346 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/input_device_factory_evdev.h ('k') | ui/events/ozone/events_ozone.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698