Gamp v0.0.7-36-g24b1eb6
Gamp: Graphics, Audio, Multimedia and Processing
Loading...
Searching...
No Matches
gamp::wt::event::PointerEvent Class Reference

Pointer event of type PointerType. More...

#include <PointerEvent.hpp>

Inheritance diagram for gamp::wt::event::PointerEvent:
Collaboration diagram for gamp::wt::event::PointerEvent:

Public Member Functions

 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.
 
 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< uint16_t > & allPointerIDs () const noexcept
 See details for multiple-pointer events.
 
constexpr const std::vector< PointerType > & allPointerTypes () const noexcept
 See details for multiple-pointer events.
 
constexpr const std::vector< jau::math::Vec2i > & allPositions () const noexcept
 Returns position of all pointers in pixel units.
 
constexpr const std::vector< float > & allPressures () const noexcept
 See details for multiple-pointer events.
 
constexpr InputButton button () const noexcept
 Returns the button number, e.g.
 
constexpr uint16_t clickCount () const noexcept
 
PointerEvent createVariant (uint16_t newEventType)
 
constexpr float maxPressure () const noexcept
 Returns the maximum pressure known for the input device generating this event.
 
constexpr size_t pointerCount () const noexcept
 See details for multiple-pointer events.
 
constexpr int pointerId (size_t index=0) const noexcept
 Return the pointer id for the given index or -1 if index not available.
 
int pointerIdx (uint16_t id) const
 See details for multiple-pointer events.
 
constexpr PointerType pointerType (size_t index) const noexcept
 See details for multiple-pointer events.
 
constexpr const jau::math::Vec2iposition (size_t index=0) const noexcept
 Returns position of given pointer-index in pixel units.
 
constexpr float pressure (bool normalized) const noexcept
 
constexpr float pressure (size_t index, bool normalized) const noexcept
 See details for multiple-pointer events.
 
constexpr const jau::math::Vec3frotation () const noexcept
 Returns a 3-component float array filled with the values of the rotational axis in the following order: horizontal-, vertical- and z-axis.
 
constexpr float rotationScale () const noexcept
 Returns the scale used to determine the rotation value, which semantics depends on the pointer type's PointerClass.
 
std::string toString () const noexcept
 
- Public Member Functions inherited from gamp::wt::event::InputEvent
 InputEvent (uint16_t type, const jau::fraction_timespec &when, const WindowRef &source, InputModifier mods) noexcept
 
constexpr int buttonDownCount () const noexcept
 Returns the number of pressed buttons by counting the set bits:
 
std::vector< InputButtonbuttonsDown () const
 See also MouseEvent's section about Multiple-Pointer Events.
 
constexpr bool has_any (InputModifier bits) const noexcept
 Use with groups of bits / mask, e.g.
 
constexpr bool is_set (InputModifier bits) const noexcept
 Use with single bits, e.g.
 
constexpr bool isAltDown () const noexcept
 Returns true if modifier() contains InputModifier::alt.
 
constexpr bool isAnyButtonDown () const noexcept
 Returns true if at least one button is pressed, otherwise false:
 
constexpr bool isAutorepeat () const noexcept
 Returns true if modifier() contains InputModifier::autorepeat.
 
constexpr bool isButtonDown (InputButton button) const noexcept
 See also MouseEvent's section about Multiple-Pointer Events.
 
constexpr bool isConfined () const noexcept
 Returns true if modifier() contains InputModifier::confined.
 
constexpr bool isControlDown () const noexcept
 Returns true if modifier() contains InputModifier::ctrl.
 
constexpr bool isInvisible () const noexcept
 Returns true if modifier() contains InputModifier::invisible.
 
constexpr bool isMetaDown () const noexcept
 Returns true if modifier() contains InputModifier::meta.
 
constexpr bool isShiftDown () const noexcept
 Returns true if modifier() contains InputModifier::shift.
 
constexpr InputModifier modifier () const noexcept
 
