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.
5 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h"
7 #include <linux/input.h>
9 #include "base/logging.h"
15 // Defines the range of button codes that we support.
17 // Check linux/input.h for more info.
18 const MouseButtonMapEvdev::Button kMinMouseButtonCode
= BTN_MISC
;
19 const MouseButtonMapEvdev::Button kMaxMouseButtonCode
= BTN_GEAR_UP
;
21 bool IsMouseButton(const MouseButtonMapEvdev::Button button
) {
22 return (button
>= kMinMouseButtonCode
&& button
<= kMaxMouseButtonCode
);
27 MouseButtonMapEvdev::MouseButtonMapEvdev() {
31 MouseButtonMapEvdev::~MouseButtonMapEvdev() {
34 void MouseButtonMapEvdev::UpdateButtonMap(Button button_from
,
36 DCHECK(IsMouseButton(button_from
) && IsMouseButton(button_to
));
37 button_map_
[button_from
] = button_to
;
40 void MouseButtonMapEvdev::ResetButtonMap() {
42 for (Button i
= kMinMouseButtonCode
; i
<= kMaxMouseButtonCode
; ++i
)
46 int MouseButtonMapEvdev::GetMappedButton(const Button button
) const {
47 ButtonMap::const_iterator it
= button_map_
.find(button
);
48 DCHECK(it
!= button_map_
.end());