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

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

Issue 2235933002: Add POINTER_TYPE_ERASER to EventPointerType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
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 #include <stddef.h> 9 #include <stddef.h>
10 10
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "ui/events/event.h" 13 #include "ui/events/event.h"
14 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" 14 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h"
15 15
16 namespace ui { 16 namespace ui {
17 17
18 namespace { 18 namespace {
19 19
20 // Convert tilt from [min, min + num_values) to [-90deg, +90deg) 20 // Convert tilt from [min, min + num_values) to [-90deg, +90deg)
21 float ScaleTilt(int value, int min_value, int num_values) { 21 float ScaleTilt(int value, int min_value, int num_values) {
22 return 180.f * (value - min_value) / num_values - 90.f; 22 return 180.f * (value - min_value) / num_values - 90.f;
23 } 23 }
24 24
25 EventPointerType GetToolType(int button_tool) {
26 if (button_tool == BTN_TOOL_RUBBER)
27 return EventPointerType::POINTER_TYPE_ERASER;
28 return EventPointerType::POINTER_TYPE_PEN;
29 }
30
25 } // namespace 31 } // namespace
26 32
27 TabletEventConverterEvdev::TabletEventConverterEvdev( 33 TabletEventConverterEvdev::TabletEventConverterEvdev(
28 int fd, 34 int fd,
29 base::FilePath path, 35 base::FilePath path,
30 int id, 36 int id,
31 CursorDelegateEvdev* cursor, 37 CursorDelegateEvdev* cursor,
32 const EventDeviceInfo& info, 38 const EventDeviceInfo& info,
33 DeviceEventDispatcherEvdev* dispatcher) 39 DeviceEventDispatcherEvdev* dispatcher)
34 : EventConverterEvdev(fd, 40 : EventConverterEvdev(fd,
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 if (abs_value_dirty_) { 179 if (abs_value_dirty_) {
174 UpdateCursor(); 180 UpdateCursor();
175 abs_value_dirty_ = false; 181 abs_value_dirty_ = false;
176 } 182 }
177 183
178 bool down = input.value; 184 bool down = input.value;
179 185
180 dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams( 186 dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams(
181 input_device_.id, EF_NONE, cursor_->GetLocation(), button, down, 187 input_device_.id, EF_NONE, cursor_->GetLocation(), button, down,
182 false /* allow_remap */, 188 false /* allow_remap */,
183 PointerDetails(EventPointerType::POINTER_TYPE_PEN, 189 PointerDetails(GetToolType(stylus_),
184 /* radius_x */ 0.0f, /* radius_y */ 0.0f, pressure_, 190 /* radius_x */ 0.0f, /* radius_y */ 0.0f, pressure_,
185 tilt_x_, tilt_y_), 191 tilt_x_, tilt_y_),
186 TimeTicksFromInputEvent(input))); 192 TimeTicksFromInputEvent(input)));
187 } 193 }
188 194
189 void TabletEventConverterEvdev::FlushEvents(const input_event& input) { 195 void TabletEventConverterEvdev::FlushEvents(const input_event& input) {
190 if (!cursor_) 196 if (!cursor_)
191 return; 197 return;
192 198
193 // Prevent propagation of invalid data on stylus lift off 199 // Prevent propagation of invalid data on stylus lift off
194 if (stylus_ == 0) { 200 if (stylus_ == 0) {
195 abs_value_dirty_ = false; 201 abs_value_dirty_ = false;
196 return; 202 return;
197 } 203 }
198 204
199 if (!abs_value_dirty_) 205 if (!abs_value_dirty_)
200 return; 206 return;
201 207
202 UpdateCursor(); 208 UpdateCursor();
203 209
204 dispatcher_->DispatchMouseMoveEvent(MouseMoveEventParams( 210 dispatcher_->DispatchMouseMoveEvent(MouseMoveEventParams(
205 input_device_.id, EF_NONE, cursor_->GetLocation(), 211 input_device_.id, EF_NONE, cursor_->GetLocation(),
206 PointerDetails(EventPointerType::POINTER_TYPE_PEN, 212 PointerDetails(GetToolType(stylus_),
207 /* radius_x */ 0.0f, /* radius_y */ 0.0f, pressure_, 213 /* radius_x */ 0.0f, /* radius_y */ 0.0f, pressure_,
208 tilt_x_, tilt_y_), 214 tilt_x_, tilt_y_),
209 TimeTicksFromInputEvent(input))); 215 TimeTicksFromInputEvent(input)));
210 216
211 abs_value_dirty_ = false; 217 abs_value_dirty_ = false;
212 } 218 }
213 219
214 } // namespace ui 220 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/gestures/motion_event_aura.cc ('k') | ui/events/ozone/evdev/touch_event_converter_evdev.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698