std::string toString () const noexcept
 
- Public Member Functions inherited from gamp::wt::event::WTEvent
 WTEvent (uint16_t type, const jau::fraction_timespec &when, const WindowRef &source) noexcept
 
constexpr bool consumed () const noexcept
 Consumed events will stop traversing through listener.
 
constexpr void setConsumed (bool v) noexcept
 Consumed events will stop traversing through listener.
 
constexpr const WindowWeakPtrsource () const noexcept
 
std::string toString () const noexcept
 
constexpr uint16_t type () const noexcept
 
constexpr const jau::fraction_timespecwhen () const noexcept
 

Static Public Member Functions

static constexpr uint16_t clickTimeout ()
 
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 is given in mods).
 
- Static Public Member Functions inherited from gamp::wt::event::InputEvent
static constexpr InputModifier buttonMask (InputButton button) noexcept
 Returns the corresponding button mask for the given button.
 

Detailed Description

Pointer event of type PointerType.

See also W3C pointerevent-interface.

Unit of Coordinates

All pointer coordinates of this interface are represented in pixel units, see Surface and Window.

Orientation of coordinate system depends on Window::isPointerBLOriented(), i.e. defaults to bottom-left.

Multiple-Pointer Events

In case an instance represents a multiple-pointer event, i.e. getPointerCount() is > 1, the first data element of the multiple-pointer fields represents the pointer triggering this event.
For example e.getX(0) at EVENT_POINTER_PRESSED returns the data of the pressed pointer, etc.

Multiple-pointer event's button number is mapped to the first pointer ID triggering the event and the button mask bits in the modifiers field represent the pressed pointer IDs.

Users can query the pressed button and pointer count via InputEvent#getButtonDownCount() or use the simple query InputEvent#isAnyButtonDown().

If representing a single-pointer PointerType#Mouse event, pointer-ID is 0 and a button value of 0 denotes no button activity, i.e. PointerType#Mouse move.

Examples
GearsES2.cpp, and GearsES2.hpp.

Definition at line 108 of file PointerEvent.hpp.

Constructor & Destructor Documentation

◆ PointerEvent() [1/2]

gamp::wt::event::PointerEvent::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 )
inline

Constructor for traditional one-pointer event.

Parameters
eventType
source
when
modifiers
posXY-axis
clickCountMouse-button click-count
buttonbutton number, e.g. [BUTTON1..BUTTON_COUNT-1]. A button value of 0 denotes no button activity, i.e. PointerType#Mouse move.
rotationRotation of all axis
rotationScaleRotation scale

Definition at line 137 of file PointerEvent.hpp.

Here is the caller graph for this function:

◆ PointerEvent() [2/2]

gamp::wt::event::PointerEvent::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 )
inline

Constructor for a multiple-pointer event.

First element of multiple-pointer arrays represents the pointer which triggered the event!

See details for multiple-pointer events.

Parameters
eventType
source
when
modifiers
pointerTypePointerType for each pointer (multiple pointer)
pointerIDPointer ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers. A pointer-ID of -1 may also denote no pointer/button activity, i.e. PointerType#Mouse move.
posXY-axis for each pointer (multiple pointer)
pressurePressure for each pointer (multiple pointer)
maxPressureMaximum pointer pressure for all pointer
buttonCorresponding mouse-button
clickCountMouse-button click-count
rotationRotation of all axis
rotationScaleRotation scale

Definition at line 183 of file PointerEvent.hpp.

Member Function Documentation

◆ swapRotation()

static jau::math::Vec3f gamp::wt::event::PointerEvent::swapRotation ( float rotationXorY,
InputModifier mods )
inlinestatic

Returns the 3-axis XYZ rotation array by given rotation on Y axis or X axis (if InputModifier::shift is given in mods).

Definition at line 111 of file PointerEvent.hpp.

◆ clickTimeout()

static constexpr uint16_t gamp::wt::event::PointerEvent::clickTimeout ( )
inlinestaticconstexpr

