kodi
GenericTouchActionHandler.h
1 /*
2  * Copyright (C) 2013-2024 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "input/touch/ITouchActionHandler.h"
12 
21 {
22 public:
27 
28  // implementation of ITouchActionHandler
29  void OnTouchAbort() override;
30 
31  bool OnSingleTouchStart(float x, float y) override;
32  bool OnSingleTouchHold(float x, float y) override;
33  bool OnSingleTouchMove(
34  float x, float y, float offsetX, float offsetY, float velocityX, float velocityY) override;
35  bool OnSingleTouchEnd(float x, float y) override;
36 
37  bool OnMultiTouchDown(float x, float y, int32_t pointer) override;
38  bool OnMultiTouchHold(float x, float y, int32_t pointers = 2) override;
39  bool OnMultiTouchMove(float x,
40  float y,
41  float offsetX,
42  float offsetY,
43  float velocityX,
44  float velocityY,
45  int32_t pointer) override;
46  bool OnMultiTouchUp(float x, float y, int32_t pointer) override;
47 
48  bool OnTouchGestureStart(float x, float y) override;
49  bool OnTouchGesturePan(
50  float x, float y, float offsetX, float offsetY, float velocityX, float velocityY) override;
51  bool OnTouchGestureEnd(
52  float x, float y, float offsetX, float offsetY, float velocityX, float velocityY) override;
53 
54  // convenience events
55  void OnTap(float x, float y, int32_t pointers = 1) override;
56  void OnLongPress(float x, float y, int32_t pointers = 1) override;
57  void OnSwipe(TouchMoveDirection direction,
58  float xDown,
59  float yDown,
60  float xUp,
61  float yUp,
62  float velocityX,
63  float velocityY,
64  int32_t pointers = 1) override;
65  void OnZoomPinch(float centerX, float centerY, float zoomFactor) override;
66  void OnRotate(float centerX, float centerY, float angle) override;
67 
76  int QuerySupportedGestures(float x, float y);
77 
78 private:
79  // private construction, and no assignments; use the provided singleton methods
80  CGenericTouchActionHandler() = default;
82  CGenericTouchActionHandler const& operator=(CGenericTouchActionHandler const&) = delete;
83  ~CGenericTouchActionHandler() override = default;
84 
85  void sendEvent(int actionId,
86  float x,
87  float y,
88  float x2 = 0.0f,
89  float y2 = 0.0f,
90  float x3 = 0.0f,
91  float y3 = 0.0f,
92  int pointers = 1);
93  void focusControl(float x, float y);
94 };
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.
Definition: GenericTouchActionHandler.cpp:88
void OnTap(float x, float y, int32_t pointers=1) override
A tap with a one or more touches has been performed.
Definition: GenericTouchActionHandler.cpp:104
void OnZoomPinch(float centerX, float centerY, float zoomFactor) override
Two simultaneous touches have been held down and moved to perform a zooming/pinching gesture...
Definition: GenericTouchActionHandler.cpp:147
void OnTouchAbort() override
A touch action has been aborted.
Definition: GenericTouchActionHandler.cpp:27
Generic implementation of ITouchActionHandler to translate touch actions into XBMC specific and mappa...
Definition: GenericTouchActionHandler.h:20
static CGenericTouchActionHandler & GetInstance()
Get an instance of the touch input manager.
Definition: GenericTouchActionHandler.cpp:21
bool OnSingleTouchStart(float x, float y) override
A single touch has started.
Definition: GenericTouchActionHandler.cpp:32
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. ...
Definition: GenericTouchActionHandler.cpp:120
int QuerySupportedGestures(float x, float y)
Asks the control at the given coordinates for a list of the supported gestures.
Definition: GenericTouchActionHandler.cpp:157
bool OnMultiTouchUp(float x, float y, int32_t pointer) override
A touch has been lifted (but there are still active touches)
Definition: GenericTouchActionHandler.cpp:76
bool OnMultiTouchDown(float x, float y, int32_t pointer) override
An additional touch has been performed.
Definition: GenericTouchActionHandler.cpp:55
bool OnMultiTouchMove(float x, float y, float offsetX, float offsetY, float velocityX, float velocityY, int32_t pointer) override
A touch has moved.
Definition: GenericTouchActionHandler.cpp:65
bool OnSingleTouchEnd(float x, float y) override
A single touch has been lifted.
Definition: GenericTouchActionHandler.cpp:50
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.
Definition: GenericTouchActionHandler.cpp:112
bool OnSingleTouchHold(float x, float y) override
A single touch has been held down for a certain amount of time.
Definition: GenericTouchActionHandler.cpp:39
bool OnTouchGestureStart(float x, float y) override
A pan gesture with a single touch has been started.
Definition: GenericTouchActionHandler.cpp:81
bool OnSingleTouchMove(float x, float y, float offsetX, float offsetY, float velocityX, float velocityY) override
A single touch has moved.
Definition: GenericTouchActionHandler.cpp:44
Interface defining all supported touch action events.
Definition: ITouchActionHandler.h:32
TouchMoveDirection
Directions in which a touch can moved.
Definition: ITouchActionHandler.h:19
void OnRotate(float centerX, float centerY, float angle) override
Two simultaneous touches have been held down and moved to perform a rotating gesture.
Definition: GenericTouchActionHandler.cpp:152
bool OnTouchGestureEnd(float x, float y, float offsetX, float offsetY, float velocityX, float velocityY) override
A pan gesture with a single touch has ended.
Definition: GenericTouchActionHandler.cpp:96
bool OnMultiTouchHold(float x, float y, int32_t pointers=2) override
Multiple simultaneous touches have been held down for a certain amount of time.
Definition: GenericTouchActionHandler.cpp:60