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

Side by Side Diff: ui/events/ozone/evdev/input_controller_evdev.cc

Issue 863353003: [PATCH 6/11] ozone: evdev: Factor device I/O out of EventFactoryOzone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates for events_unittests 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/events/ozone/evdev/input_controller_evdev.h" 5 #include "ui/events/ozone/evdev/input_controller_evdev.h"
6 6
7 #include <linux/input.h> 7 #include <linux/input.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ui/events/ozone/evdev/event_factory_evdev.h" 10 #include "ui/events/ozone/evdev/input_device_factory_evdev.h"
11 #include "ui/events/ozone/evdev/keyboard_evdev.h"
11 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h" 12 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h"
12 13
13 #if defined(USE_EVDEV_GESTURES) 14 #if defined(USE_EVDEV_GESTURES)
14 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h" 15 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h"
15 #endif 16 #endif
16 17
17 namespace ui { 18 namespace ui {
18 19
19 namespace { 20 namespace {
20 21
(...skipping 17 matching lines...) Expand all
38 if (property) { 39 if (property) {
39 std::vector<bool> values(1, value); 40 std::vector<bool> values(1, value);
40 property->SetBoolValue(values); 41 property->SetBoolValue(values);
41 } 42 }
42 } 43 }
43 #endif 44 #endif
44 45
45 } // namespace 46 } // namespace
46 47
47 InputControllerEvdev::InputControllerEvdev( 48 InputControllerEvdev::InputControllerEvdev(
48 EventFactoryEvdev* event_factory,
49 KeyboardEvdev* keyboard, 49 KeyboardEvdev* keyboard,
50 MouseButtonMapEvdev* button_map 50 MouseButtonMapEvdev* button_map
51 #if defined(USE_EVDEV_GESTURES) 51 #if defined(USE_EVDEV_GESTURES)
52 , 52 ,
53 GesturePropertyProvider* gesture_property_provider 53 GesturePropertyProvider* gesture_property_provider
54 #endif 54 #endif
55 ) 55 )
56 : event_factory_(event_factory), 56 : input_device_factory_(nullptr),
57 keyboard_(keyboard), 57 keyboard_(keyboard),
58 button_map_(button_map) 58 button_map_(button_map)
59 #if defined(USE_EVDEV_GESTURES) 59 #if defined(USE_EVDEV_GESTURES)
60 , 60 ,
61 gesture_property_provider_(gesture_property_provider) 61 gesture_property_provider_(gesture_property_provider)
62 #endif 62 #endif
63 { 63 {
64 } 64 }
65 65
66 InputControllerEvdev::~InputControllerEvdev() { 66 InputControllerEvdev::~InputControllerEvdev() {
67 } 67 }
68 68
69 void InputControllerEvdev::SetInputDeviceFactory(
70 InputDeviceFactoryEvdev* input_device_factory) {
71 input_device_factory_ = input_device_factory;
72 }
73
69 bool InputControllerEvdev::HasMouse() { 74 bool InputControllerEvdev::HasMouse() {
70 return event_factory_->GetDeviceIdsByType(DT_MOUSE, NULL); 75 if (!input_device_factory_)
76 return false;
77 return input_device_factory_->GetDeviceIdsByType(DT_MOUSE, NULL);
71 } 78 }
72 79
73 bool InputControllerEvdev::HasTouchpad() { 80 bool InputControllerEvdev::HasTouchpad() {
74 return event_factory_->GetDeviceIdsByType(DT_TOUCHPAD, NULL); 81 if (!input_device_factory_)
82 return false;
83 return input_device_factory_->GetDeviceIdsByType(DT_TOUCHPAD, NULL);
75 } 84 }
76 85
77 bool InputControllerEvdev::IsCapsLockEnabled() { 86 bool InputControllerEvdev::IsCapsLockEnabled() {
78 return false; 87 return false;
79 } 88 }
80 89
81 void InputControllerEvdev::SetCapsLockEnabled(bool enabled) { 90 void InputControllerEvdev::SetCapsLockEnabled(bool enabled) {
82 NOTIMPLEMENTED(); 91 NOTIMPLEMENTED();
83 } 92 }
84 93
(...skipping 13 matching lines...) Expand all
98 const base::TimeDelta& interval) { 107 const base::TimeDelta& interval) {
99 keyboard_->SetAutoRepeatRate(delay, interval); 108 keyboard_->SetAutoRepeatRate(delay, interval);
100 } 109 }
101 110
102 void InputControllerEvdev::GetAutoRepeatRate(base::TimeDelta* delay, 111 void InputControllerEvdev::GetAutoRepeatRate(base::TimeDelta* delay,
103 base::TimeDelta* interval) { 112 base::TimeDelta* interval) {
104 keyboard_->GetAutoRepeatRate(delay, interval); 113 keyboard_->GetAutoRepeatRate(delay, interval);
105 } 114 }
106 115
107 void InputControllerEvdev::DisableInternalTouchpad() { 116 void InputControllerEvdev::DisableInternalTouchpad() {
108 event_factory_->DisableInternalTouchpad(); 117 if (input_device_factory_)
118 input_device_factory_->DisableInternalTouchpad();
109 } 119 }
110 120
111 void InputControllerEvdev::EnableInternalTouchpad() { 121 void InputControllerEvdev::EnableInternalTouchpad() {
112 event_factory_->EnableInternalTouchpad(); 122 if (input_device_factory_)
123 input_device_factory_->EnableInternalTouchpad();
113 } 124 }
114 125
115 void InputControllerEvdev::DisableInternalKeyboardExceptKeys( 126 void InputControllerEvdev::DisableInternalKeyboardExceptKeys(
116 scoped_ptr<std::set<DomCode>> excepted_keys) { 127 scoped_ptr<std::set<DomCode>> excepted_keys) {
117 event_factory_->DisableInternalKeyboardExceptKeys(excepted_keys.Pass()); 128 if (input_device_factory_)
129 input_device_factory_->DisableInternalKeyboardExceptKeys(
alexst (slow to review) 2015/01/27 19:31:41 nit: I prefer a set of curly braces once it become
spang 2015/01/28 01:40:46 Done.
130 excepted_keys.Pass());
118 } 131 }
119 132
120 void InputControllerEvdev::EnableInternalKeyboard() { 133 void InputControllerEvdev::EnableInternalKeyboard() {
121 event_factory_->EnableInternalKeyboard(); 134 if (input_device_factory_)
135 input_device_factory_->EnableInternalKeyboard();
122 } 136 }
123 137
124 void InputControllerEvdev::SetIntPropertyForOneType(const EventDeviceType type, 138 void InputControllerEvdev::SetIntPropertyForOneType(const EventDeviceType type,
125 const std::string& name, 139 const std::string& name,
126 int value) { 140 int value) {
141 if (!input_device_factory_)
142 return;
127 #if defined(USE_EVDEV_GESTURES) 143 #if defined(USE_EVDEV_GESTURES)
128 std::vector<int> ids; 144 std::vector<int> ids;
129 event_factory_->GetDeviceIdsByType(type, &ids); 145 input_device_factory_->GetDeviceIdsByType(type, &ids);
130 for (size_t i = 0; i < ids.size(); ++i) { 146 for (size_t i = 0; i < ids.size(); ++i) {
131 SetGestureIntProperty(gesture_property_provider_, ids[i], name, value); 147 SetGestureIntProperty(gesture_property_provider_, ids[i], name, value);
132 } 148 }
133 #endif 149 #endif
134 // In the future, we may add property setting codes for other non-gesture 150 // In the future, we may add property setting codes for other non-gesture
135 // devices. One example would be keyboard settings. 151 // devices. One example would be keyboard settings.
136 // TODO(sheckylin): See http://crbug.com/398518 for example. 152 // TODO(sheckylin): See http://crbug.com/398518 for example.
137 } 153 }
138 154
139 void InputControllerEvdev::SetBoolPropertyForOneType(const EventDeviceType type, 155 void InputControllerEvdev::SetBoolPropertyForOneType(const EventDeviceType type,
140 const std::string& name, 156 const std::string& name,
141 bool value) { 157 bool value) {
158 if (!input_device_factory_)
159 return;
142 #if defined(USE_EVDEV_GESTURES) 160 #if defined(USE_EVDEV_GESTURES)
143 std::vector<int> ids; 161 std::vector<int> ids;
144 event_factory_->GetDeviceIdsByType(type, &ids); 162 input_device_factory_->GetDeviceIdsByType(type, &ids);
145 for (size_t i = 0; i < ids.size(); ++i) { 163 for (size_t i = 0; i < ids.size(); ++i) {
146 SetGestureBoolProperty(gesture_property_provider_, ids[i], name, value); 164 SetGestureBoolProperty(gesture_property_provider_, ids[i], name, value);
147 } 165 }
148 #endif 166 #endif
149 } 167 }
150 168
151 void InputControllerEvdev::SetTouchpadSensitivity(int value) { 169 void InputControllerEvdev::SetTouchpadSensitivity(int value) {
152 SetIntPropertyForOneType(DT_TOUCHPAD, "Pointer Sensitivity", value); 170 SetIntPropertyForOneType(DT_TOUCHPAD, "Pointer Sensitivity", value);
153 SetIntPropertyForOneType(DT_TOUCHPAD, "Scroll Sensitivity", value); 171 SetIntPropertyForOneType(DT_TOUCHPAD, "Scroll Sensitivity", value);
154 } 172 }
(...skipping 23 matching lines...) Expand all
178 void InputControllerEvdev::SetPrimaryButtonRight(bool right) { 196 void InputControllerEvdev::SetPrimaryButtonRight(bool right) {
179 button_map_->UpdateButtonMap(BTN_LEFT, right ? BTN_RIGHT : BTN_LEFT); 197 button_map_->UpdateButtonMap(BTN_LEFT, right ? BTN_RIGHT : BTN_LEFT);
180 button_map_->UpdateButtonMap(BTN_RIGHT, right ? BTN_LEFT : BTN_RIGHT); 198 button_map_->UpdateButtonMap(BTN_RIGHT, right ? BTN_LEFT : BTN_RIGHT);
181 } 199 }
182 200
183 void InputControllerEvdev::SetTapToClickPaused(bool state) { 201 void InputControllerEvdev::SetTapToClickPaused(bool state) {
184 SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Paused", state); 202 SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Paused", state);
185 } 203 }
186 204
187 } // namespace ui 205 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698