24#ifndef GAMP_WTPOINTEREVENT_HPP_
25#define GAMP_WTPOINTEREVENT_HPP_
50 using namespace jau::enums;
77 const uint16_t m = 1U << 15 | 1U << 14;
114 res.
x = rotationXorY;
116 res.
y = rotationXorY;
145 m_pos.push_back(pos);
150 m_pressure.push_back(constMousePressure1);
153 m_pressure.push_back(constMousePressure0);
155 m_pointerID.push_back(
id);
156 m_pointerType.push_back(ptype);
184 const std::vector<PointerType>&
pointerType,
const std::vector<uint16_t>& pointerID,
185 const std::vector<jau::math::Vec2i>& pos,
const std::vector<float>&
pressure,
float maxPressure,
194 throw jau::IllegalArgumentError(
"All multiple pointer arrays must be of same size", E_FILE_LINE);
197 throw jau::IllegalArgumentError(
"maxPressure must be > 0.0f", E_FILE_LINE);
201 m_pointerID = pointerID;
212 m_pos, m_pressure, m_maxPressure, m_clickCount, m_button, m_rotation, m_rotationScale);
219 constexpr size_t pointerCount() const noexcept {
return m_pointerType.size(); }
226 if( index >= m_pointerType.size() ) {
229 return m_pointerType[index];
236 constexpr const std::vector<PointerType>&
allPointerTypes() const noexcept {
return m_pointerType; }
247 constexpr int pointerId(
size_t index = 0) const noexcept {
248 if( index >= m_pointerID.size() ) {
251 return m_pointerID[index];
260 if( m_pointerID[i] ==
id ) {
271 constexpr const std::vector<uint16_t>&
allPointerIDs() const noexcept {
return m_pointerID; }
284 constexpr uint16_t
clickCount() const noexcept {
return m_clickCount; }
302 constexpr const std::vector<jau::math::Vec2i>&
allPositions() const noexcept {
return m_pos; }
310 constexpr float pressure(
bool normalized)
const noexcept {
return pressure(0, normalized); }
320 constexpr float pressure(
size_t index,
bool normalized)
const noexcept {
321 return normalized ? m_pressure[index] / m_maxPressure : m_pressure[index];
328 constexpr const std::vector<float>&
allPressures() const noexcept {
return m_pressure; }
343 constexpr float maxPressure() const noexcept {
return m_maxPressure; }
403 std::string sb =
"PointerEvent[";
404 sb.append(getEventTypeString())
407 .append(
"], button ")
410 .append(std::to_string(m_clickCount));
412 sb.append(
", rotation [")
413 .append(m_rotation.toString())
415 .append(std::to_string(m_rotationScale));
417 if( m_pointerID.size() > 0 ) {
418 sb.append(
", pointer<").append(std::to_string(m_pointerID.size())).append(
">[");
419 for(
size_t i = 0; i < m_pointerID.size(); i++ ) {
423 sb.append(std::to_string(m_pointerID[i])).append(
"/").append(
to_string(m_pointerType[i])).append(
": ")
424 .append(m_pos[i].
toString()).append(
", ")
425 .append(
"p[").append(std::to_string(m_pressure[i])).append(
"/").append(std::to_string(m_maxPressure)).append(
"=")
426 .append(std::to_string(m_pressure[i] / m_maxPressure)).append(
"]");
435 std::string getEventTypeString() const noexcept {
445 default:
return "unknown (" + std::to_string(
type()) +
")";
450 std::vector<PointerType> m_pointerType;
452 std::vector<uint16_t> m_pointerID;
454 std::vector<jau::math::Vec2i> m_pos;
456 std::vector<float> m_pressure;
458 uint16_t m_clickCount;
469 float m_rotationScale;
472 constexpr static float constMousePressure0 = 0.0f;
473 constexpr static float constMousePressure1 = 1.0f;
Pointer event of type PointerType.
constexpr uint16_t clickCount() const noexcept
constexpr const std::vector< float > & allPressures() const noexcept
See details for multiple-pointer events.
constexpr PointerType pointerType(size_t index) const noexcept
See details for multiple-pointer events.
constexpr InputButton button() const noexcept
Returns the button number, e.g.
constexpr float rotationScale() const noexcept
Returns the scale used to determine the rotation value, which semantics depends on the pointer type's...
constexpr int pointerId(size_t index=0) const noexcept
Return the pointer id for the given index or -1 if index not available.
std::string toString() const noexcept
constexpr const std::vector< PointerType > & allPointerTypes() const noexcept
See details for multiple-pointer events.
constexpr const jau::math::Vec2i & position(size_t index=0) const noexcept
Returns position of given pointer-index in pixel units.
int pointerIdx(uint16_t id) const
See details for multiple-pointer events.
static constexpr uint16_t clickTimeout()
constexpr float maxPressure() const noexcept
Returns the maximum pressure known for the input device generating this event.
constexpr const std::vector< uint16_t > & allPointerIDs() const noexcept
See details for multiple-pointer events.
constexpr float pressure(size_t index, bool normalized) const noexcept
See details for multiple-pointer events.
constexpr size_t pointerCount() const noexcept
See details for multiple-pointer events.
PointerEvent(uint16_t type, const jau::fraction_timespec &when, const WindowRef &source, InputModifier mods, const std::vector< PointerType > &pointerType, const std::vector< uint16_t > &pointerID, const std::vector< jau::math::Vec2i > &pos, const std::vector< float > &pressure, float maxPressure, uint16_t clickCount, InputButton button, const jau::math::Vec3f &rotation, float rotationScale)
Constructor for a multiple-pointer event.
constexpr const jau::math::Vec3f & rotation() const noexcept
Returns a 3-component float array filled with the values of the rotational axis in the following orde...
PointerEvent createVariant(uint16_t newEventType)
constexpr float pressure(bool normalized) const noexcept
PointerEvent(uint16_t type, const jau::fraction_timespec &when, const WindowRef &source, InputModifier mods, PointerType ptype, uint16_t id, jau::math::Vec2i pos, uint16_t clickCount, InputButton button, jau::math::Vec3f rotation, float rotationScale)
Constructor for traditional one-pointer event.
constexpr const std::vector< jau::math::Vec2i > & allPositions() const noexcept
Returns position of all pointers in pixel units.
static jau::math::Vec3f swapRotation(float rotationXorY, InputModifier mods)
Returns the 3-axis XYZ rotation array by given rotation on Y axis or X axis (if InputModifier::shift ...
Listener for PointerEvent.
virtual void pointerDragged(PointerEvent &)
virtual void pointerReleased(PointerEvent &)
virtual void pointerEntered(PointerEvent &)
Only generated for PointerType#Mouse.
virtual ~PointerListener() noexcept=default
virtual void pointerClicked(PointerEvent &)
virtual void pointerExited(PointerEvent &)
Only generated for PointerType#Mouse.
virtual void pointerMoved(PointerEvent &)
virtual void pointerWheelMoved(PointerEvent &)
Traditional event name originally produced by a PointerType::mouse pointer type.
virtual void pointerPressed(PointerEvent &)
constexpr const WindowWeakPtr & source() const noexcept
constexpr const jau::fraction_timespec & when() const noexcept
constexpr uint16_t type() const noexcept
std::string to_string(const endian_t v) noexcept
Return std::string representation of the given endian.
constexpr std::underlying_type_t< E > number(const E v) noexcept
#define JAU_MAKE_ENUM_STRING(type,...)
constexpr bool is_set(const E mask, const E bits) noexcept
static constexpr short EVENT_POINTER_WHEEL
static constexpr short EVENT_POINTER_PRESSED
std::shared_ptr< PointerListener > PointerListenerRef
static constexpr short EVENT_POINTER_RELEASED
PointerClass
Class of pointer types.
static constexpr short EVENT_POINTER_CLICKED
constexpr PointerClass getPointerClass(PointerType pt) noexcept
static constexpr short EVENT_POINTER_EXITED
Only generated for PointerType::mouse.
PointerType
Type of pointer devices.
static constexpr short EVENT_POINTER_DRAGGED
std::shared_ptr< Window > WindowRef
static constexpr short EVENT_POINTER_MOVED
static constexpr short EVENT_POINTER_ENTERED
Only generated for PointerType::mouse.
@ offscreen
Desktop compatibility profile.
@ onscreen
Desktop core profile.
@ pen
Pen usually off-screen.
@ touchscreen
Touch screen, fingers on screen.
@ touchpad
Touch pad, fingers off screen.
std::string to_string(const math_error_t v) noexcept
Returns std::string representation of math_error_t.
Timespec structure using int64_t for its components in analogy to struct timespec_t on 64-bit platfor...