OLD | NEW |
---|---|
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" | |
11 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
12 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
13 #include "base/task_runner.h" | |
14 #include "base/thread_task_runner_handle.h" | |
15 #include "base/threading/worker_pool.h" | 12 #include "base/threading/worker_pool.h" |
16 #include "base/time/time.h" | 13 #include "base/time/time.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 Loading... | |
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_(new GesturePropertyProvider), |
spang
2015/01/27 20:25:21
Oops.
alexst (slow to review)
2015/01/27 20:26:18
Noted in patch 7.
| |
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(¶ms), | |
198 ui_task_runner_, reply_callback), | |
199 true /* task_is_slow */); | |
207 } | 200 } |
208 | 201 |
209 void EventFactoryEvdev::DispatchKeyEvent(int device_id, | 202 void InputDeviceFactoryEvdev::RemoveInputDevice(const base::FilePath& path) { |
210 unsigned int code, | 203 DetachInputDevice(path); |
211 bool down) { | |
212 keyboard_.OnKeyChange(code, down); | |
213 } | 204 } |
214 | 205 |
215 void EventFactoryEvdev::DispatchMouseMoveEvent(int device_id, | 206 void InputDeviceFactoryEvdev::AttachInputDevice( |
216 const gfx::PointF& location) { | |
217 scoped_ptr<MouseEvent> event(new MouseEvent( | |
218 ui::ET_MOUSE_MOVED, location, location, modifiers_.GetModifierFlags(), | |
219 /* changed_button_flags */ 0)); | |
220 event->set_source_device_id(device_id); | |
221 PostUiEvent(event.Pass()); | |
222 } | |
223 | |
224 void EventFactoryEvdev::DispatchMouseButtonEvent(int device_id, | |
225 const gfx::PointF& location, | |
226 unsigned int button, | |
227 bool down, | |
228 bool allow_remap) { | |
229 // Mouse buttons can be remapped, touchpad taps & clicks cannot. | |
230 if (allow_remap) | |
231 button = button_map_.GetMappedButton(button); | |
232 | |
233 int modifier = EVDEV_MODIFIER_NONE; | |
234 switch (button) { | |
235 case BTN_LEFT: | |
236 modifier = EVDEV_MODIFIER_LEFT_MOUSE_BUTTON; | |
237 break; | |
238 case BTN_RIGHT: | |
239 modifier = EVDEV_MODIFIER_RIGHT_MOUSE_BUTTON; | |
240 break; | |
241 case BTN_MIDDLE: | |
242 modifier = EVDEV_MODIFIER_MIDDLE_MOUSE_BUTTON; | |
243 break; | |
244 default: | |
245 return; | |
246 } | |
247 | |
248 int flag = modifiers_.GetEventFlagFromModifier(modifier); | |
249 modifiers_.UpdateModifier(modifier, down); | |
250 | |
251 scoped_ptr<MouseEvent> event( | |
252 new MouseEvent(down ? ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED, | |
253 location, location, modifiers_.GetModifierFlags() | flag, | |
254 /* changed_button_flags */ flag)); | |
255 event->set_source_device_id(device_id); | |
256 PostUiEvent(event.Pass()); | |
257 } | |
258 | |
259 void EventFactoryEvdev::DispatchMouseWheelEvent(int device_id, | |
260 const gfx::PointF& location, | |
261 const gfx::Vector2d& delta) { | |
262 scoped_ptr<MouseWheelEvent> event(new MouseWheelEvent( | |
263 delta, location, location, modifiers_.GetModifierFlags(), | |
264 0 /* changed_button_flags */)); | |
265 event->set_source_device_id(device_id); | |
266 PostUiEvent(event.Pass()); | |
267 } | |
268 | |
269 void EventFactoryEvdev::DispatchScrollEvent(const ScrollEventParams& params) { | |
270 scoped_ptr<ScrollEvent> event(new ScrollEvent( | |
271 params.type, params.location, params.timestamp, | |
272 modifiers_.GetModifierFlags(), params.delta.x(), params.delta.y(), | |
273 params.ordinal_delta.x(), params.ordinal_delta.y(), params.finger_count)); | |
274 event->set_source_device_id(params.device_id); | |
275 PostUiEvent(event.Pass()); | |
276 } | |
277 | |
278 void EventFactoryEvdev::DispatchTouchEvent(const TouchEventParams& params) { | |
279 float x = params.location.x(); | |
280 float y = params.location.y(); | |
281 double radius_x = params.radii.x(); | |
282 double radius_y = params.radii.y(); | |
283 | |
284 // Transform the event according (this is used to align touches | |
285 // to the image based on display mode). | |
286 DeviceDataManager::GetInstance()->ApplyTouchTransformer(params.device_id, &x, | |
287 &y); | |
288 DeviceDataManager::GetInstance()->ApplyTouchRadiusScale(params.device_id, | |
289 &radius_x); | |
290 DeviceDataManager::GetInstance()->ApplyTouchRadiusScale(params.device_id, | |
291 &radius_y); | |
292 | |
293 scoped_ptr<TouchEvent> touch_event(new TouchEvent( | |
294 params.type, gfx::PointF(x, y), | |
295 /* flags */ 0, params.touch_id, params.timestamp, radius_x, radius_y, | |
296 /* angle */ 0., params.pressure)); | |
297 touch_event->set_source_device_id(params.device_id); | |
298 PostUiEvent(touch_event.Pass()); | |
299 } | |
300 | |
301 void EventFactoryEvdev::PostUiEvent(scoped_ptr<Event> event) { | |
302 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
303 FROM_HERE, | |
304 base::Bind(&EventFactoryEvdev::DispatchUiEventTask, | |
305 weak_ptr_factory_.GetWeakPtr(), | |
306 base::Passed(&event))); | |
307 } | |
308 | |
309 void EventFactoryEvdev::DispatchUiEventTask(scoped_ptr<Event> event) { | |
310 DispatchEvent(event.get()); | |
311 } | |
312 | |
313 void EventFactoryEvdev::AttachInputDevice( | |
314 scoped_ptr<EventConverterEvdev> converter) { | 207 scoped_ptr<EventConverterEvdev> converter) { |
315 const base::FilePath& path = converter->path(); | 208 const base::FilePath& path = converter->path(); |
316 | 209 |
317 TRACE_EVENT1("ozone", "AttachInputDevice", "path", path.value()); | 210 TRACE_EVENT1("ozone", "AttachInputDevice", "path", path.value()); |
318 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 211 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
319 | 212 |
320 // 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 |
321 // devices with the same name open at the same time. | 214 // devices with the same name open at the same time. |
322 if (converters_[path]) | 215 if (converters_[path]) |
323 DetachInputDevice(path); | 216 DetachInputDevice(path); |
324 | 217 |
325 // Add initialized device to map. | 218 // Add initialized device to map. |
326 converters_[path] = converter.release(); | 219 converters_[path] = converter.release(); |
327 converters_[path]->Start(); | 220 converters_[path]->Start(); |
328 | 221 |
329 NotifyDeviceChange(*converters_[path]); | 222 NotifyDeviceChange(*converters_[path]); |
330 } | 223 } |
331 | 224 |
332 void EventFactoryEvdev::OnDeviceEvent(const DeviceEvent& event) { | 225 void InputDeviceFactoryEvdev::DetachInputDevice(const base::FilePath& path) { |
333 if (event.device_type() != DeviceEvent::INPUT) | |
334 return; | |
335 | |
336 switch (event.action_type()) { | |
337 case DeviceEvent::ADD: | |
338 case DeviceEvent::CHANGE: { | |
339 TRACE_EVENT1("ozone", "OnDeviceAdded", "path", event.path().value()); | |
340 | |
341 scoped_ptr<OpenInputDeviceParams> params(new OpenInputDeviceParams); | |
342 params->id = NextDeviceId(); | |
343 params->path = event.path(); | |
344 params->cursor = cursor_; | |
345 params->dispatcher = this; | |
346 | |
347 #if defined(USE_EVDEV_GESTURES) | |
348 params->gesture_property_provider = gesture_property_provider_.get(); | |
349 #endif | |
350 | |
351 OpenInputDeviceReplyCallback reply_callback = | |
352 base::Bind(&EventFactoryEvdev::AttachInputDevice, | |
353 weak_ptr_factory_.GetWeakPtr()); | |
354 | |
355 // Dispatch task to open from the worker pool, since open may block. | |
356 base::WorkerPool::PostTask(FROM_HERE, | |
357 base::Bind(&OpenInputDevice, | |
358 base::Passed(¶ms), | |
359 ui_task_runner_, | |
360 reply_callback), | |
361 true /* task_is_slow */); | |
362 } | |
363 break; | |
364 case DeviceEvent::REMOVE: { | |
365 TRACE_EVENT1("ozone", "OnDeviceRemoved", "path", event.path().value()); | |
366 DetachInputDevice(event.path()); | |
367 } | |
368 break; | |
369 } | |
370 } | |
371 | |
372 void EventFactoryEvdev::OnDispatcherListChanged() { | |
373 if (!initialized_) | |
374 Init(); | |
375 } | |
376 | |
377 void EventFactoryEvdev::DetachInputDevice(const base::FilePath& path) { | |
378 TRACE_EVENT1("ozone", "DetachInputDevice", "path", path.value()); | 226 TRACE_EVENT1("ozone", "DetachInputDevice", "path", path.value()); |
379 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 227 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
380 | 228 |
381 // Remove device from map. | 229 // Remove device from map. |
382 scoped_ptr<EventConverterEvdev> converter(converters_[path]); | 230 scoped_ptr<EventConverterEvdev> converter(converters_[path]); |
383 converters_.erase(path); | 231 converters_.erase(path); |
384 | 232 |
385 if (converter) { | 233 if (converter) { |
386 // Cancel libevent notifications from this converter. This part must be | 234 // Cancel libevent notifications from this converter. This part must be |
387 // on UI since the polling happens on UI. | 235 // on UI since the polling happens on UI. |
388 converter->Stop(); | 236 converter->Stop(); |
389 | 237 |
390 NotifyDeviceChange(*converter); | 238 NotifyDeviceChange(*converter); |
391 | 239 |
392 // 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. |
393 base::WorkerPool::PostTask( | 241 base::WorkerPool::PostTask( |
394 FROM_HERE, | 242 FROM_HERE, |
395 base::Bind(&CloseInputDevice, path, base::Passed(&converter)), | 243 base::Bind(&CloseInputDevice, path, base::Passed(&converter)), true); |
396 true); | |
397 } | 244 } |
398 } | 245 } |
399 | 246 |
400 void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget, | 247 void InputDeviceFactoryEvdev::DisableInternalTouchpad() { |
401 const gfx::PointF& location) { | |
402 if (cursor_) { | |
403 cursor_->MoveCursorTo(widget, location); | |
404 PostUiEvent(make_scoped_ptr(new MouseEvent(ET_MOUSE_MOVED, | |
405 cursor_->GetLocation(), | |
406 cursor_->GetLocation(), | |
407 modifiers_.GetModifierFlags(), | |
408 /* changed_button_flags */ 0))); | |
409 } | |
410 } | |
411 | |
412 void EventFactoryEvdev::DisableInternalTouchpad() { | |
413 for (const auto& it : converters_) { | 248 for (const auto& it : converters_) { |
414 EventConverterEvdev* converter = it.second; | 249 EventConverterEvdev* converter = it.second; |
415 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && | 250 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && |
416 converter->HasTouchpad()) { | 251 converter->HasTouchpad()) { |
417 DCHECK(!converter->HasKeyboard()); | 252 DCHECK(!converter->HasKeyboard()); |
418 converter->set_ignore_events(true); | 253 converter->set_ignore_events(true); |
419 } | 254 } |
420 } | 255 } |
421 } | 256 } |
422 | 257 |
423 void EventFactoryEvdev::EnableInternalTouchpad() { | 258 void InputDeviceFactoryEvdev::EnableInternalTouchpad() { |
424 for (const auto& it : converters_) { | 259 for (const auto& it : converters_) { |
425 EventConverterEvdev* converter = it.second; | 260 EventConverterEvdev* converter = it.second; |
426 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && | 261 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && |
427 converter->HasTouchpad()) { | 262 converter->HasTouchpad()) { |
428 DCHECK(!converter->HasKeyboard()); | 263 DCHECK(!converter->HasKeyboard()); |
429 converter->set_ignore_events(false); | 264 converter->set_ignore_events(false); |
430 } | 265 } |
431 } | 266 } |
432 } | 267 } |
433 | 268 |
434 void EventFactoryEvdev::DisableInternalKeyboardExceptKeys( | 269 void InputDeviceFactoryEvdev::DisableInternalKeyboardExceptKeys( |
435 scoped_ptr<std::set<DomCode>> excepted_keys) { | 270 scoped_ptr<std::set<DomCode>> excepted_keys) { |
436 for (const auto& it : converters_) { | 271 for (const auto& it : converters_) { |
437 EventConverterEvdev* converter = it.second; | 272 EventConverterEvdev* converter = it.second; |
438 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && | 273 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && |
439 converter->HasKeyboard()) { | 274 converter->HasKeyboard()) { |
440 converter->SetAllowedKeys(excepted_keys.Pass()); | 275 converter->SetAllowedKeys(excepted_keys.Pass()); |
441 } | 276 } |
442 } | 277 } |
443 } | 278 } |
444 | 279 |
445 void EventFactoryEvdev::EnableInternalKeyboard() { | 280 void InputDeviceFactoryEvdev::EnableInternalKeyboard() { |
446 for (const auto& it : converters_) { | 281 for (const auto& it : converters_) { |
447 EventConverterEvdev* converter = it.second; | 282 EventConverterEvdev* converter = it.second; |
448 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && | 283 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && |
449 converter->HasKeyboard()) { | 284 converter->HasKeyboard()) { |
450 converter->AllowAllKeys(); | 285 converter->AllowAllKeys(); |
451 } | 286 } |
452 } | 287 } |
453 } | 288 } |
454 | 289 |
455 void EventFactoryEvdev::NotifyDeviceChange( | 290 void InputDeviceFactoryEvdev::NotifyDeviceChange( |
456 const EventConverterEvdev& converter) { | 291 const EventConverterEvdev& converter) { |
457 if (converter.HasTouchscreen()) | 292 if (converter.HasTouchscreen()) |
458 NotifyTouchscreensUpdated(); | 293 NotifyTouchscreensUpdated(); |
459 | 294 |
460 if (converter.HasKeyboard()) | 295 if (converter.HasKeyboard()) |
461 NotifyKeyboardsUpdated(); | 296 NotifyKeyboardsUpdated(); |
462 } | 297 } |
463 | 298 |
464 void EventFactoryEvdev::NotifyTouchscreensUpdated() { | 299 void InputDeviceFactoryEvdev::NotifyTouchscreensUpdated() { |
465 DeviceHotplugEventObserver* observer = DeviceDataManager::GetInstance(); | 300 DeviceHotplugEventObserver* observer = DeviceDataManager::GetInstance(); |
466 std::vector<TouchscreenDevice> touchscreens; | 301 std::vector<TouchscreenDevice> touchscreens; |
467 for (auto it = converters_.begin(); it != converters_.end(); ++it) { | 302 for (auto it = converters_.begin(); it != converters_.end(); ++it) { |
468 if (it->second->HasTouchscreen()) { | 303 if (it->second->HasTouchscreen()) { |
469 // TODO(spang): Extract the number of touch-points supported by the | 304 // TODO(spang): Extract the number of touch-points supported by the |
470 // device. | 305 // device. |
471 const int touch_points = 11; | 306 const int touch_points = 11; |
472 touchscreens.push_back(TouchscreenDevice( | 307 touchscreens.push_back(TouchscreenDevice( |
473 it->second->id(), it->second->type(), std::string() /* Device name */, | 308 it->second->id(), it->second->type(), std::string() /* Device name */, |
474 it->second->GetTouchscreenSize(), touch_points)); | 309 it->second->GetTouchscreenSize(), touch_points)); |
475 } | 310 } |
476 } | 311 } |
477 | 312 |
478 observer->OnTouchscreenDevicesUpdated(touchscreens); | 313 observer->OnTouchscreenDevicesUpdated(touchscreens); |
479 } | 314 } |
480 | 315 |
481 void EventFactoryEvdev::NotifyKeyboardsUpdated() { | 316 void InputDeviceFactoryEvdev::NotifyKeyboardsUpdated() { |
482 DeviceHotplugEventObserver* observer = DeviceDataManager::GetInstance(); | 317 DeviceHotplugEventObserver* observer = DeviceDataManager::GetInstance(); |
483 std::vector<KeyboardDevice> keyboards; | 318 std::vector<KeyboardDevice> keyboards; |
484 for (auto it = converters_.begin(); it != converters_.end(); ++it) { | 319 for (auto it = converters_.begin(); it != converters_.end(); ++it) { |
485 if (it->second->HasKeyboard()) { | 320 if (it->second->HasKeyboard()) { |
486 keyboards.push_back(KeyboardDevice(it->second->id(), it->second->type(), | 321 keyboards.push_back(KeyboardDevice(it->second->id(), it->second->type(), |
487 std::string() /* Device name */)); | 322 std::string() /* Device name */)); |
488 } | 323 } |
489 } | 324 } |
490 | 325 |
491 observer->OnKeyboardDevicesUpdated(keyboards); | 326 observer->OnKeyboardDevicesUpdated(keyboards); |
492 } | 327 } |
493 | 328 |
494 int EventFactoryEvdev::NextDeviceId() { | 329 bool InputDeviceFactoryEvdev::GetDeviceIdsByType(const EventDeviceType type, |
495 return ++last_device_id_; | 330 std::vector<int>* device_ids) { |
496 } | |
497 | |
498 bool EventFactoryEvdev::GetDeviceIdsByType(const EventDeviceType type, | |
499 std::vector<int>* device_ids) { | |
500 if (device_ids) | 331 if (device_ids) |
501 device_ids->clear(); | 332 device_ids->clear(); |
502 std::vector<int> ids; | 333 std::vector<int> ids; |
503 | 334 |
504 #if defined(USE_EVDEV_GESTURES) | 335 #if defined(USE_EVDEV_GESTURES) |
505 // Ask GesturePropertyProvider for matching devices. | 336 // Ask GesturePropertyProvider for matching devices. |
506 gesture_property_provider_->GetDeviceIdsByType(type, &ids); | 337 gesture_property_provider_->GetDeviceIdsByType(type, &ids); |
507 #endif | 338 #endif |
508 // In the future we can add other device matching logics here. | 339 // In the future we can add other device matching logics here. |
509 | 340 |
510 if (device_ids) | 341 if (device_ids) |
511 device_ids->assign(ids.begin(), ids.end()); | 342 device_ids->assign(ids.begin(), ids.end()); |
512 return !ids.empty(); | 343 return !ids.empty(); |
513 } | 344 } |
514 | 345 |
515 } // namespace ui | 346 } // namespace ui |
OLD | NEW |