kodi
MouseInputHandling.h
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 
31 {
32 public:
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
BUTTON_ID
Buttons on a mouse.
Definition: MouseTypes.h:26
Button map interface to translate between the driver's raw button/hat/axis elements and physical joys...
Definition: IButtonMap.h:29
Class to translate input from driver info to higher-level features.
Definition: MouseInputHandling.h:30
Definition: AudioDecoder.h:18
Interface for handling mouse events.
Definition: IMouseInputHandler.h:24
Interface for handling mouse driver events.
Definition: IMouseDriverHandler.h:22