Definition at line 121 of file PointerEvent.hpp.

◆ createVariant()

PointerEvent gamp::wt::event::PointerEvent::createVariant ( uint16_t newEventType)
inline

Definition at line 209 of file PointerEvent.hpp.

◆ pointerCount()

size_t gamp::wt::event::PointerEvent::pointerCount ( ) const
inlineconstexprnoexcept

See details for multiple-pointer events.

Returns
the count of pointers involved in this event
Examples
GearsES2.cpp.

Definition at line 219 of file PointerEvent.hpp.

Here is the caller graph for this function:

◆ pointerType()

PointerType gamp::wt::event::PointerEvent::pointerType ( size_t index) const
inlineconstexprnoexcept

See details for multiple-pointer events.

Returns
the PointerType for the data at index or null if index not available.

Definition at line 225 of file PointerEvent.hpp.

Here is the caller graph for this function:

◆ allPointerTypes()

const std::vector< PointerType > & gamp::wt::event::PointerEvent::allPointerTypes ( ) const
inlineconstexprnoexcept

See details for multiple-pointer events.

Returns
array of all PointerTypes for all pointers

Definition at line 236 of file PointerEvent.hpp.

Here is the caller graph for this function:

◆ pointerId()

int gamp::wt::event::PointerEvent::pointerId ( size_t index = 0) const
inlineconstexprnoexcept

Return the pointer id for the given index or -1 if index not available.

IDs start w/ 0 and are consecutive numbers.

See details for multiple-pointer events.

Definition at line 247 of file PointerEvent.hpp.

◆ pointerIdx()

int gamp::wt::event::PointerEvent::pointerIdx ( uint16_t id) const
inline

See details for multiple-pointer events.

Returns
the pointer index for the given pointer id or -1 if id not available.

Definition at line 258 of file PointerEvent.hpp.

◆ allPointerIDs()

const std::vector< uint16_t > & gamp::wt::event::PointerEvent::allPointerIDs ( ) const
inlineconstexprnoexcept

See details for multiple-pointer events.

Returns
array of all pointer IDs for all pointers. IDs start w/ 0 and are consecutive numbers.

Definition at line 271 of file PointerEvent.hpp.

Here is the caller graph for this function:

◆ button()

InputButton gamp::wt::event::PointerEvent::button ( ) const
inlineconstexprnoexcept

Returns the button number, e.g.

[BUTTON1..BUTTON_COUNT-1].

A button value of 0 denotes no button activity, i.e. PointerType#Mouse move.

See details for multiple-pointer events.

Definition at line 282 of file PointerEvent.hpp.

Here is the caller graph for this function:

◆ clickCount()

uint16_t gamp::wt::event::PointerEvent::clickCount ( ) const
inlineconstexprnoexcept

Definition at line 284 of file PointerEvent.hpp.

Here is the caller graph for this function:

◆ position()

const jau::math::Vec2i & gamp::wt::event::PointerEvent::position ( size_t index = 0) const
inlineconstexprnoexcept

Returns position of given pointer-index in pixel units.

Orientation depends on Window::isPointerBLOriented().

See details for multiple-pointer events.

Parameters
indexpointer-index within [0 .. getPointerCount()-1]
Returns
XYZ-Coord associated with the pointer-index in pixel units.
See also
getPointerId(index)
Examples
GearsES2.cpp.

Definition at line 294 of file PointerEvent.hpp.

◆ allPositions()

const std::vector< jau::math::Vec2i > & gamp::wt::event::PointerEvent::allPositions ( ) const
inlineconstexprnoexcept

Returns position of all pointers in pixel units.

Orientation depends on Window::isPointerBLOriented().

See details for multiple-pointer events.

Returns
array of all coordinates for all pointers in pixel units.

Definition at line 302 of file PointerEvent.hpp.

◆ pressure() [1/2]

