#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "ui/events/ozone/evdev/touch_event_converter_evdev.h"
#include <errno.h>
#include <fcntl.h>
#include <linux/input.h>
#include <poll.h>
#include <stdio.h>
#include <unistd.h>
#include <cmath>
#include <limits>
#include <optional>
#include <queue>
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "ui/events/devices/device_data_manager.h"
#include "ui/events/devices/device_util_linux.h"
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
#include "ui/events/event_switches.h"
#include "ui/events/event_utils.h"
#include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h"
#include "ui/events/ozone/evdev/touch_evdev_types.h"
#include "ui/events/ozone/evdev/touch_filter/false_touch_finder.h"
#include "ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.h"
#include "ui/events/ozone/evdev/touch_filter/palm_detection_filter.h"
#include "ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory.h"
#include "ui/events/ozone/features.h"
#include "ui/events/types/event_type.h"
#include "ui/ozone/public/input_controller.h"
namespace {
const int kMaxTrackingId = …;
const int kMaxTouchSessionGapInSeconds = …;
const int kMaxTouchStylusGapInSeconds = …;
const int kMaxRepeatedTouchGapInSeconds = …;
const float kRepeatedTouchThresholdInSquareMillimeter = …;
const int kMaxTouchStylusGapInMs = …;
enum class TouchType { … };
float ScaleTilt(int value, int min_value, int num_values) { … }
int32_t AbsCodeToMtCode(int32_t code) { … }
ui::EventPointerType GetEventPointerType(int tool_code) { … }
float GetFingerSizeScale(int32_t finger_size_res, int32_t screen_size_res) { … }
const int kTrackingIdForUnusedSlot = …;
struct SupportedHidrawDevice { … };
std::vector<SupportedHidrawDevice> GetSupportedHidrawDevices() { … }
ui::HeatmapPalmDetector::ModelId GetHidrawModelId(
const ui::EventDeviceInfo& info) { … }
base::FilePath GetHidrawPath(const base::FilePath& root_path) { … }
std::optional<ui::HeatmapPalmDetector::CropHeatmap> GetCropHeatmap(
const ui::EventDeviceInfo& info) { … }
}
namespace ui {
BASE_FEATURE(…);
TouchEventConverterEvdev::TouchEventConverterEvdev(
base::ScopedFD fd,
base::FilePath path,
int id,
const EventDeviceInfo& devinfo,
SharedPalmDetectionFilterState* shared_palm_state,
DeviceEventDispatcherEvdev* dispatcher)
: … { … }
TouchEventConverterEvdev::~TouchEventConverterEvdev() = default;
std::unique_ptr<TouchEventConverterEvdev> TouchEventConverterEvdev::Create(
base::ScopedFD fd,
base::FilePath path,
int id,
const EventDeviceInfo& devinfo,
SharedPalmDetectionFilterState* shared_palm_state,
DeviceEventDispatcherEvdev* dispatcher) { … }
void TouchEventConverterEvdev::Initialize(const EventDeviceInfo& info) { … }
void TouchEventConverterEvdev::Reinitialize() { … }
bool TouchEventConverterEvdev::HasTouchscreen() const { … }
bool TouchEventConverterEvdev::HasPen() const { … }
gfx::Size TouchEventConverterEvdev::GetTouchscreenSize() const { … }
int TouchEventConverterEvdev::GetTouchPoints() const { … }
void TouchEventConverterEvdev::OnEnabled() { … }
void TouchEventConverterEvdev::OnDisabled() { … }
void TouchEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { … }
void TouchEventConverterEvdev::DumpTouchEventLog(const char* filename) { … }
void TouchEventConverterEvdev::SetTouchEventLoggingEnabled(bool enabled) { … }
void TouchEventConverterEvdev::SetPalmSuppressionCallback(
const base::RepeatingCallback<void(bool)>& callback) { … }
void TouchEventConverterEvdev::SetReportStylusStateCallback(
const ReportStylusStateCallback& callback) { … }
void TouchEventConverterEvdev::SetGetLatestStylusStateCallback(
const GetLatestStylusStateCallback& callback) { … }
void TouchEventConverterEvdev::ProcessMultitouchEvent(
const input_event& input) { … }
void TouchEventConverterEvdev::EmulateMultitouchEvent(
const input_event& event) { … }
void TouchEventConverterEvdev::ProcessKey(const input_event& input) { … }
void TouchEventConverterEvdev::ProcessAbs(const input_event& input) { … }
void TouchEventConverterEvdev::ProcessSyn(const input_event& input) { … }
EventType TouchEventConverterEvdev::GetEventTypeForTouch(
const InProgressTouchEvdev& touch) { … }
void TouchEventConverterEvdev::ReportTouchEvent(
const InProgressTouchEvdev& event,
EventType event_type,
base::TimeTicks timestamp) { … }
bool TouchEventConverterEvdev::MaybeCancelAllTouches() { … }
bool TouchEventConverterEvdev::IsPalm(const InProgressTouchEvdev& touch) { … }
void TouchEventConverterEvdev::ReportEvents(base::TimeTicks timestamp) { … }
void TouchEventConverterEvdev::UpdateSharedPalmState(
base::TimeTicks timestamp) { … }
void TouchEventConverterEvdev::DetectRepeatedTouch(base::TimeTicks timestamp) { … }
void TouchEventConverterEvdev::RecordMetrics(base::TimeTicks timestamp) { … }
void TouchEventConverterEvdev::RecordSession(base::TimeDelta session_length) { … }
void TouchEventConverterEvdev::ProcessTouchEvent(InProgressTouchEvdev* event,
base::TimeTicks timestamp) { … }
void TouchEventConverterEvdev::UpdateTrackingId(int slot, int tracking_id) { … }
void TouchEventConverterEvdev::ReleaseTouches() { … }
float TouchEventConverterEvdev::ScalePressure(int32_t value) const { … }
bool TouchEventConverterEvdev::SupportsOrientation() const { … }
void TouchEventConverterEvdev::UpdateRadiusFromTouchWithOrientation(
InProgressTouchEvdev* event) const { … }
int TouchEventConverterEvdev::NextTrackingId() { … }
std::ostream& TouchEventConverterEvdev::DescribeForLog(std::ostream& os) const { … }
const char TouchEventConverterEvdev::kHoldCountAtReleaseEventName[] = …;
const char TouchEventConverterEvdev::kHoldCountAtCancelEventName[] = …;
const char TouchEventConverterEvdev::kPalmFilterTimerEventName[] = …;
const char TouchEventConverterEvdev::kPalmTouchCountEventName[] = …;
const char TouchEventConverterEvdev::kRepeatedTouchCountEventName[] = …;
const char TouchEventConverterEvdev::kTouchGapAfterStylusEventName[] = …;
const char TouchEventConverterEvdev::kTouchGapBeforeStylusEventName[] = …;
const char TouchEventConverterEvdev::kTouchTypeAfterStylusEventName[] = …;
const char TouchEventConverterEvdev::kTouchTypeBeforeStylusEventName[] = …;
const char TouchEventConverterEvdev::kTouchSessionCountEventName[] = …;
const char TouchEventConverterEvdev::kTouchSessionLengthEventName[] = …;
const char TouchEventConverterEvdev::kStylusSessionCountEventName[] = …;
const char TouchEventConverterEvdev::kStylusSessionLengthEventName[] = …;
}