kodi
GameClientKeyboard.h
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/keyboard/interfaces/IKeyboardInputHandler.h"
12 #include "peripherals/PeripheralTypes.h"
13 
14 namespace KODI
15 {
16 namespace KEYBOARD
17 {
18 class IKeyboardInputProvider;
19 }
20 
21 namespace GAME
22 {
23 class CControllerActivity;
24 class CGameClient;
25 
34 {
35 public:
43  CGameClientKeyboard(CGameClient& gameClient,
44  std::string controllerId,
45  KEYBOARD::IKeyboardInputProvider* inputProvider);
46 
50  ~CGameClientKeyboard() override;
51 
52  // implementation of IKeyboardInputHandler
53  std::string ControllerID() const override;
54  bool HasKey(const KEYBOARD::KeyName& key) const override;
55  bool OnKeyPress(const KEYBOARD::KeyName& key, KEYBOARD::Modifier mod, uint32_t unicode) override;
56  void OnKeyRelease(const KEYBOARD::KeyName& key,
57  KEYBOARD::Modifier mod,
58  uint32_t unicode) override;
59 
60  // Input accessors
61  const std::string& GetControllerID() const { return m_controllerId; }
62  const PERIPHERALS::PeripheralPtr& GetSource() const { return m_sourcePeripheral; }
63  float GetActivation() const;
64 
65  // Input mutators
66  void SetSource(PERIPHERALS::PeripheralPtr sourcePeripheral);
67  void ClearSource();
68 
69 private:
70  // Construction parameters
71  CGameClient& m_gameClient;
72  const std::string m_controllerId;
73  KEYBOARD::IKeyboardInputProvider* const m_inputProvider;
74 
75  // Input parameters
76  PERIPHERALS::PeripheralPtr m_sourcePeripheral;
77  std::unique_ptr<CControllerActivity> m_keyboardActivity;
78 };
79 } // namespace GAME
80 } // namespace KODI
std::string KeyName
Name of a hardware-indendent symbol representing a key.
Definition: KeyboardTypes.h:33
Interface for handling input events for keyboards.
Definition: IKeyboardInputHandler.h:28
Handles keyboard events for games.
Definition: GameClientKeyboard.h:33
Interface between Kodi and Game add-ons.
Definition: GameClient.h:116
Definition: AudioDecoder.h:18
Interface for classes that can provide keyboard input.
Definition: IKeyboardInputProvider.h:22