Debian Codegraph @

xbmc/peripherals/devices/PeripheralMouse.h

raw
1 /*
2 * Copyright (C) 2017-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 "Peripheral.h"
12 #include "XBDateTime.h"
13 #include "input/mouse/interfaces/IMouseDriverHandler.h"
14 #include "threads/CriticalSection.h"
15
16 #include <vector>
17
18 namespace PERIPHERALS
19 {
20 /*!
21 * \ingroup peripherals
22 */
23 class CPeripheralMouse : public CPeripheral, public KODI::MOUSE::IMouseDriverHandler
24 {
25 public:
26 CPeripheralMouse(CPeripherals& manager,
27 const PeripheralScanResult& scanResult,
28 CPeripheralBus* bus);
29
30 ~CPeripheralMouse(void) override;
31
32 // implementation of CPeripheral
33 bool InitialiseFeature(const PeripheralFeature feature) override;
34 void RegisterMouseDriverHandler(KODI::MOUSE::IMouseDriverHandler* handler,
35 bool bPromiscuous) override;
36 void UnregisterMouseDriverHandler(KODI::MOUSE::IMouseDriverHandler* handler) override;
37 CDateTime LastActive() const override { return m_lastActive; }
38 void SetLastActive(const CDateTime& lastActive) override;
39 KODI::GAME::ControllerPtr ControllerProfile() const override;
40
41 // implementation of IMouseDriverHandler
42 bool OnPosition(int x, int y) override;
43 bool OnButtonPress(KODI::MOUSE::BUTTON_ID button) override;
44 void OnButtonRelease(KODI::MOUSE::BUTTON_ID button) override;
45
46 private:
47 struct MouseHandle
48 {
49 KODI::MOUSE::IMouseDriverHandler* handler;
50 bool bPromiscuous;
51 };
52
53 std::vector<MouseHandle> m_mouseHandlers;
54 CCriticalSection m_mutex;
55 CDateTime m_lastActive;
56 };
57 } // namespace PERIPHERALS