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/input_controller_evdev.h"
8 #include <linux/input.h>
10 #include "ui/events/ozone/evdev/input_device_factory_evdev_proxy.h"
11 #include "ui/events/ozone/evdev/keyboard_evdev.h"
12 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h"
16 InputControllerEvdev::InputControllerEvdev(KeyboardEvdev
* keyboard
,
17 MouseButtonMapEvdev
* button_map
)
18 : input_device_factory_(nullptr),
20 button_map_(button_map
),
22 has_touchpad_(false) {
25 InputControllerEvdev::~InputControllerEvdev() {
28 void InputControllerEvdev::SetInputDeviceFactory(
29 InputDeviceFactoryEvdevProxy
* input_device_factory
) {
30 input_device_factory_
= input_device_factory
;
33 void InputControllerEvdev::set_has_mouse(bool has_mouse
) {
34 has_mouse_
= has_mouse
;
37 void InputControllerEvdev::set_has_touchpad(bool has_touchpad
) {
38 has_touchpad_
= has_touchpad
;
41 bool InputControllerEvdev::HasMouse() {
45 bool InputControllerEvdev::HasTouchpad() {
49 bool InputControllerEvdev::IsCapsLockEnabled() {
50 return keyboard_
->IsCapsLockEnabled();
53 void InputControllerEvdev::SetCapsLockEnabled(bool enabled
) {
54 keyboard_
->SetCapsLockEnabled(enabled
);
57 void InputControllerEvdev::SetNumLockEnabled(bool enabled
) {
61 bool InputControllerEvdev::IsAutoRepeatEnabled() {
62 return keyboard_
->IsAutoRepeatEnabled();
65 void InputControllerEvdev::SetAutoRepeatEnabled(bool enabled
) {
66 keyboard_
->SetAutoRepeatEnabled(enabled
);
69 void InputControllerEvdev::SetAutoRepeatRate(const base::TimeDelta
& delay
,
70 const base::TimeDelta
& interval
) {
71 keyboard_
->SetAutoRepeatRate(delay
, interval
);
74 void InputControllerEvdev::GetAutoRepeatRate(base::TimeDelta
* delay
,
75 base::TimeDelta
* interval
) {
76 keyboard_
->GetAutoRepeatRate(delay
, interval
);
79 void InputControllerEvdev::DisableInternalTouchpad() {
80 if (input_device_factory_
)
81 input_device_factory_
->DisableInternalTouchpad();
84 void InputControllerEvdev::EnableInternalTouchpad() {
85 if (input_device_factory_
)
86 input_device_factory_
->EnableInternalTouchpad();
89 void InputControllerEvdev::DisableInternalKeyboardExceptKeys(
90 scoped_ptr
<std::set
<DomCode
>> excepted_keys
) {
91 if (input_device_factory_
) {
92 input_device_factory_
->DisableInternalKeyboardExceptKeys(
93 excepted_keys
.Pass());
97 void InputControllerEvdev::EnableInternalKeyboard() {
98 if (input_device_factory_
)
99 input_device_factory_
->EnableInternalKeyboard();
102 void InputControllerEvdev::SetTouchpadSensitivity(int value
) {
103 if (input_device_factory_
)
104 input_device_factory_
->SetTouchpadSensitivity(value
);
107 void InputControllerEvdev::SetTapToClick(bool enabled
) {
108 if (input_device_factory_
)
109 input_device_factory_
->SetTapToClick(enabled
);
112 void InputControllerEvdev::SetThreeFingerClick(bool enabled
) {
113 if (input_device_factory_
)
114 input_device_factory_
->SetThreeFingerClick(enabled
);
117 void InputControllerEvdev::SetTapDragging(bool enabled
) {
118 if (input_device_factory_
)
119 input_device_factory_
->SetTapDragging(enabled
);
122 void InputControllerEvdev::SetNaturalScroll(bool enabled
) {
123 if (input_device_factory_
)
124 input_device_factory_
->SetNaturalScroll(enabled
);
127 void InputControllerEvdev::SetMouseSensitivity(int value
) {
128 if (input_device_factory_
)
129 input_device_factory_
->SetMouseSensitivity(value
);
132 void InputControllerEvdev::SetPrimaryButtonRight(bool right
) {
133 button_map_
->UpdateButtonMap(BTN_LEFT
, right
? BTN_RIGHT
: BTN_LEFT
);
134 button_map_
->UpdateButtonMap(BTN_RIGHT
, right
? BTN_LEFT
: BTN_RIGHT
);
137 void InputControllerEvdev::SetTapToClickPaused(bool state
) {
138 if (input_device_factory_
)
139 input_device_factory_
->SetTapToClickPaused(state
);
142 void InputControllerEvdev::GetTouchDeviceStatus(
143 const GetTouchDeviceStatusReply
& reply
) {
144 if (input_device_factory_
)
145 input_device_factory_
->GetTouchDeviceStatus(reply
);
147 reply
.Run(make_scoped_ptr(new std::string
));