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

Side by Side 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 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/ozone/evdev/mouse_button_map_evdev.h"
6
7 #include <linux/input.h>
8
9 #include "base/logging.h"
10
11 namespace ui {
12
13 namespace {
14
15 // Defines the range of button codes that we support.
16 //
17 // Check linux/input.h for more info.
18 const MouseButtonMapEvdev::Button kMinMouseButtonCode = BTN_MISC;
19 const MouseButtonMapEvdev::Button kMaxMouseButtonCode = BTN_GEAR_UP;
20
21 bool IsMouseButton(const MouseButtonMapEvdev::Button button) {
22 return (button >= kMinMouseButtonCode && button <= kMaxMouseButtonCode);
23 }
24
25 } // namespace
26
27 MouseButtonMapEvdev::MouseButtonMapEvdev() {
28 ResetButtonMap();
29 }
30
31 MouseButtonMapEvdev::~MouseButtonMapEvdev() {
32 }
33
34 void MouseButtonMapEvdev::UpdateButtonMap(Button button_from,
35 Button button_to) {
36 DCHECK(IsMouseButton(button_from) && IsMouseButton(button_to));
37 button_map_[button_from] = button_to;
38 }
39
40 void MouseButtonMapEvdev::ResetButtonMap() {
41 button_map_.clear();
42 for (Button i = kMinMouseButtonCode; i <= kMaxMouseButtonCode; ++i)
43 button_map_[i] = i;
44 }
45
46 int MouseButtonMapEvdev::GetMappedButton(const Button button) const {
47 ButtonMap::const_iterator it = button_map_.find(button);
48 DCHECK(it != button_map_.end());
49 return it->second;
50 }
51
52 } // namespace ui
OLDNEW
« 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