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

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

Issue 1294523004: ozone: Handle pressure and tilt for stylus devices (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new-pe-details
Patch Set: Drop now unused mutators. Created 5 years, 3 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/tablet_event_converter_evdev.h" 5 #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <linux/input.h> 8 #include <linux/input.h>
9 9
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 16 matching lines...) Expand all
27 info.device_type(), 27 info.device_type(),
28 info.name(), 28 info.name(),
29 info.vendor_id(), 29 info.vendor_id(),
30 info.product_id()), 30 info.product_id()),
31 cursor_(cursor), 31 cursor_(cursor),
32 dispatcher_(dispatcher) { 32 dispatcher_(dispatcher) {
33 x_abs_min_ = info.GetAbsMinimum(ABS_X); 33 x_abs_min_ = info.GetAbsMinimum(ABS_X);
34 x_abs_range_ = info.GetAbsMaximum(ABS_X) - x_abs_min_ + 1; 34 x_abs_range_ = info.GetAbsMaximum(ABS_X) - x_abs_min_ + 1;
35 y_abs_min_ = info.GetAbsMinimum(ABS_Y); 35 y_abs_min_ = info.GetAbsMinimum(ABS_Y);
36 y_abs_range_ = info.GetAbsMaximum(ABS_Y) - y_abs_min_ + 1; 36 y_abs_range_ = info.GetAbsMaximum(ABS_Y) - y_abs_min_ + 1;
37
38 tilt_x_max_ = info.GetAbsMaximum(ABS_TILT_X);
39 tilt_y_max_ = info.GetAbsMaximum(ABS_TILT_Y);
40 pressure_max_ = info.GetAbsMaximum(ABS_PRESSURE);
37 } 41 }
38 42
39 TabletEventConverterEvdev::~TabletEventConverterEvdev() { 43 TabletEventConverterEvdev::~TabletEventConverterEvdev() {
40 } 44 }
41 45
42 void TabletEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { 46 void TabletEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) {
43 TRACE_EVENT1("evdev", 47 TRACE_EVENT1("evdev",
44 "TabletEventConverterEvdev::OnFileCanReadWithoutBlocking", "fd", 48 "TabletEventConverterEvdev::OnFileCanReadWithoutBlocking", "fd",
45 fd); 49 fd);
46 50
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 108
105 switch (input.code) { 109 switch (input.code) {
106 case ABS_X: 110 case ABS_X:
107 x_abs_location_ = input.value; 111 x_abs_location_ = input.value;
108 abs_value_dirty_ = true; 112 abs_value_dirty_ = true;
109 break; 113 break;
110 case ABS_Y: 114 case ABS_Y:
111 y_abs_location_ = input.value; 115 y_abs_location_ = input.value;
112 abs_value_dirty_ = true; 116 abs_value_dirty_ = true;
113 break; 117 break;
118 case ABS_TILT_X:
119 tilt_x_ = (90.0f * input.value) / tilt_x_max_;
120 abs_value_dirty_ = true;
121 break;
122 case ABS_TILT_Y:
123 tilt_y_ = (90.0f * input.value) / tilt_y_max_;
124 abs_value_dirty_ = true;
125 break;
126 case ABS_PRESSURE:
127 pressure_ = (float)input.value / pressure_max_;
128 abs_value_dirty_ = true;
129 break;
114 } 130 }
115 } 131 }
116 132
117 void TabletEventConverterEvdev::UpdateCursor() { 133 void TabletEventConverterEvdev::UpdateCursor() {
118 gfx::Rect confined_bounds = cursor_->GetCursorConfinedBounds(); 134 gfx::Rect confined_bounds = cursor_->GetCursorConfinedBounds();
119 135
120 int x = 136 int x =
121 ((x_abs_location_ - x_abs_min_) * confined_bounds.width()) / x_abs_range_; 137 ((x_abs_location_ - x_abs_min_) * confined_bounds.width()) / x_abs_range_;
122 int y = ((y_abs_location_ - y_abs_min_) * confined_bounds.height()) / 138 int y = ((y_abs_location_ - y_abs_min_) * confined_bounds.height()) /
123 y_abs_range_; 139 y_abs_range_;
(...skipping 21 matching lines...) Expand all
145 161
146 if (abs_value_dirty_) { 162 if (abs_value_dirty_) {
147 UpdateCursor(); 163 UpdateCursor();
148 abs_value_dirty_ = false; 164 abs_value_dirty_ = false;
149 } 165 }
150 166
151 bool down = input.value; 167 bool down = input.value;
152 168
153 dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams( 169 dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams(
154 input_device_.id, cursor_->GetLocation(), button, down, 170 input_device_.id, cursor_->GetLocation(), button, down,
155 false /* allow_remap */, TimeDeltaFromInputEvent(input))); 171 false /* allow_remap */,
172 PointerDetails(EventPointerType::POINTER_TYPE_PEN,
173 /* radius_x */ 0.0f, /* radius_y */ 0.0f, pressure_,
174 tilt_x_, tilt_y_),
175 TimeDeltaFromInputEvent(input)));
156 } 176 }
157 177
158 void TabletEventConverterEvdev::FlushEvents(const input_event& input) { 178 void TabletEventConverterEvdev::FlushEvents(const input_event& input) {
159 if (!cursor_) 179 if (!cursor_)
160 return; 180 return;
161 181
162 // Prevent propagation of invalid data on stylus lift off 182 // Prevent propagation of invalid data on stylus lift off
163 if (stylus_ == 0) { 183 if (stylus_ == 0) {
164 abs_value_dirty_ = false; 184 abs_value_dirty_ = false;
165 return; 185 return;
166 } 186 }
167 187
168 if (!abs_value_dirty_) 188 if (!abs_value_dirty_)
169 return; 189 return;
170 190
171 UpdateCursor(); 191 UpdateCursor();
172 192
173 dispatcher_->DispatchMouseMoveEvent( 193 dispatcher_->DispatchMouseMoveEvent(MouseMoveEventParams(
174 MouseMoveEventParams(input_device_.id, cursor_->GetLocation(), 194 input_device_.id, cursor_->GetLocation(),
175 TimeDeltaFromInputEvent(input))); 195 PointerDetails(EventPointerType::POINTER_TYPE_PEN,
196 /* radius_x */ 0.0f, /* radius_y */ 0.0f, pressure_,
197 tilt_x_, tilt_y_),
198 TimeDeltaFromInputEvent(input)));
176 199
177 abs_value_dirty_ = false; 200 abs_value_dirty_ = false;
178 } 201 }
179 202
180 } // namespace ui 203 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/tablet_event_converter_evdev.h ('k') | ui/events/ozone/evdev/tablet_event_converter_evdev_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698