OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/events/device_util_linux.h" | |
6 | |
7 #include <string> | |
8 | |
9 #include "base/files/file_enumerator.h" | |
10 #include "base/files/file_path.h" | |
11 #include "base/strings/string_util.h" | |
12 | |
13 namespace ui { | |
14 | |
15 bool IsTouchscreenInternal(const base::FilePath& path) { | |
16 std::string event_node = path.BaseName().value(); | |
17 if (event_node.empty() || !StartsWithASCII(event_node, "event", false)) | |
18 return false; | |
19 | |
20 // Extract id "XXX" from "eventXXX" | |
21 std::string event_node_id = event_node.substr(5); | |
22 | |
23 // I2C input device registers its dev input node at | |
24 // /sys/bus/i2c/devices/*/input/inputXXX/eventXXX | |
25 base::FileEnumerator i2c_enum( | |
26 base::FilePath(FILE_PATH_LITERAL("/sys/bus/i2c/devices/")), | |
27 false, | |
28 base::FileEnumerator::DIRECTORIES); | |
29 for (base::FilePath i2c_name = i2c_enum.Next(); !i2c_name.empty(); | |
30 i2c_name = i2c_enum.Next()) { | |
31 base::FileEnumerator input_enum( | |
32 i2c_name.Append(FILE_PATH_LITERAL("input")), | |
33 false, | |
34 base::FileEnumerator::DIRECTORIES, | |
35 FILE_PATH_LITERAL("input*")); | |
36 for (base::FilePath input = input_enum.Next(); !input.empty(); | |
37 input = input_enum.Next()) { | |
38 if (input.BaseName().value().substr(5) == event_node_id) | |
39 return true; | |
40 } | |
41 } | |
42 | |
43 return false; | |
44 } | |
45 | |
46 } // namespace | |
OLD | NEW |