Debian Codegraph @

xbmc/games/addons/input/GameClientMouse.h

raw
1 /*
2 * Copyright (C) 2015-2018 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/interfaces/IMouseInputHandler.h"
12 #include "peripherals/PeripheralTypes.h"
13
14 namespace KODI
15 {
16 namespace MOUSE
17 {
18 class IMouseInputProvider;
19 }
20
21 namespace GAME
22 {
23 class CControllerActivity;
24 class CGameClient;
25
26 /*!
27 * \ingroup games
28 *
29 * \brief Handles mouse events for games.
30 *
31 * Listens to mouse events and forwards them to the games (as game_input_event).
32 */
33 class CGameClientMouse : public MOUSE::IMouseInputHandler
34 {
35 public:
36 /*!
37 * \brief Constructor registers for mouse events at CInputManager.
38 * \param gameClient The game client implementation.
39 * \param controllerId The controller profile used for input
40 * \param dllStruct The emulator or game to which the events are sent.
41 * \param inputProvider The interface providing us with mouse input.
42 */
43 CGameClientMouse(CGameClient& gameClient,
44 std::string controllerId,
45 MOUSE::IMouseInputProvider* inputProvider);
46
47 /*!
48 * \brief Destructor unregisters from mouse events from CInputManager.
49 */
50 ~CGameClientMouse() override;
51
52 // implementation of IMouseInputHandler
53 std::string ControllerID() const override;
54 bool OnMotion(const std::string& relpointer, int dx, int dy) override;
55 bool OnButtonPress(const std::string& button) override;
56 void OnButtonRelease(const std::string& button) override;
57 void OnInputFrame() override;
58
59 // Input accessors
60 const std::string& GetControllerID() const { return m_controllerId; }
61 const PERIPHERALS::PeripheralPtr& GetSource() const { return m_sourcePeripheral; }
62 float GetActivation() const;
63
64 // Input mutators
65 void SetSource(PERIPHERALS::PeripheralPtr sourcePeripheral);
66 void ClearSource();
67
68 private:
69 // Construction parameters
70 CGameClient& m_gameClient;
71 const std::string m_controllerId;
72 MOUSE::IMouseInputProvider* const m_inputProvider;
73
74 // Input parameters
75 PERIPHERALS::PeripheralPtr m_sourcePeripheral;
76 std::unique_ptr<CControllerActivity> m_mouseActivity;
77 };
78 } // namespace GAME
79 } // namespace KODI