| 1 |
/* |
| 2 |
* Copyright (C) 2018-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 "InputTypes.h" |
| 12 |
|
| 13 |
namespace KODI |
| 14 |
{ |
| 15 |
namespace INPUT |
| 16 |
{ |
| 17 |
class CInputTranslator |
| 18 |
{ |
| 19 |
public: |
| 20 |
/*! |
| 21 |
* \brief Get the closest cardinal direction to the given vector |
| 22 |
* |
| 23 |
* This function assumes a right-handed cartesian coordinate system; positive |
| 24 |
* X is right, positive Y is up. |
| 25 |
* |
| 26 |
* Ties are resolved in the clockwise direction: (0.5, 0.5) will resolve to |
| 27 |
* RIGHT. |
| 28 |
* |
| 29 |
* \param x The x component of the vector |
| 30 |
* \param y The y component of the vector |
| 31 |
* |
| 32 |
* \return The closest cardinal direction (up, down, right or left), or |
| 33 |
* CARDINAL_DIRECTION::NONE if x and y are both 0 |
| 34 |
*/ |
| 35 |
static CARDINAL_DIRECTION VectorToCardinalDirection(float x, float y); |
| 36 |
|
| 37 |
/*! |
| 38 |
* \brief Get the closest cardinal or intercardinal direction to the given |
| 39 |
* vector |
| 40 |
* |
| 41 |
* This function assumes a right-handed cartesian coordinate system; positive |
| 42 |
* X is right, positive Y is up. |
| 43 |
* |
| 44 |
* Ties are resolved in the clockwise direction. |
| 45 |
* |
| 46 |
* \param x The x component of the vector |
| 47 |
* \param y The y component of the vector |
| 48 |
* |
| 49 |
* \return The closest intercardinal direction, or |
| 50 |
* INTERCARDINAL_DIRECTION::NONE if x and y are both 0 |
| 51 |
*/ |
| 52 |
static INTERCARDINAL_DIRECTION VectorToIntercardinalDirection(float x, float y); |
| 53 |
}; |
| 54 |
} // namespace INPUT |
| 55 |
} // namespace KODI |