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

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

Issue 616633002: [Ozone-Evdev] Propagate touchscreen device information to DeviceDataManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 2 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/touch_event_converter_evdev.h" 5 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <linux/input.h> 9 #include <linux/input.h>
10 #include <poll.h> 10 #include <poll.h>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 return val * num_pixels / num_tuxels; 68 return val * num_pixels / num_tuxels;
69 } 69 }
70 70
71 } // namespace 71 } // namespace
72 72
73 namespace ui { 73 namespace ui {
74 74
75 TouchEventConverterEvdev::TouchEventConverterEvdev( 75 TouchEventConverterEvdev::TouchEventConverterEvdev(
76 int fd, 76 int fd,
77 base::FilePath path, 77 base::FilePath path,
78 int id,
78 const EventDeviceInfo& info, 79 const EventDeviceInfo& info,
79 const EventDispatchCallback& callback) 80 const EventDispatchCallback& callback)
80 : EventConverterEvdev(fd, path), 81 : EventConverterEvdev(fd, path, id),
81 callback_(callback), 82 callback_(callback),
82 syn_dropped_(false), 83 syn_dropped_(false),
83 is_type_a_(false), 84 is_type_a_(false),
84 current_slot_(0) { 85 current_slot_(0) {
85 Init(info); 86 Init(info);
86 } 87 }
87 88
88 TouchEventConverterEvdev::~TouchEventConverterEvdev() { 89 TouchEventConverterEvdev::~TouchEventConverterEvdev() {
89 Stop(); 90 Stop();
90 close(fd_); 91 close(fd_);
91 } 92 }
92 93
93 void TouchEventConverterEvdev::Init(const EventDeviceInfo& info) { 94 void TouchEventConverterEvdev::Init(const EventDeviceInfo& info) {
94 gfx::Screen *screen = gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); 95 gfx::Screen* screen = gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE);
95 if (!screen) 96 if (!screen)
96 return; // No scaling. 97 return; // No scaling.
97 gfx::Display display = screen->GetPrimaryDisplay(); 98 gfx::Display display = screen->GetPrimaryDisplay();
98 gfx::Size size = display.GetSizeInPixel(); 99 gfx::Size size = display.GetSizeInPixel();
99 100
100 pressure_min_ = info.GetAbsMinimum(ABS_MT_PRESSURE), 101 pressure_min_ = info.GetAbsMinimum(ABS_MT_PRESSURE);
101 pressure_max_ = info.GetAbsMaximum(ABS_MT_PRESSURE), 102 pressure_max_ = info.GetAbsMaximum(ABS_MT_PRESSURE);
102 x_min_tuxels_ = info.GetAbsMinimum(ABS_MT_POSITION_X), 103 x_min_tuxels_ = info.GetAbsMinimum(ABS_MT_POSITION_X);
103 x_num_tuxels_ = info.GetAbsMaximum(ABS_MT_POSITION_X) - x_min_tuxels_ + 1, 104 x_num_tuxels_ = info.GetAbsMaximum(ABS_MT_POSITION_X) - x_min_tuxels_ + 1;
104 y_min_tuxels_ = info.GetAbsMinimum(ABS_MT_POSITION_Y), 105 y_min_tuxels_ = info.GetAbsMinimum(ABS_MT_POSITION_Y);
105 y_num_tuxels_ = info.GetAbsMaximum(ABS_MT_POSITION_Y) - y_min_tuxels_ + 1, 106 y_num_tuxels_ = info.GetAbsMaximum(ABS_MT_POSITION_Y) - y_min_tuxels_ + 1;
106 x_min_pixels_ = x_min_tuxels_, 107 native_size_ = gfx::Size(x_num_tuxels_, y_num_tuxels_);
107 x_num_pixels_ = x_num_tuxels_,
108 y_min_pixels_ = y_min_tuxels_,
109 y_num_pixels_ = y_num_tuxels_,
110 108
111 // Map coordinates onto screen. 109 // Map coordinates onto screen.
112 x_min_pixels_ = 0; 110 x_min_pixels_ = 0;
113 y_min_pixels_ = 0; 111 y_min_pixels_ = 0;
114 x_num_pixels_ = size.width(); 112 x_num_pixels_ = size.width();
115 y_num_pixels_ = size.height(); 113 y_num_pixels_ = size.height();
116 114
117 VLOG(1) << "mapping touch coordinates to screen coordinates: " 115 VLOG(1) << "mapping touch coordinates to screen coordinates: "
118 << base::StringPrintf("%dx%d", size.width(), size.height()); 116 << base::StringPrintf("%dx%d", size.width(), size.height());
119 117
(...skipping 15 matching lines...) Expand all
135 133
136 bool TouchEventConverterEvdev::Reinitialize() { 134 bool TouchEventConverterEvdev::Reinitialize() {
137 EventDeviceInfo info; 135 EventDeviceInfo info;
138 if (info.Initialize(fd_)) { 136 if (info.Initialize(fd_)) {
139 Init(info); 137 Init(info);
140 return true; 138 return true;
141 } 139 }
142 return false; 140 return false;
143 } 141 }
144 142
143 bool TouchEventConverterEvdev::HasTouchscreen() const {
144 return true;
145 }
146
147 gfx::Size TouchEventConverterEvdev::GetTouchscreenSize() const {
148 return native_size_;
149 }
150
145 void TouchEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { 151 void TouchEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) {
146 input_event inputs[MAX_FINGERS * 6 + 1]; 152 input_event inputs[MAX_FINGERS * 6 + 1];
147 ssize_t read_size = read(fd, inputs, sizeof(inputs)); 153 ssize_t read_size = read(fd, inputs, sizeof(inputs));
148 if (read_size < 0) { 154 if (read_size < 0) {
149 if (errno == EINTR || errno == EAGAIN) 155 if (errno == EINTR || errno == EAGAIN)
150 return; 156 return;
151 if (errno != ENODEV) 157 if (errno != ENODEV)
152 PLOG(ERROR) << "error reading device " << path_.value(); 158 PLOG(ERROR) << "error reading device " << path_.value();
153 Stop(); 159 Stop();
154 return; 160 return;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 293
288 // Subsequent events for this finger will be touch-move until it 294 // Subsequent events for this finger will be touch-move until it
289 // is released. 295 // is released.
290 events_[i].type_ = ET_TOUCH_MOVED; 296 events_[i].type_ = ET_TOUCH_MOVED;
291 } 297 }
292 } 298 }
293 altered_slots_.reset(); 299 altered_slots_.reset();
294 } 300 }
295 301
296 } // namespace ui 302 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/touch_event_converter_evdev.h ('k') | ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698