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

Side by Side Diff: ui/events/ozone/evdev/input_device_factory_evdev.cc

Issue 893753002: Dump touchpad event logs for touch log source (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change functions to Chromium counterparts and cleanup stuff Created 5 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ozone/evdev/input_device_factory_evdev.h" 5 #include "ui/events/ozone/evdev/input_device_factory_evdev.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <linux/input.h> 8 #include <linux/input.h>
9 9
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/strings/stringprintf.h"
12 #include "base/thread_task_runner_handle.h" 11 #include "base/thread_task_runner_handle.h"
13 #include "base/threading/worker_pool.h" 12 #include "base/threading/worker_pool.h"
14 #include "base/time/time.h" 13 #include "base/time/time.h"
15 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
16 #include "ui/events/devices/device_data_manager.h" 15 #include "ui/events/devices/device_data_manager.h"
17 #include "ui/events/devices/device_util_linux.h" 16 #include "ui/events/devices/device_util_linux.h"
18 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" 17 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h"
19 #include "ui/events/ozone/evdev/event_converter_evdev_impl.h" 18 #include "ui/events/ozone/evdev/event_converter_evdev_impl.h"
20 #include "ui/events/ozone/evdev/event_device_info.h" 19 #include "ui/events/ozone/evdev/event_device_info.h"
21 #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h" 20 #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h"
22 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h" 21 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h"
23 22
24 #if defined(USE_EVDEV_GESTURES) 23 #if defined(USE_EVDEV_GESTURES)
25 #include "ui/events/ozone/evdev/libgestures_glue/event_reader_libevdev_cros.h" 24 #include "ui/events/ozone/evdev/libgestures_glue/event_reader_libevdev_cros.h"
25 #include "ui/events/ozone/evdev/libgestures_glue/gesture_feedback.h"
26 #include "ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cr os.h" 26 #include "ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cr os.h"
27 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h" 27 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h"
28 #endif 28 #endif
29 29
30 #ifndef EVIOCSCLOCKID 30 #ifndef EVIOCSCLOCKID
31 #define EVIOCSCLOCKID _IOW('E', 0xa0, int) 31 #define EVIOCSCLOCKID _IOW('E', 0xa0, int)
32 #endif 32 #endif
33 33
34 namespace ui { 34 namespace ui {
35 35
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 int id, 81 int id,
82 const std::string& name, 82 const std::string& name,
83 bool value) { 83 bool value) {
84 GesturesProp* property = provider->GetProperty(id, name); 84 GesturesProp* property = provider->GetProperty(id, name);
85 if (property) { 85 if (property) {
86 std::vector<bool> values(1, value); 86 std::vector<bool> values(1, value);
87 property->SetBoolValue(values); 87 property->SetBoolValue(values);
88 } 88 }
89 } 89 }
90 90
91 // Return the values in an array in one string. Used for touch logging.
92 template <typename T>
93 std::string DumpArrayProperty(const std::vector<T>& value, const char* format) {
94 std::string ret;
95 for (size_t i = 0; i < value.size(); ++i) {
96 if (i > 0)
97 ret.append(", ");
98 ret.append(base::StringPrintf(format, value[i]));
99 }
100 return ret;
101 }
102
103 // Return the values in a gesture property in one string. Used for touch
104 // logging.
105 std::string DumpGesturePropertyValue(GesturesProp* property) {
106 switch (property->type()) {
107 case GesturePropertyProvider::PT_INT:
108 return DumpArrayProperty(property->GetIntValue(), "%d");
109 break;
110 case GesturePropertyProvider::PT_SHORT:
111 return DumpArrayProperty(property->GetShortValue(), "%d");
112 break;
113 case GesturePropertyProvider::PT_BOOL:
114 return DumpArrayProperty(property->GetBoolValue(), "%d");
115 break;
116 case GesturePropertyProvider::PT_STRING:
117 return "\"" + property->GetStringValue() + "\"";
118 break;
119 case GesturePropertyProvider::PT_REAL:
120 return DumpArrayProperty(property->GetDoubleValue(), "%lf");
121 break;
122 default:
123 NOTREACHED();
124 break;
125 }
126 return std::string();
127 }
128
129 // Dump touch device property values to a string.
130 void DumpTouchDeviceStatus(GesturePropertyProvider* provider,
131 std::string* status) {
132 // We use DT_ALL since we want gesture property values for all devices that
133 // run with the gesture library, not just mice or touchpads.
134 std::vector<int> ids;
135 provider->GetDeviceIdsByType(DT_ALL, &ids);
136
137 // Dump the property names and values for each device.
138 for (size_t i = 0; i < ids.size(); ++i) {
139 std::vector<std::string> names = provider->GetPropertyNamesById(ids[i]);
140 status->append("\n");
141 status->append(base::StringPrintf("ID %d:\n", ids[i]));
142 status->append(base::StringPrintf(
143 "Device \'%s\':\n", provider->GetDeviceNameById(ids[i]).c_str()));
144
145 // Note that, unlike X11, we don't maintain the "atom" concept here.
146 // Therefore, the property name indices we output here shouldn't be treated
147 // as unique identifiers of the properties.
148 std::sort(names.begin(), names.end());
149 for (size_t j = 0; j < names.size(); ++j) {
150 status->append(base::StringPrintf("\t%s (%zu):", names[j].c_str(), j));
151 GesturesProp* property = provider->GetProperty(ids[i], names[j]);
152 status->append("\t" + DumpGesturePropertyValue(property) + '\n');
153 }
154 }
155 }
156 #endif 91 #endif
157 92
158 scoped_ptr<EventConverterEvdev> CreateConverter( 93 scoped_ptr<EventConverterEvdev> CreateConverter(
159 const OpenInputDeviceParams& params, 94 const OpenInputDeviceParams& params,
160 int fd, 95 int fd,
161 InputDeviceType type, 96 InputDeviceType type,
162 const EventDeviceInfo& devinfo) { 97 const EventDeviceInfo& devinfo) {
163 #if defined(USE_EVDEV_GESTURES) 98 #if defined(USE_EVDEV_GESTURES)
164 // Touchpad or mouse: use gestures library. 99 // Touchpad or mouse: use gestures library.
165 // EventReaderLibevdevCros -> GestureInterpreterLibevdevCros -> DispatchEvent 100 // EventReaderLibevdevCros -> GestureInterpreterLibevdevCros -> DispatchEvent
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 342
408 void InputDeviceFactoryEvdev::GetTouchDeviceStatus( 343 void InputDeviceFactoryEvdev::GetTouchDeviceStatus(
409 const GetTouchDeviceStatusReply& reply) { 344 const GetTouchDeviceStatusReply& reply) {
410 scoped_ptr<std::string> status(new std::string); 345 scoped_ptr<std::string> status(new std::string);
411 #if defined(USE_EVDEV_GESTURES) 346 #if defined(USE_EVDEV_GESTURES)
412 DumpTouchDeviceStatus(gesture_property_provider_.get(), status.get()); 347 DumpTouchDeviceStatus(gesture_property_provider_.get(), status.get());
413 #endif 348 #endif
414 reply.Run(status.Pass()); 349 reply.Run(status.Pass());
415 } 350 }
416 351
352 void InputDeviceFactoryEvdev::GetTouchEventLog(
353 const base::FilePath& out_dir,
354 const GetTouchEventLogReply& reply) {
355 scoped_ptr<std::vector<base::FilePath>> log_paths(
356 new std::vector<base::FilePath>);
357 #if defined(USE_EVDEV_GESTURES)
358 DumpTouchEventLog(gesture_property_provider_.get(), out_dir, log_paths.Pass(),
359 reply);
360 #else
361 reply.Run(log_paths.Pass());
362 #endif
363 }
364
417 base::WeakPtr<InputDeviceFactoryEvdev> InputDeviceFactoryEvdev::GetWeakPtr() { 365 base::WeakPtr<InputDeviceFactoryEvdev> InputDeviceFactoryEvdev::GetWeakPtr() {
418 return weak_ptr_factory_.GetWeakPtr(); 366 return weak_ptr_factory_.GetWeakPtr();
419 } 367 }
420 368
421 void InputDeviceFactoryEvdev::NotifyDeviceChange( 369 void InputDeviceFactoryEvdev::NotifyDeviceChange(
422 const EventConverterEvdev& converter) { 370 const EventConverterEvdev& converter) {
423 if (converter.HasTouchscreen()) 371 if (converter.HasTouchscreen())
424 NotifyTouchscreensUpdated(); 372 NotifyTouchscreensUpdated();
425 373
426 if (converter.HasKeyboard()) 374 if (converter.HasKeyboard())
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 std::vector<int> ids; 453 std::vector<int> ids;
506 gesture_property_provider_->GetDeviceIdsByType(type, &ids); 454 gesture_property_provider_->GetDeviceIdsByType(type, &ids);
507 for (size_t i = 0; i < ids.size(); ++i) { 455 for (size_t i = 0; i < ids.size(); ++i) {
508 SetGestureBoolProperty(gesture_property_provider_.get(), ids[i], name, 456 SetGestureBoolProperty(gesture_property_provider_.get(), ids[i], name,
509 value); 457 value);
510 } 458 }
511 #endif 459 #endif
512 } 460 }
513 461
514 } // namespace ui 462 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698