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

Side by Side Diff: ui/events/devices/input_device.cc

Issue 1992443002: Add Mojo IPC based input-device service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_ddm
Patch Set: Rebase/move. Created 4 years, 6 months 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
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 "ui/events/devices/input_device.h" 5 #include "ui/events/devices/input_device.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/stringprintf.h"
10
9 namespace ui { 11 namespace ui {
10 12
13 namespace {
14
15 std::string InputDeviceTypeString(InputDeviceType type) {
16 #define ECASE(value) \
17 case value: \
18 return #value
19 switch (type) {
20 ECASE(INPUT_DEVICE_INTERNAL);
21 ECASE(INPUT_DEVICE_EXTERNAL);
22 ECASE(INPUT_DEVICE_UNKNOWN);
23 }
24 #undef ECASE
25 }
26
27 } // namespace
28
11 // static 29 // static
12 const int InputDevice::kInvalidId = 0; 30 const int InputDevice::kInvalidId = 0;
13 31
14 InputDevice::InputDevice() 32 InputDevice::InputDevice()
15 : id(kInvalidId), type(InputDeviceType::INPUT_DEVICE_UNKNOWN) { 33 : id(kInvalidId), type(InputDeviceType::INPUT_DEVICE_UNKNOWN) {
16 } 34 }
17 35
18 InputDevice::InputDevice(int id, InputDeviceType type, const std::string& name) 36 InputDevice::InputDevice(int id, InputDeviceType type, const std::string& name)
19 : id(id), type(type), name(name), vendor_id(0), product_id(0) { 37 : id(id), type(type), name(name), vendor_id(0), product_id(0) {
20 } 38 }
21 39
22 InputDevice::InputDevice(int id, 40 InputDevice::InputDevice(int id,
23 InputDeviceType type, 41 InputDeviceType type,
24 const std::string& name, 42 const std::string& name,
25 const base::FilePath& sys_path, 43 const base::FilePath& sys_path,
26 uint16_t vendor, 44 uint16_t vendor,
27 uint16_t product) 45 uint16_t product)
28 : id(id), 46 : id(id),
29 type(type), 47 type(type),
30 name(name), 48 name(name),
31 sys_path(sys_path), 49 sys_path(sys_path),
32 vendor_id(vendor), 50 vendor_id(vendor),
33 product_id(product) {} 51 product_id(product) {}
34 52
35 InputDevice::InputDevice(const InputDevice& other) = default; 53 InputDevice::InputDevice(const InputDevice& other) = default;
36 54
37 InputDevice::~InputDevice() { 55 InputDevice::~InputDevice() {
38 } 56 }
39 57
58 std::string InputDevice::ToString() const {
59 return base::StringPrintf("InputDevice[id=%d, name=\"%s\", type=%s]", id,
60 name.c_str(), InputDeviceTypeString(type).c_str());
61 }
62
40 } // namespace ui 63 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698