#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "ui/events/ozone/evdev/event_device_info.h"
#include <linux/input.h>
#include <cstring>
#include "base/containers/fixed_flat_set.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
#include "base/notreached.h"
#include "base/threading/thread_restrictions.h"
#include "base/types/fixed_array.h"
#include "ui/events/devices/device_util_linux.h"
#include "ui/events/ozone/evdev/keyboard_mouse_combo_device_metrics.h"
#include "ui/events/ozone/features.h"
#if !defined(EVIOCGMTSLOTS)
#define EVIOCGMTSLOTS …
#endif
#ifndef INPUT_PROP_HAPTICPAD
#define INPUT_PROP_HAPTICPAD …
#endif
namespace ui {
namespace {
const size_t kMaximumDeviceNameLength = …;
struct DeviceId { … };
constexpr auto kKeyboardAllowlist = …;
constexpr auto kKeyboardBlocklist = …;
constexpr DeviceId kStylusButtonDevices[] = …;
constexpr DeviceId kHeatmapSupportedDevices[] = …;
constexpr DeviceId kForceLibinputlist[] = …;
bool IsForceLibinput(const EventDeviceInfo& devinfo) { … }
const uint16_t kSteelSeriesBluetoothVendorId = …;
const uint16_t kSteelSeriesStratusDuoBluetoothProductId = …;
const uint16_t kSteelSeriesStratusPlusBluetoothProductId = …;
const uint16_t kFlossVirtualSuspendVendorId = …;
const uint16_t kFlossVirtualSuspendProductId = …;
const char kFlossVirtualSuspendName[] = …;
bool GetEventBits(int fd,
const base::FilePath& path,
unsigned int type,
void* buf,
unsigned int size) { … }
bool GetPropBits(int fd,
const base::FilePath& path,
void* buf,
unsigned int size) { … }
bool GetAbsInfo(int fd,
const base::FilePath& path,
int code,
struct input_absinfo* absinfo) { … }
bool GetDeviceName(int fd, const base::FilePath& path, std::string* name) { … }
bool GetDeviceIdentifiers(int fd, const base::FilePath& path, input_id* id) { … }
void GetDevicePhysInfo(int fd, const base::FilePath& path, std::string* phys) { … }
void GetSlotValues(int fd,
const base::FilePath& path,
int32_t* request,
unsigned int size) { … }
void AssignBitset(const unsigned long* src,
size_t src_len,
unsigned long* dst,
size_t dst_len) { … }
bool IsDenylistedAbsoluteMouseDevice(const input_id& id) { … }
}
EventDeviceInfo::EventDeviceInfo()
: … { … }
EventDeviceInfo::~EventDeviceInfo() { … }
bool EventDeviceInfo::Initialize(int fd, const base::FilePath& path) { … }
void EventDeviceInfo::SetEventTypes(const unsigned long* ev_bits, size_t len) { … }
void EventDeviceInfo::SetKeyEvents(const unsigned long* key_bits, size_t len) { … }
void EventDeviceInfo::SetRelEvents(const unsigned long* rel_bits, size_t len) { … }
void EventDeviceInfo::SetAbsEvents(const unsigned long* abs_bits, size_t len) { … }
void EventDeviceInfo::SetMscEvents(const unsigned long* msc_bits, size_t len) { … }
void EventDeviceInfo::SetSwEvents(const unsigned long* sw_bits, size_t len) { … }
void EventDeviceInfo::SetLedEvents(const unsigned long* led_bits, size_t len) { … }
void EventDeviceInfo::SetFfEvents(const unsigned long* ff_bits, size_t len) { … }
void EventDeviceInfo::SetProps(const unsigned long* prop_bits, size_t len) { … }
void EventDeviceInfo::SetAbsInfo(unsigned int code,
const input_absinfo& abs_info) { … }
void EventDeviceInfo::SetAbsMtSlots(unsigned int code,
const std::vector<int32_t>& values) { … }
void EventDeviceInfo::SetAbsMtSlot(unsigned int code,
unsigned int slot,
uint32_t value) { … }
void EventDeviceInfo::SetDeviceType(InputDeviceType type) { … }
void EventDeviceInfo::SetId(input_id id) { … }
void EventDeviceInfo::SetName(const std::string& name) { … }
bool EventDeviceInfo::HasEventType(unsigned int type) const { … }
bool EventDeviceInfo::HasKeyEvent(unsigned int code) const { … }
bool EventDeviceInfo::HasRelEvent(unsigned int code) const { … }
bool EventDeviceInfo::HasAbsEvent(unsigned int code) const { … }
bool EventDeviceInfo::HasMscEvent(unsigned int code) const { … }
bool EventDeviceInfo::HasSwEvent(unsigned int code) const { … }
bool EventDeviceInfo::HasLedEvent(unsigned int code) const { … }
bool EventDeviceInfo::HasFfEvent(unsigned int code) const { … }
bool EventDeviceInfo::HasProp(unsigned int code) const { … }
bool EventDeviceInfo::SupportsHeatmap() const { … }
int32_t EventDeviceInfo::GetAbsMinimum(unsigned int code) const { … }
int32_t EventDeviceInfo::GetAbsMaximum(unsigned int code) const { … }
int32_t EventDeviceInfo::GetAbsResolution(unsigned int code) const { … }
int32_t EventDeviceInfo::GetAbsValue(unsigned int code) const { … }
input_absinfo EventDeviceInfo::GetAbsInfoByCode(unsigned int code) const { … }
uint32_t EventDeviceInfo::GetAbsMtSlotCount() const { … }
int32_t EventDeviceInfo::GetAbsMtSlotValue(unsigned int code,
unsigned int slot) const { … }
int32_t EventDeviceInfo::GetAbsMtSlotValueWithDefault(
unsigned int code,
unsigned int slot,
int32_t default_value) const { … }
bool EventDeviceInfo::HasAbsXY() const { … }
bool EventDeviceInfo::HasMTAbsXY() const { … }
bool EventDeviceInfo::HasRelXY() const { … }
bool EventDeviceInfo::HasMultitouch() const { … }
bool EventDeviceInfo::HasDirect() const { … }
bool EventDeviceInfo::HasPointer() const { … }
bool EventDeviceInfo::HasStylus() const { … }
bool EventDeviceInfo::IsSemiMultitouch() const { … }
bool EventDeviceInfo::IsStylusButtonDevice() const { … }
bool EventDeviceInfo::IsMicrophoneMuteSwitchDevice() const { … }
bool EventDeviceInfo::UseLibinput() const { … }
void RecordBlocklistedKeyboardMetric(input_id input_id_) { … }
bool IsInKeyboardBlockList(input_id input_id_) { … }
bool IsInKeyboardAllowList(input_id input_id_) { … }
bool EventDeviceInfo::HasKeyboard() const { … }
KeyboardType EventDeviceInfo::GetKeyboardType() const { … }
bool EventDeviceInfo::HasMouse() const { … }
bool EventDeviceInfo::HasPointingStick() const { … }
bool EventDeviceInfo::HasTouchpad() const { … }
bool EventDeviceInfo::HasHapticTouchpad() const { … }
bool EventDeviceInfo::HasTablet() const { … }
bool EventDeviceInfo::HasTouchscreen() const { … }
bool EventDeviceInfo::HasStylusSwitch() const { … }
bool EventDeviceInfo::HasNumberpad() const { … }
bool EventDeviceInfo::HasGamepad() const { … }
bool EventDeviceInfo::HasValidMTAbsXY() const { … }
bool EventDeviceInfo::SupportsRumble() const { … }
ui::InputDeviceType EventDeviceInfo::GetInputDeviceTypeFromId(input_id id) { … }
bool EventDeviceInfo::IsInternalUSB(input_id id) { … }
EventDeviceInfo::LegacyAbsoluteDeviceType
EventDeviceInfo::ProbeLegacyAbsoluteDevice() const { … }
std::ostream& operator<<(std::ostream& os, const EventDeviceType value) { … }
std::ostream& operator<<(std::ostream& os, const KeyboardType value) { … }
}