Debian Codegraph @

xbmc/peripherals/devices/PeripheralKeyboard.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/keyboard/interfaces/IKeyboardDriverHandler.h"
14 #include "threads/CriticalSection.h"
15
16 #include <vector>
17
18 namespace PERIPHERALS
19 {
20 /*!
21 * \ingroup peripherals
22 */
23 class CPeripheralKeyboard : public CPeripheral, public KODI::KEYBOARD::IKeyboardDriverHandler
24 {
25 public:
26 CPeripheralKeyboard(CPeripherals& manager,
27 const PeripheralScanResult& scanResult,
28 CPeripheralBus* bus);
29
30 ~CPeripheralKeyboard(void) override;
31
32 // implementation of CPeripheral
33 bool InitialiseFeature(const PeripheralFeature feature) override;
34 void RegisterKeyboardDriverHandler(KODI::KEYBOARD::IKeyboardDriverHandler* handler,
35 bool bPromiscuous) override;
36 void UnregisterKeyboardDriverHandler(KODI::KEYBOARD::IKeyboardDriverHandler* 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 IKeyboardDriverHandler
42 bool OnKeyPress(const CKey& key) override;
43 void OnKeyRelease(const CKey& key) override;
44
45 private:
46 struct KeyboardHandle
47 {
48 KODI::KEYBOARD::IKeyboardDriverHandler* handler;
49 bool bPromiscuous;
50 };
51
52 std::vector<KeyboardHandle> m_keyboardHandlers;
53 CCriticalSection m_mutex;
54 CDateTime m_lastActive;
55 };
56 } // namespace PERIPHERALS