| OLD | NEW |
| 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> |
| 11 #include <stdio.h> | 11 #include <stdio.h> |
| 12 #include <unistd.h> | 12 #include <unistd.h> |
| 13 | 13 |
| 14 #include <cmath> | 14 #include <cmath> |
| 15 #include <limits> | 15 #include <limits> |
| 16 | 16 |
| 17 #include "base/bind.h" | 17 #include "base/bind.h" |
| 18 #include "base/callback.h" | 18 #include "base/callback.h" |
| 19 #include "base/command_line.h" | 19 #include "base/command_line.h" |
| 20 #include "base/logging.h" | 20 #include "base/logging.h" |
| 21 #include "base/memory/scoped_vector.h" | 21 #include "base/memory/scoped_vector.h" |
| 22 #include "base/message_loop/message_loop.h" | 22 #include "base/message_loop/message_loop.h" |
| 23 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
| 24 #include "base/strings/string_split.h" |
| 24 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
| 25 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
| 26 #include "base/trace_event/trace_event.h" | 27 #include "base/trace_event/trace_event.h" |
| 27 #include "ui/events/devices/device_data_manager.h" | 28 #include "ui/events/devices/device_data_manager.h" |
| 28 #include "ui/events/devices/device_util_linux.h" | 29 #include "ui/events/devices/device_util_linux.h" |
| 29 #include "ui/events/event.h" | 30 #include "ui/events/event.h" |
| 30 #include "ui/events/event_constants.h" | 31 #include "ui/events/event_constants.h" |
| 31 #include "ui/events/event_switches.h" | 32 #include "ui/events/event_switches.h" |
| 32 #include "ui/events/event_utils.h" | 33 #include "ui/events/event_utils.h" |
| 33 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" | 34 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" |
| 34 #include "ui/events/ozone/evdev/touch_evdev_types.h" | 35 #include "ui/events/ozone/evdev/touch_evdev_types.h" |
| 35 #include "ui/events/ozone/evdev/touch_noise/touch_noise_finder.h" | 36 #include "ui/events/ozone/evdev/touch_noise/touch_noise_finder.h" |
| 36 | 37 |
| 37 namespace { | 38 namespace { |
| 38 | 39 |
| 39 const int kMaxTrackingId = 0xffff; // TRKID_MAX in kernel. | 40 const int kMaxTrackingId = 0xffff; // TRKID_MAX in kernel. |
| 40 | 41 |
| 41 struct TouchCalibration { | 42 struct TouchCalibration { |
| 42 int bezel_left; | 43 int bezel_left; |
| 43 int bezel_right; | 44 int bezel_right; |
| 44 int bezel_top; | 45 int bezel_top; |
| 45 int bezel_bottom; | 46 int bezel_bottom; |
| 46 }; | 47 }; |
| 47 | 48 |
| 48 void GetTouchCalibration(TouchCalibration* cal) { | 49 void GetTouchCalibration(TouchCalibration* cal) { |
| 49 std::vector<std::string> parts; | 50 std::vector<std::string> parts = base::SplitString( |
| 50 if (Tokenize(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 51 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 51 switches::kTouchCalibration), | 52 switches::kTouchCalibration), |
| 52 ",", &parts) >= 4) { | 53 ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 54 |
| 55 if (parts.size() >= 4) { |
| 53 if (!base::StringToInt(parts[0], &cal->bezel_left)) | 56 if (!base::StringToInt(parts[0], &cal->bezel_left)) |
| 54 LOG(ERROR) << "Incorrect left border calibration value passed."; | 57 LOG(ERROR) << "Incorrect left border calibration value passed."; |
| 55 if (!base::StringToInt(parts[1], &cal->bezel_right)) | 58 if (!base::StringToInt(parts[1], &cal->bezel_right)) |
| 56 LOG(ERROR) << "Incorrect right border calibration value passed."; | 59 LOG(ERROR) << "Incorrect right border calibration value passed."; |
| 57 if (!base::StringToInt(parts[2], &cal->bezel_top)) | 60 if (!base::StringToInt(parts[2], &cal->bezel_top)) |
| 58 LOG(ERROR) << "Incorrect top border calibration value passed."; | 61 LOG(ERROR) << "Incorrect top border calibration value passed."; |
| 59 if (!base::StringToInt(parts[3], &cal->bezel_bottom)) | 62 if (!base::StringToInt(parts[3], &cal->bezel_bottom)) |
| 60 LOG(ERROR) << "Incorrect bottom border calibration value passed."; | 63 LOG(ERROR) << "Incorrect bottom border calibration value passed."; |
| 61 } | 64 } |
| 62 } | 65 } |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 if (pressure_max_ - pressure_min_) | 436 if (pressure_max_ - pressure_min_) |
| 434 pressure /= pressure_max_ - pressure_min_; | 437 pressure /= pressure_max_ - pressure_min_; |
| 435 return pressure; | 438 return pressure; |
| 436 } | 439 } |
| 437 | 440 |
| 438 int TouchEventConverterEvdev::NextTrackingId() { | 441 int TouchEventConverterEvdev::NextTrackingId() { |
| 439 return next_tracking_id_++ & kMaxTrackingId; | 442 return next_tracking_id_++ & kMaxTrackingId; |
| 440 } | 443 } |
| 441 | 444 |
| 442 } // namespace ui | 445 } // namespace ui |
| OLD | NEW |