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

Side by Side Diff: ui/events/device_util_linux.cc

Issue 685793002: Move all event related devices from ui/events/ to ui/events/devices/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@internal-touchscreens
Patch Set: Fix gn build Created 6 years, 1 month 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
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698