| 1 |
/* |
| 2 |
* Copyright (C) 2016-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/mouse/MouseTypes.h" |
| 12 |
#include "input/mouse/interfaces/IMouseDriverHandler.h" |
| 13 |
|
| 14 |
namespace KODI |
| 15 |
{ |
| 16 |
namespace JOYSTICK |
| 17 |
{ |
| 18 |
class IButtonMap; |
| 19 |
} |
| 20 |
|
| 21 |
namespace MOUSE |
| 22 |
{ |
| 23 |
class IMouseInputHandler; |
| 24 |
|
| 25 |
/*! |
| 26 |
* \ingroup mouse |
| 27 |
* |
| 28 |
* \brief Class to translate input from driver info to higher-level features |
| 29 |
*/ |
| 30 |
class CMouseInputHandling : public IMouseDriverHandler |
| 31 |
{ |
| 32 |
public: |
| 33 |
CMouseInputHandling(IMouseInputHandler* handler, JOYSTICK::IButtonMap* buttonMap); |
| 34 |
|
| 35 |
~CMouseInputHandling(void) override = default; |
| 36 |
|
| 37 |
// implementation of IMouseDriverHandler |
| 38 |
bool OnPosition(int x, int y) override; |
| 39 |
bool OnButtonPress(BUTTON_ID button) override; |
| 40 |
void OnButtonRelease(BUTTON_ID button) override; |
| 41 |
|
| 42 |
private: |
| 43 |
// Utility functions |
| 44 |
static POINTER_DIRECTION GetPointerDirection(int x, int y); |
| 45 |
static POINTER_DIRECTION GetOrthogonalDirectionCCW(POINTER_DIRECTION direction); |
| 46 |
|
| 47 |
static void GetRotation(POINTER_DIRECTION source, |
| 48 |
POINTER_DIRECTION target, |
| 49 |
int (&rotation)[2][2]); |
| 50 |
static void GetRotation(int deg, int (&rotation)[2][2]); |
| 51 |
|
| 52 |
static void GetReflectionCCW(POINTER_DIRECTION source, |
| 53 |
POINTER_DIRECTION target, |
| 54 |
int (&reflection)[2][2]); |
| 55 |
static void GetReflection(int deg, int (&reflection)[2][2]); |
| 56 |
|
| 57 |
// Construction parameters |
| 58 |
IMouseInputHandler* const m_handler; |
| 59 |
JOYSTICK::IButtonMap* const m_buttonMap; |
| 60 |
|
| 61 |
// Mouse parameters |
| 62 |
bool m_bHasPosition = false; |
| 63 |
int m_x = 0; |
| 64 |
int m_y = 0; |
| 65 |
}; |
| 66 |
} // namespace MOUSE |
| 67 |
} // namespace KODI |