OLD | NEW |
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 "device/hid/input_service_linux.h" | 5 #include "device/hid/input_service_linux.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "base/macros.h" | 12 #include "base/macros.h" |
11 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
13 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
14 #include "device/udev_linux/udev.h" | 16 #include "device/udev_linux/udev.h" |
15 | 17 |
16 namespace device { | 18 namespace device { |
17 | 19 |
18 namespace { | 20 namespace { |
19 | 21 |
20 const char kSubsystemHid[] = "hid"; | 22 const char kSubsystemHid[] = "hid"; |
21 const char kSubsystemInput[] = "input"; | 23 const char kSubsystemInput[] = "input"; |
22 const char kSubsystemMisc[] = "misc"; | 24 const char kSubsystemMisc[] = "misc"; |
23 const char kTypeBluetooth[] = "bluetooth"; | 25 const char kTypeBluetooth[] = "bluetooth"; |
24 const char kTypeUsb[] = "usb"; | 26 const char kTypeUsb[] = "usb"; |
25 const char kTypeSerio[] = "serio"; | 27 const char kTypeSerio[] = "serio"; |
26 const char kIdInputAccelerometer[] = "ID_INPUT_ACCELEROMETER"; | 28 const char kIdInputAccelerometer[] = "ID_INPUT_ACCELEROMETER"; |
27 const char kIdInputJoystick[] = "ID_INPUT_JOYSTICK"; | 29 const char kIdInputJoystick[] = "ID_INPUT_JOYSTICK"; |
28 const char kIdInputKey[] = "ID_INPUT_KEY"; | 30 const char kIdInputKey[] = "ID_INPUT_KEY"; |
29 const char kIdInputKeyboard[] = "ID_INPUT_KEYBOARD"; | 31 const char kIdInputKeyboard[] = "ID_INPUT_KEYBOARD"; |
30 const char kIdInputMouse[] = "ID_INPUT_MOUSE"; | 32 const char kIdInputMouse[] = "ID_INPUT_MOUSE"; |
31 const char kIdInputTablet[] = "ID_INPUT_TABLET"; | 33 const char kIdInputTablet[] = "ID_INPUT_TABLET"; |
32 const char kIdInputTouchpad[] = "ID_INPUT_TOUCHPAD"; | 34 const char kIdInputTouchpad[] = "ID_INPUT_TOUCHPAD"; |
33 const char kIdInputTouchscreen[] = "ID_INPUT_TOUCHSCREEN"; | 35 const char kIdInputTouchscreen[] = "ID_INPUT_TOUCHSCREEN"; |
34 | 36 |
35 // The instance will be reset when message loop destroys. | 37 // The instance will be reset when message loop destroys. |
36 base::LazyInstance<scoped_ptr<InputServiceLinux> >::Leaky | 38 base::LazyInstance<std::unique_ptr<InputServiceLinux>>::Leaky |
37 g_input_service_linux_ptr = LAZY_INSTANCE_INITIALIZER; | 39 g_input_service_linux_ptr = LAZY_INSTANCE_INITIALIZER; |
38 | 40 |
39 bool GetBoolProperty(udev_device* device, const char* key) { | 41 bool GetBoolProperty(udev_device* device, const char* key) { |
40 CHECK(device); | 42 CHECK(device); |
41 CHECK(key); | 43 CHECK(key); |
42 const char* property = udev_device_get_property_value(device, key); | 44 const char* property = udev_device_get_property_value(device, key); |
43 if (!property) | 45 if (!property) |
44 return false; | 46 return false; |
45 int value; | 47 int value; |
46 if (!base::StringToInt(property, &value)) { | 48 if (!base::StringToInt(property, &value)) { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 void InputServiceLinux::RemoveDevice(const std::string& id) { | 245 void InputServiceLinux::RemoveDevice(const std::string& id) { |
244 devices_.erase(id); | 246 devices_.erase(id); |
245 FOR_EACH_OBSERVER(Observer, observers_, OnInputDeviceRemoved(id)); | 247 FOR_EACH_OBSERVER(Observer, observers_, OnInputDeviceRemoved(id)); |
246 } | 248 } |
247 | 249 |
248 bool InputServiceLinux::CalledOnValidThread() const { | 250 bool InputServiceLinux::CalledOnValidThread() const { |
249 return thread_checker_.CalledOnValidThread(); | 251 return thread_checker_.CalledOnValidThread(); |
250 } | 252 } |
251 | 253 |
252 } // namespace device | 254 } // namespace device |
OLD | NEW |