Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
CGenericTouchInputHandler Class Reference

Generic implementation of ITouchInputHandler to handle low level (raw) touch events and translate them into touch actions which are passed on to the registered ITouchActionHandler implementation. More...

#include <GenericTouchInputHandler.h>

Inheritance diagram for CGenericTouchInputHandler:
ITouchInputHandler ITimerCallback ITouchInputHandling ITouchActionHandler

Public Member Functions

bool HandleTouchInput (TouchInput event, float x, float y, int64_t time, int32_t pointer=0, float size=0.0f) override
 Handle a touch event.
 
bool UpdateTouchPointer (int32_t pointer, float x, float y, int64_t time, float size=0.0f) override
 Update the coordinates of a pointer.
 
- Public Member Functions inherited from ITouchInputHandler
 ITouchInputHandler ()
 
 ~ITouchInputHandler () override=default
 
void SetScreenDPI (float dpi)
 
float GetScreenDPI ()
 
- Public Member Functions inherited from ITouchInputHandling
 ITouchInputHandling ()
 
 ~ITouchInputHandling () override=default
 
void RegisterHandler (ITouchActionHandler *touchHandler)
 Register a touch input handler.
 
void UnregisterHandler ()
 Unregister the previously registered touch handler.
 

Static Public Member Functions

static CGenericTouchInputHandlerGetInstance ()
 Get an instance of the touch input manager.
 

Static Public Attributes

static constexpr int MAX_POINTERS = 2
 

Additional Inherited Members

- Protected Member Functions inherited from ITouchInputHandling
void OnTouchAbort () override
 A touch action has been aborted.
 
bool OnSingleTouchStart (float x, float y) override
 A single touch has started.
 
bool OnSingleTouchHold (float x, float y) override
 A single touch has been held down for a certain amount of time.
 
bool OnSingleTouchMove (float x, float y, float offsetX, float offsetY, float velocityX, float velocityY) override
 A single touch has moved.
 
bool OnSingleTouchEnd (float x, float y) override
 A single touch has been lifted.
 
bool OnMultiTouchDown (float x, float y, int32_t pointer) override
 An additional touch has been performed.
 
bool OnMultiTouchHold (float x, float y, int32_t pointers=2) override
 Multiple simultaneous touches have been held down for a certain amount of time.
 
bool OnMultiTouchMove (float x, float y, float offsetX, float offsetY, float velocityX, float velocityY, int32_t pointer) override
 A touch has moved.
 
bool OnMultiTouchUp (float x, float y, int32_t pointer) override
 A touch has been lifted (but there are still active touches)
 
bool OnTouchGestureStart (float x, float y) override
 A pan gesture with a single touch has been started.
 
bool OnTouchGesturePan (float x, float y, float offsetX, float offsetY, float velocityX, float velocityY) override
 A pan gesture with a single touch is in progress.
 
bool OnTouchGestureEnd (float x, float y, float offsetX, float offsetY, float velocityX, float velocityY) override
 A pan gesture with a single touch has ended.
 
void OnTap (float x, float y, int32_t pointers=1) override
 A tap with a one or more touches has been performed.
 
void OnLongPress (float x, float y, int32_t pointers=1) override
 One or more touches have been held down for a certain amount of time.
 
void OnSwipe (TouchMoveDirection direction, float xDown, float yDown, float xUp, float yUp, float velocityX, float velocityY, int32_t pointers=1) override
 One or more touches has been moved quickly in a single direction in a short time.
 
void OnZoomPinch (float centerX, float centerY, float zoomFactor) override
 Two simultaneous touches have been held down and moved to perform a zooming/pinching gesture.
 
void OnRotate (float centerX, float centerY, float angle) override
 Two simultaneous touches have been held down and moved to perform a rotating gesture.
 
- Protected Member Functions inherited from ITouchActionHandler
virtual ~ITouchActionHandler ()=default
 
- Protected Attributes inherited from ITouchInputHandler
std::atomic< float > m_dpi
 DPI value of the touch screen.
 

Detailed Description

Generic implementation of ITouchInputHandler to handle low level (raw) touch events and translate them into touch actions which are passed on to the registered ITouchActionHandler implementation.

The generic implementation supports single a double touch and hold actions and basic gesture recognition for panning, swiping, pinching/zooming and rotating.

See also
ITouchInputHandler

Member Function Documentation

◆ GetInstance()

CGenericTouchInputHandler & CGenericTouchInputHandler::GetInstance ( )
static

Get an instance of the touch input manager.

◆ HandleTouchInput()

bool CGenericTouchInputHandler::HandleTouchInput ( TouchInput event,
float x,
float y,
int64_t time,
int32_t pointer = 0,
float size = 0.0f )
overridevirtual

Handle a touch event.

Handles the given touch event at the given location. This takes into account all the currently active pointers which need to be updated before calling this method to actually interpret and handle the changes in touch.

Parameters
eventThe actual touch event (abort, down, up, move)
xThe x coordinate (with sub-pixel) of the touch
yThe y coordinate (with sub-pixel) of the touch
timeThe time (in nanoseconds) when this touch occurred
pointerThe number of the touch pointer which caused this event (default 0)
sizeThe size of the touch pointer (with sub-pixel) (default 0.0)
Returns
True if the event was handled otherwise false.
See also
Update

Implements ITouchInputHandler.

◆ UpdateTouchPointer()

bool CGenericTouchInputHandler::UpdateTouchPointer ( int32_t pointer,
float x,
float y,
int64_t time,
float size = 0.0f )
overridevirtual

Update the coordinates of a pointer.

Depending on how a platform handles touch input and provides the necessary events this method needs to be called at different times. If there's an event for every touch action this method does not need to be called at all. If there's only a touch event for the primary pointer (and no special events for any secondary pointers in a multi touch gesture) this method should be called for every active secondary pointer before calling Handle.

Parameters
pointerThe number of the touch pointer which caused this event (default 0)
xThe x coordinate (with sub-pixel) of the touch
yThe y coordinate (with sub-pixel) of the touch
timeThe time (in nanoseconds) when this touch occurred
sizeThe size of the touch pointer (with sub-pixel) (default 0.0)
Returns
True if the pointer was updated otherwise false.
See also
Handle

Reimplemented from ITouchInputHandler.

Member Data Documentation

◆ MAX_POINTERS

int CGenericTouchInputHandler::MAX_POINTERS = 2
staticconstexpr

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