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

Unified Diff: ui/events/ozone/evdev/input_controller_evdev.cc

Issue 864253002: Dump property values for the touch log source (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sort property values. Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: ui/events/ozone/evdev/input_controller_evdev.cc
diff --git a/ui/events/ozone/evdev/input_controller_evdev.cc b/ui/events/ozone/evdev/input_controller_evdev.cc
index 65ca67ec8cc4ebd86ff926c4fc819b87851ae2ce..989163aae5f611a05fecc596c05922a9aff86083 100644
--- a/ui/events/ozone/evdev/input_controller_evdev.cc
+++ b/ui/events/ozone/evdev/input_controller_evdev.cc
@@ -4,9 +4,11 @@
#include "ui/events/ozone/evdev/input_controller_evdev.h"
+#include <algorithm>
#include <linux/input.h>
#include <vector>
+#include "base/strings/stringprintf.h"
#include "ui/events/ozone/evdev/event_factory_evdev.h"
#include "ui/events/ozone/evdev/mouse_button_map_evdev.h"
@@ -40,6 +42,42 @@ void SetGestureBoolProperty(GesturePropertyProvider* provider,
property->SetBoolValue(values);
}
}
+
achuithb 2015/01/22 20:42:12 Add a function comment
Shecky Lin 2015/01/23 07:46:46 Done.
+template <typename T>
+std::string DumpArrayProperty(const std::vector<T>& value, const char* format) {
+ std::string ret;
+ for (size_t i = 0; i < value.size(); ++i) {
+ if (i > 0)
+ ret.append(", ");
+ ret.append(base::StringPrintf(format, value[i]));
+ }
+ return ret;
+}
+
+std::string DumpGesturePropertyValue(GesturesProp* property) {
achuithb 2015/01/22 20:42:12 Add a function comment
Shecky Lin 2015/01/23 07:46:46 Done.
+ switch (property->type()) {
+ case GesturePropertyProvider::PT_INT:
+ return DumpArrayProperty(property->GetIntValue(), "%d");
+ break;
+ case GesturePropertyProvider::PT_SHORT:
+ return DumpArrayProperty(property->GetShortValue(), "%d");
+ break;
+ case GesturePropertyProvider::PT_BOOL:
+ return DumpArrayProperty(property->GetBoolValue(), "%d");
+ break;
+ case GesturePropertyProvider::PT_STRING:
+ return "\"" + property->GetStringValue() + "\"";
+ break;
+ case GesturePropertyProvider::PT_REAL:
+ return DumpArrayProperty(property->GetDoubleValue(), "%lf");
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+ return std::string();
+}
+
#endif
} // namespace
@@ -184,4 +222,37 @@ void InputControllerEvdev::SetTapToClickPaused(bool state) {
SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Paused", state);
}
+std::string InputControllerEvdev::GetGestureDeviceStatus() {
+ std::string ret;
+#if defined(USE_EVDEV_GESTURES)
+ // We use DT_ALL since we want gesture property values for all devices that
+ // run with the gesture library, not just mice or touchpads.
+ std::vector<int> ids;
+ event_factory_->GetDeviceIdsByType(DT_ALL, &ids);
+
+ // Dump the property names and values for each device.
+ for (size_t i = 0; i < ids.size(); ++i) {
+ std::vector<std::string> names =
+ gesture_property_provider_->GetPropertyNamesById(ids[i]);
+ ret.append("\n");
+ ret.append(base::StringPrintf("ID %d:\n", ids[i]));
+ ret.append(base::StringPrintf(
+ "Device \'%s\':\n",
+ gesture_property_provider_->GetDeviceNameById(ids[i]).c_str()));
+
+ // Note that, unlike X11, we don't maintain the "atom" concept here.
+ // Therefore, the property name indices we output here shouldn't be treated
+ // as unique identifiers of the properties.
+ std::sort(names.begin(), names.end());
+ for (size_t j = 0; j < names.size(); ++j) {
+ ret.append(base::StringPrintf("\t%s (%lu):", names[j].c_str(), j));
+ GesturesProp* property =
+ gesture_property_provider_->GetProperty(ids[i], names[j]);
+ ret.append("\t" + DumpGesturePropertyValue(property) + '\n');
+ }
+ }
+#endif
+ return ret;
+}
+
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698