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

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

Issue 1287103004: Sync ui/events to chromium @ https://codereview.chromium.org/1210203002 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 4 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/mouse_button_map_evdev.cc
diff --git a/ui/events/ozone/evdev/mouse_button_map_evdev.cc b/ui/events/ozone/evdev/mouse_button_map_evdev.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c8f8e1f48bb423a290586efb90dd9ac8474bd69d
--- /dev/null
+++ b/ui/events/ozone/evdev/mouse_button_map_evdev.cc
@@ -0,0 +1,52 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/events/ozone/evdev/mouse_button_map_evdev.h"
+
+#include <linux/input.h>
+
+#include "base/logging.h"
+
+namespace ui {
+
+namespace {
+
+// Defines the range of button codes that we support.
+//
+// Check linux/input.h for more info.
+const MouseButtonMapEvdev::Button kMinMouseButtonCode = BTN_MISC;
+const MouseButtonMapEvdev::Button kMaxMouseButtonCode = BTN_GEAR_UP;
+
+bool IsMouseButton(const MouseButtonMapEvdev::Button button) {
+ return (button >= kMinMouseButtonCode && button <= kMaxMouseButtonCode);
+}
+
+} // namespace
+
+MouseButtonMapEvdev::MouseButtonMapEvdev() {
+ ResetButtonMap();
+}
+
+MouseButtonMapEvdev::~MouseButtonMapEvdev() {
+}
+
+void MouseButtonMapEvdev::UpdateButtonMap(Button button_from,
+ Button button_to) {
+ DCHECK(IsMouseButton(button_from) && IsMouseButton(button_to));
+ button_map_[button_from] = button_to;
+}
+
+void MouseButtonMapEvdev::ResetButtonMap() {
+ button_map_.clear();
+ for (Button i = kMinMouseButtonCode; i <= kMaxMouseButtonCode; ++i)
+ button_map_[i] = i;
+}
+
+int MouseButtonMapEvdev::GetMappedButton(const Button button) const {
+ ButtonMap::const_iterator it = button_map_.find(button);
+ DCHECK(it != button_map_.end());
+ return it->second;
+}
+
+} // namespace ui
« no previous file with comments | « ui/events/ozone/evdev/mouse_button_map_evdev.h ('k') | ui/events/ozone/evdev/tablet_event_converter_evdev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698