float gamp::wt::event::PointerEvent::pressure ( bool normalized) const
inlineconstexprnoexcept
Parameters
normalizedif true, method returns the normalized pressure, i.e. pressure / maxPressure
Returns
The pressure associated with the pointer-index 0. The value of zero is return if not available.
See also
#getMaxPressure()

Definition at line 310 of file PointerEvent.hpp.

Here is the caller graph for this function:

◆ pressure() [2/2]

float gamp::wt::event::PointerEvent::pressure ( size_t index,
bool normalized ) const
inlineconstexprnoexcept

See details for multiple-pointer events.

Parameters
indexpointer-index within [0 .. getPointerCount()-1]
normalizedif true, method returns the normalized pressure, i.e. pressure / maxPressure
Returns
The pressure associated with the pointer-index. The value of zero is return if not available.
See also
#getMaxPressure()

Definition at line 320 of file PointerEvent.hpp.

◆ allPressures()

const std::vector< float > & gamp::wt::event::PointerEvent::allPressures ( ) const
inlineconstexprnoexcept

See details for multiple-pointer events.

Returns
array of all raw, un-normalized pressures for all pointers

Definition at line 328 of file PointerEvent.hpp.

◆ maxPressure()

float gamp::wt::event::PointerEvent::maxPressure ( ) const
inlineconstexprnoexcept

Returns the maximum pressure known for the input device generating this event.

This value may be self calibrating on devices/OS, where no known maximum pressure is known. Hence subsequent events may return a higher value.

Self calibrating maximum pressure is performed on:

  • Android

Definition at line 343 of file PointerEvent.hpp.

Here is the caller graph for this function:

◆ rotation()

const jau::math::Vec3f & gamp::wt::event::PointerEvent::rotation ( ) const
inlineconstexprnoexcept

Returns a 3-component float array filled with the values of the rotational axis in the following order: horizontal-, vertical- and z-axis.

A vertical rotation of > 0.0f is up and < 0.0f is down.

A horizontal rotation of > 0.0f is left and < 0.0f is right.

A z-axis rotation of > 0.0f is back and < 0.0f is front.

However, on some OS this might be flipped due to the OS default behavior. The latter is true for OS X 10.7 (Lion) for example.

On PointerClass onscreen devices, i.e. touch screens, rotation events are usually produced by a 2-finger movement, where horizontal and vertical rotation values are filled.

On PointerClass offscreen devices, i.e. mouse, either the horizontal or the vertical rotation value is filled.

The InputEvent#SHIFT_MASK modifier is set in case |horizontal| > |vertical| value.
This can be utilized to implement only one 2d rotation direction, you may use isShiftDown() to query it.

In case the pointer type is mouse, events are usually send in steps of one, ie. -1.0f and 1.0f. Higher values may result due to fast scrolling. Fractional values may result due to slow scrolling with high resolution devices.
Here the button number refers to the wheel number.

In case the pointer type is of class PointerClass#Onscreen, e.g. touch screen, see getRotationScale() for semantics.

Examples
GearsES2.cpp.

Definition at line 385 of file PointerEvent.hpp.

Here is the caller graph for this function:

◆ rotationScale()

float gamp::wt::event::PointerEvent::rotationScale ( ) const
inlineconstexprnoexcept

Returns the scale used to determine the rotation value, which semantics depends on the pointer type's PointerClass.

For PointerClass#Offscreen, the scale is usually 1.0f and denominates an abstract value without association to a physical value.

For PointerClass#Onscreen, the scale varies and denominates the divisor of the distance the finger[s] have moved on the screen. Hence scale * rotation reproduces the screen distance in pixels the finger[s] have moved.

Definition at line 400 of file PointerEvent.hpp.

Here is the caller graph for this function:

◆ toString()

std::string gamp::wt::event::PointerEvent::toString ( ) const
inlinenoexcept

Definition at line 402 of file PointerEvent.hpp.

Here is the caller graph for this function:

The documentation for this class was generated from the following file: