Debian Codegraph @

xbmc/games/agents/input/AgentMouse.h

raw
1 /*
2 * Copyright (C) 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 "games/controllers/ControllerTypes.h"
12 #include "input/mouse/interfaces/IMouseInputHandler.h"
13 #include "peripherals/PeripheralTypes.h"
14
15 namespace KODI
16 {
17 namespace GAME
18 {
19 class CControllerActivity;
20
21 /*!
22 * \ingroup games
23 *
24 * \brief Handles mouse events for game agent functionality
25 */
26 class CAgentMouse : public MOUSE::IMouseInputHandler
27 {
28 public:
29 CAgentMouse(PERIPHERALS::PeripheralPtr peripheral);
30
31 ~CAgentMouse() override;
32
33 void Initialize();
34 void Deinitialize();
35 void ClearButtonState();
36
37 // Input parameters
38 float GetActivation() const;
39 ControllerPtr Appearance() const { return m_controllerAppearance; }
40
41 // Implementation of IMouseInputHandler
42 std::string ControllerID() const override;
43 bool OnMotion(const MOUSE::PointerName& relpointer, int differenceX, int differenceY) override;
44 bool OnButtonPress(const MOUSE::ButtonName& button) override;
45 void OnButtonRelease(const MOUSE::ButtonName& button) override;
46 void OnInputFrame() override;
47
48 private:
49 static INPUT::INTERCARDINAL_DIRECTION GetPointerDirection(int differenceX, int differenceY);
50
51 // Construction parameters
52 const PERIPHERALS::PeripheralPtr m_peripheral;
53
54 // Input properties
55 std::unique_ptr<CControllerActivity> m_mouseActivity;
56 ControllerPtr m_controllerAppearance;
57
58 // Input state
59 bool m_bStarted{false};
60 int m_startX{0};
61 int m_startY{0};
62 int m_frameCount{0};
63 };
64 } // namespace GAME
65 } // namespace KODI