#include "ui/events/ozone/evdev/input_device_factory_evdev.h"
#include <fcntl.h>
#include <linux/input.h>
#include <stddef.h>
#include <utility>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/files/scoped_file.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/task/single_thread_task_runner.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/devices/input_device.h"
#include "ui/events/devices/keyboard_device.h"
#include "ui/events/devices/stylus_state.h"
#include "ui/events/devices/touchpad_device.h"
#include "ui/events/event_switches.h"
#include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h"
#include "ui/events/ozone/evdev/event_converter_evdev_impl.h"
#include "ui/events/ozone/evdev/event_device_info.h"
#include "ui/events/ozone/evdev/gamepad_event_converter_evdev.h"
#include "ui/events/ozone/evdev/imposter_checker_evdev.h"
#include "ui/events/ozone/evdev/imposter_checker_evdev_state.h"
#include "ui/events/ozone/evdev/input_controller_evdev.h"
#include "ui/events/ozone/evdev/input_device_settings_evdev.h"
#include "ui/events/ozone/evdev/microphone_mute_switch_event_converter_evdev.h"
#include "ui/events/ozone/evdev/stylus_button_event_converter_evdev.h"
#include "ui/events/ozone/evdev/tablet_event_converter_evdev.h"
#include "ui/events/ozone/evdev/touch_evdev_types.h"
#include "ui/events/ozone/evdev/touch_event_converter_evdev.h"
#include "ui/events/ozone/features.h"
#include "ui/events/ozone/gamepad/gamepad_provider_ozone.h"
#if defined(USE_EVDEV_GESTURES)
#include "ui/events/ozone/evdev/libgestures_glue/event_reader_libevdev_cros.h"
#include "ui/events/ozone/evdev/libgestures_glue/gesture_feedback.h"
#include "ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.h"
#include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h"
#endif
#if defined(USE_LIBINPUT)
#include "ui/events/ozone/evdev/libinput_event_converter.h"
#endif
#ifndef EVIOCSCLOCKID
#define EVIOCSCLOCKID …
#endif
namespace ui {
namespace {
#if defined(USE_EVDEV_GESTURES)
void SetGestureIntProperty(GesturePropertyProvider* provider,
int id,
const std::string& name,
int value) {
GesturesProp* property = provider->GetProperty(id, name);
if (property) {
std::vector<int> values(1, value);
property->SetIntValue(values);
}
}
void SetGestureBoolProperty(GesturePropertyProvider* provider,
int id,
const std::string& name,
bool value) {
GesturesProp* property = provider->GetProperty(id, name);
if (property) {
std::vector<bool> values(1, value);
property->SetBoolValue(values);
}
}
#endif
bool IsUncategorizedDevice(const EventConverterEvdev& converter) { … }
}
InputDeviceFactoryEvdev::InputDeviceFactoryEvdev(
std::unique_ptr<DeviceEventDispatcherEvdev> dispatcher,
CursorDelegateEvdev* cursor,
std::unique_ptr<InputDeviceOpener> input_device_opener,
InputControllerEvdev* input_controller)
: … { … }
InputDeviceFactoryEvdev::~InputDeviceFactoryEvdev() = default;
void InputDeviceFactoryEvdev::AddInputDevice(int id,
const base::FilePath& path) { … }
void InputDeviceFactoryEvdev::RemoveInputDevice(const base::FilePath& path) { … }
void InputDeviceFactoryEvdev::OnStartupScanComplete() { … }
void InputDeviceFactoryEvdev::AttachInputDevice(
std::unique_ptr<EventConverterEvdev> converter) { … }
void InputDeviceFactoryEvdev::DetachInputDevice(const base::FilePath& path) { … }
void InputDeviceFactoryEvdev::GetStylusSwitchState(
InputController::GetStylusSwitchStateReply reply) { … }
void InputDeviceFactoryEvdev::SetCapsLockLed(bool enabled) { … }
void InputDeviceFactoryEvdev::UpdateInputDeviceSettings(
const InputDeviceSettingsEvdev& settings) { … }
void InputDeviceFactoryEvdev::GetTouchDeviceStatus(
InputController::GetTouchDeviceStatusReply reply) { … }
void InputDeviceFactoryEvdev::GetTouchEventLog(
const base::FilePath& out_dir,
InputController::GetTouchEventLogReply reply) { … }
void InputDeviceFactoryEvdev::DescribeForLog(
InputController::DescribeForLogReply reply) const { … }
void InputDeviceFactoryEvdev::GetGesturePropertiesService(
mojo::PendingReceiver<ozone::mojom::GesturePropertiesService> receiver) { … }
base::WeakPtr<InputDeviceFactoryEvdev> InputDeviceFactoryEvdev::GetWeakPtr() { … }
void InputDeviceFactoryEvdev::SetMousePropertiesPerDevice() { … }
void InputDeviceFactoryEvdev::SetTouchpadPropertiesPerDevice() { … }
void InputDeviceFactoryEvdev::SetPointingStickPropertiesPerDevice() { … }
void InputDeviceFactoryEvdev::ApplyInputDeviceSettings() { … }
void InputDeviceFactoryEvdev::ApplyCapsLockLed() { … }
void InputDeviceFactoryEvdev::PlayVibrationEffect(int id,
uint8_t amplitude,
uint16_t duration_millis) { … }
void InputDeviceFactoryEvdev::StopVibration(int id) { … }
void InputDeviceFactoryEvdev::PlayHapticTouchpadEffect(
ui::HapticTouchpadEffect effect,
ui::HapticTouchpadEffectStrength strength) { … }
void InputDeviceFactoryEvdev::SetHapticTouchpadEffectForNextButtonRelease(
ui::HapticTouchpadEffect effect,
ui::HapticTouchpadEffectStrength strength) { … }
bool InputDeviceFactoryEvdev::IsDeviceEnabled(
const EventConverterEvdev* converter) { … }
void InputDeviceFactoryEvdev::UpdateDirtyFlags(
const EventConverterEvdev* converter) { … }
void InputDeviceFactoryEvdev::NotifyDevicesUpdated() { … }
void InputDeviceFactoryEvdev::NotifyTouchscreensUpdated() { … }
void InputDeviceFactoryEvdev::NotifyKeyboardsUpdated() { … }
void InputDeviceFactoryEvdev::NotifyMouseDevicesUpdated() { … }
void InputDeviceFactoryEvdev::NotifyPointingStickDevicesUpdated() { … }
void InputDeviceFactoryEvdev::NotifyTouchpadDevicesUpdated() { … }
void InputDeviceFactoryEvdev::NotifyGraphicsTabletDevicesUpdated() { … }
void InputDeviceFactoryEvdev::NotifyGamepadDevicesUpdated() { … }
void InputDeviceFactoryEvdev::NotifyUncategorizedDevicesUpdated() { … }
void InputDeviceFactoryEvdev::UpdateDevicesOnImposterOverride(
const EventConverterEvdev* converter) { … }
void InputDeviceFactoryEvdev::SetBoolPropertyForOneDevice(
int device_id,
const std::string& name,
bool value) { … }
void InputDeviceFactoryEvdev::SetIntPropertyForOneDevice(
int device_id,
const std::string& name,
int value) { … }
void InputDeviceFactoryEvdev::SetIntPropertyForOneType(
const EventDeviceType type,
const std::string& name,
int value) { … }
void InputDeviceFactoryEvdev::SetBoolPropertyForOneType(
const EventDeviceType type,
const std::string& name,
bool value) { … }
void InputDeviceFactoryEvdev::EnablePalmSuppression(bool enabled) { … }
void InputDeviceFactoryEvdev::EnableDevices() { … }
void InputDeviceFactoryEvdev::DisableKeyboardImposterCheck() { … }
void InputDeviceFactoryEvdev::ForceReloadKeyboards() { … }
void InputDeviceFactoryEvdev::SetLatestStylusState(
const InProgressTouchEvdev& event,
const int32_t x_res,
const int32_t y_res,
const base::TimeTicks& timestamp) { … }
void InputDeviceFactoryEvdev::GetLatestStylusState(
const InProgressStylusState** stylus_state) const { … }
}