blob: a6103f2f7a06bb99bf7129dc2712d788194a5c2e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*
* Copyright (C) 2015-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "input/keyboard/interfaces/IKeyboardInputHandler.h"
#include "peripherals/PeripheralTypes.h"
namespace KODI
{
namespace KEYBOARD
{
class IKeyboardInputProvider;
}
namespace GAME
{
class CGameClient;
/*!
* \ingroup games
* \brief Handles keyboard events for games.
*
* Listens to keyboard events and forwards them to the games (as game_input_event).
*/
class CGameClientKeyboard : public KEYBOARD::IKeyboardInputHandler
{
public:
/*!
* \brief Constructor registers for keyboard events at CInputManager.
* \param gameClient The game client implementation.
* \param controllerId The controller profile used for input
* \param dllStruct The emulator or game to which the events are sent.
* \param inputProvider The interface providing us with keyboard input.
*/
CGameClientKeyboard(CGameClient& gameClient,
std::string controllerId,
KEYBOARD::IKeyboardInputProvider* inputProvider);
/*!
* \brief Destructor unregisters from keyboard events from CInputManager.
*/
~CGameClientKeyboard() override;
// implementation of IKeyboardInputHandler
std::string ControllerID() const override;
bool HasKey(const KEYBOARD::KeyName& key) const override;
bool OnKeyPress(const KEYBOARD::KeyName& key, KEYBOARD::Modifier mod, uint32_t unicode) override;
void OnKeyRelease(const KEYBOARD::KeyName& key,
KEYBOARD::Modifier mod,
uint32_t unicode) override;
// Input accessors
const std::string& GetControllerID() const { return m_controllerId; }
const PERIPHERALS::PeripheralPtr& GetSource() const { return m_sourcePeripheral; }
// Input mutators
void SetSource(PERIPHERALS::PeripheralPtr sourcePeripheral);
void ClearSource();
private:
// Construction parameters
CGameClient& m_gameClient;
const std::string m_controllerId;
KEYBOARD::IKeyboardInputProvider* const m_inputProvider;
// Input parameters
PERIPHERALS::PeripheralPtr m_sourcePeripheral;
};
} // namespace GAME
} // namespace KODI
|