#ifndef UI_BASE_POINTER_POINTER_DEVICE_H_
#define UI_BASE_POINTER_POINTER_DEVICE_H_
#include <cstdint>
#include <optional>
#include <tuple>
#include <utility>
#include <vector>
#include "base/component_export.h"
#include "build/build_config.h"
#if BUILDFLAG(IS_ANDROID)
#include <jni.h>
#endif
#if BUILDFLAG(IS_WIN)
#include "base/win/windows_types.h"
#endif
namespace ui {
enum class TouchScreensAvailability {
NONE,
ENABLED,
DISABLED,
};
COMPONENT_EXPORT(UI_BASE)
TouchScreensAvailability GetTouchScreensAvailability();
COMPONENT_EXPORT(UI_BASE) int MaxTouchPoints();
enum PointerType {
POINTER_TYPE_NONE = 1 << 0,
POINTER_TYPE_FIRST = POINTER_TYPE_NONE,
POINTER_TYPE_COARSE = 1 << 1,
POINTER_TYPE_FINE = 1 << 2,
POINTER_TYPE_LAST = POINTER_TYPE_FINE
};
enum HoverType {
HOVER_TYPE_NONE = 1 << 0,
HOVER_TYPE_FIRST = HOVER_TYPE_NONE,
HOVER_TYPE_HOVER = 1 << 1,
HOVER_TYPE_LAST = HOVER_TYPE_HOVER
};
enum class PointerDigitizerType : uint8_t {
kUnknown = 0,
kDirectPen = 1,
kIndirectPen = 2,
kTouch = 3,
kTouchPad = 4,
kMaxValue = kTouchPad
};
struct COMPONENT_EXPORT(UI_BASE) PointerDevice final {
#if BUILDFLAG(IS_WIN)
using Key = HANDLE;
#else
using Key = uintptr_t;
#endif
Key key;
PointerDigitizerType digitizer;
int32_t max_active_contacts;
};
class COMPONENT_EXPORT(UI_BASE)
[[maybe_unused, nodiscard]] ScopedSetPointerAndHoverTypesForTesting {
public:
ScopedSetPointerAndHoverTypesForTesting(int available_pointer_types,
int available_hover_types);
~ScopedSetPointerAndHoverTypesForTesting();
const std::pair<int, int>& pointer_and_hover_types() const {
return pointer_and_hover_types_;
}
private:
std::pair<int, int> pointer_and_hover_types_;
};
COMPONENT_EXPORT(UI_BASE)
std::pair<int, int> GetAvailablePointerAndHoverTypes();
COMPONENT_EXPORT(UI_BASE) PointerType GetPrimaryPointerType();
COMPONENT_EXPORT(UI_BASE) HoverType GetPrimaryHoverType();
COMPONENT_EXPORT(UI_BASE)
std::optional<PointerDevice> GetPointerDevice(PointerDevice::Key key);
COMPONENT_EXPORT(UI_BASE) std::vector<PointerDevice> GetPointerDevices();
inline constexpr bool operator==(const PointerDevice& left,
const PointerDevice& right) {
return left.key == right.key;
}
inline constexpr bool operator==(const PointerDevice& left,
PointerDevice::Key right) {
return left.key == right;
}
inline constexpr bool operator==(PointerDevice::Key left,
const PointerDevice& right) {
return left == right.key;
}
}
#endif