kodi
AgentKeyboard.h
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/keyboard/interfaces/IKeyboardInputHandler.h"
13 #include "peripherals/PeripheralTypes.h"
14 
15 namespace KODI
16 {
17 namespace GAME
18 {
19 class CControllerActivity;
20 
27 {
28 public:
29  CAgentKeyboard(PERIPHERALS::PeripheralPtr peripheral);
30 
31  ~CAgentKeyboard() 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 IKeyboardInputHandler
42  std::string ControllerID() const override;
43  bool HasKey(const KEYBOARD::KeyName& key) const override;
44  bool OnKeyPress(const KEYBOARD::KeyName& key, KEYBOARD::Modifier mod, uint32_t unicode) override;
45  void OnKeyRelease(const KEYBOARD::KeyName& key,
46  KEYBOARD::Modifier mod,
47  uint32_t unicode) override;
48 
49 private:
50  // Construction parameters
51  const PERIPHERALS::PeripheralPtr m_peripheral;
52 
53  // Input state
54  std::unique_ptr<CControllerActivity> m_keyboardActivity;
55  ControllerPtr m_controllerAppearance;
56 };
57 } // namespace GAME
58 } // 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
void OnKeyRelease(const KEYBOARD::KeyName &key, KEYBOARD::Modifier mod, uint32_t unicode) override
A key has been released.
Definition: AgentKeyboard.cpp:81
bool OnKeyPress(const KEYBOARD::KeyName &key, KEYBOARD::Modifier mod, uint32_t unicode) override
A key has been pressed.
Definition: AgentKeyboard.cpp:71
Definition: AudioDecoder.h:18
std::shared_ptr< CController > ControllerPtr
Smart pointer to a game controller (CController)
Definition: ControllerTypes.h:25
Handles keyboard events for game agent functionality.
Definition: AgentKeyboard.h:26
std::string ControllerID() const override
The add-on ID of the keyboard&#39;s controller profile.
Definition: AgentKeyboard.cpp:61
bool HasKey(const KEYBOARD::KeyName &key) const override
Return true if the input handler accepts the given key.
Definition: AgentKeyboard.cpp:66