OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/hid_connection_linux.h" | 5 #include "device/hid/hid_connection_linux.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <libudev.h> | 9 #include <libudev.h> |
10 #include <linux/hidraw.h> | 10 #include <linux/hidraw.h> |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 parent_path += '/'; | 225 parent_path += '/'; |
226 udev_list_entry* devices = udev_enumerate_get_list_entry(enumerate.get()); | 226 udev_list_entry* devices = udev_enumerate_get_list_entry(enumerate.get()); |
227 for (udev_list_entry* i = devices; i != NULL; | 227 for (udev_list_entry* i = devices; i != NULL; |
228 i = udev_list_entry_get_next(i)) { | 228 i = udev_list_entry_get_next(i)) { |
229 ScopedUdevDevicePtr hid_dev( | 229 ScopedUdevDevicePtr hid_dev( |
230 udev_device_new_from_syspath(udev, udev_list_entry_get_name(i))); | 230 udev_device_new_from_syspath(udev, udev_list_entry_get_name(i))); |
231 const char* raw_path = udev_device_get_devnode(hid_dev.get()); | 231 const char* raw_path = udev_device_get_devnode(hid_dev.get()); |
232 std::string device_path = udev_device_get_devpath(hid_dev.get()); | 232 std::string device_path = udev_device_get_devpath(hid_dev.get()); |
233 if (raw_path && | 233 if (raw_path && |
234 !device_path.compare(0, parent_path.length(), parent_path)) { | 234 !device_path.compare(0, parent_path.length(), parent_path)) { |
235 *result = raw_path; | 235 std::string sub_path = device_path.substr(parent_path.length()); |
236 return true; | 236 if (sub_path.substr(0, sizeof(kHidrawSubsystem)-1) == kHidrawSubsystem) { |
| 237 *result = raw_path; |
| 238 return true; |
| 239 } |
237 } | 240 } |
238 } | 241 } |
239 | 242 |
240 return false; | 243 return false; |
241 } | 244 } |
242 | 245 |
243 } // namespace device | 246 } // namespace device |
| 247 |
OLD | NEW |