| 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/ITouchInputHandling.h" |
| 12 |
#include "input/touch/TouchTypes.h" |
| 13 |
|
| 14 |
#include <array> |
| 15 |
|
| 16 |
/*! |
| 17 |
* \ingroup touch_generic |
| 18 |
* \brief Interface defining methods to perform gesture recognition |
| 19 |
*/ |
| 20 |
class IGenericTouchGestureDetector : public ITouchInputHandling |
| 21 |
{ |
| 22 |
public: |
| 23 |
IGenericTouchGestureDetector(ITouchActionHandler* handler, float dpi) : m_dpi(dpi) |
| 24 |
{ |
| 25 |
RegisterHandler(handler); |
| 26 |
} |
| 27 |
~IGenericTouchGestureDetector() override = default; |
| 28 |
static constexpr int MAX_POINTERS = 2; |
| 29 |
|
| 30 |
/*! |
| 31 |
* \brief Check whether the gesture recognition is finished or not |
| 32 |
* |
| 33 |
* \return True if the gesture recognition is finished otherwise false |
| 34 |
*/ |
| 35 |
bool IsDone() { return m_done; } |
| 36 |
|
| 37 |
/*! |
| 38 |
* \brief A new touch pointer has been recognised. |
| 39 |
* |
| 40 |
* \param index Index of the given touch pointer |
| 41 |
* \param pointer Touch pointer that has changed |
| 42 |
* |
| 43 |
* \return True if the event was handled otherwise false |
| 44 |
*/ |
| 45 |
virtual bool OnTouchDown(unsigned int index, const Pointer& pointer) = 0; |
| 46 |
/*! |
| 47 |
* \brief An active touch pointer has vanished. |
| 48 |
* |
| 49 |
* If the first touch pointer is lifted and there are more active touch |
| 50 |
* pointers, the remaining pointers change their index. |
| 51 |
* |
| 52 |
* \param index Index of the given touch pointer |
| 53 |
* \param pointer Touch pointer that has changed |
| 54 |
* |
| 55 |
* \return True if the event was handled otherwise false |
| 56 |
*/ |
| 57 |
virtual bool OnTouchUp(unsigned int index, const Pointer& pointer) { return false; } |
| 58 |
/*! |
| 59 |
* \brief An active touch pointer has moved. |
| 60 |
* |
| 61 |
* \param index Index of the given touch pointer |
| 62 |
* \param pointer Touch pointer that has changed |
| 63 |
* |
| 64 |
* \return True if the event was handled otherwise false |
| 65 |
*/ |
| 66 |
virtual bool OnTouchMove(unsigned int index, const Pointer& pointer) { return false; } |
| 67 |
/*! |
| 68 |
* \brief An active touch pointer's values have been updated but no event has |
| 69 |
* occurred. |
| 70 |
* |
| 71 |
* \param index Index of the given touch pointer |
| 72 |
* \param pointer Touch pointer that has changed |
| 73 |
* |
| 74 |
* \return True if the event was handled otherwise false |
| 75 |
*/ |
| 76 |
virtual bool OnTouchUpdate(unsigned int index, const Pointer& pointer) { return false; } |
| 77 |
|
| 78 |
protected: |
| 79 |
/*! |
| 80 |
* \brief Whether the gesture recognition is finished or not |
| 81 |
*/ |
| 82 |
bool m_done = false; |
| 83 |
/*! |
| 84 |
* \brief DPI value of the touch screen |
| 85 |
*/ |
| 86 |
float m_dpi; |
| 87 |
/*! |
| 88 |
* \brief Local list of all known touch pointers |
| 89 |
*/ |
| 90 |
std::array<Pointer, MAX_POINTERS> m_pointers; |
| 91 |
}; |