| 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 "input/keymaps/KeymapTypes.h" |
| 12 |
|
| 13 |
#include <string> |
| 14 |
|
| 15 |
namespace KODI |
| 16 |
{ |
| 17 |
namespace KEYMAP |
| 18 |
{ |
| 19 |
class IKeymapEnvironment; |
| 20 |
|
| 21 |
/*! |
| 22 |
* \ingroup keymap |
| 23 |
* |
| 24 |
* \brief Interface for mapping buttons to Kodi actions |
| 25 |
* |
| 26 |
* \sa CJoystickUtils::MakeKeyName |
| 27 |
*/ |
| 28 |
class IKeymap |
| 29 |
{ |
| 30 |
public: |
| 31 |
virtual ~IKeymap() = default; |
| 32 |
|
| 33 |
/*! |
| 34 |
* \brief The controller ID |
| 35 |
* |
| 36 |
* This is required because key names are specific to each controller |
| 37 |
*/ |
| 38 |
virtual std::string ControllerID() const = 0; |
| 39 |
|
| 40 |
/*! |
| 41 |
* \brief Access properties of the keymapping environment |
| 42 |
*/ |
| 43 |
virtual const IKeymapEnvironment* Environment() const = 0; |
| 44 |
|
| 45 |
/*! |
| 46 |
* \brief Get the actions for a given key name |
| 47 |
* |
| 48 |
* \param keyName The key name created by CJoystickUtils::MakeKeyName() |
| 49 |
* |
| 50 |
* \return A list of actions associated with the given key |
| 51 |
*/ |
| 52 |
virtual const KeymapActionGroup& GetActions(const std::string& keyName) const = 0; |
| 53 |
}; |
| 54 |
|
| 55 |
/*! |
| 56 |
* \brief Interface for mapping buttons to Kodi actions for specific windows |
| 57 |
* |
| 58 |
* \sa CJoystickUtils::MakeKeyName |
| 59 |
*/ |
| 60 |
class IWindowKeymap |
| 61 |
{ |
| 62 |
public: |
| 63 |
virtual ~IWindowKeymap() = default; |
| 64 |
|
| 65 |
/*! |
| 66 |
* \brief The controller ID |
| 67 |
* |
| 68 |
* This is required because key names are specific to each controller |
| 69 |
*/ |
| 70 |
virtual std::string ControllerID() const = 0; |
| 71 |
|
| 72 |
/*! |
| 73 |
* \brief Add an action to the keymap for a given key name and window ID |
| 74 |
* |
| 75 |
* \param windowId The window ID to look up |
| 76 |
* \param keyName The key name created by CJoystickUtils::MakeKeyName() |
| 77 |
* \param action The action to map |
| 78 |
*/ |
| 79 |
virtual void MapAction(int windowId, const std::string& keyName, KeymapAction action) = 0; |
| 80 |
|
| 81 |
/*! |
| 82 |
* \brief Get the actions for a given key name and window ID |
| 83 |
* |
| 84 |
* \param windowId The window ID to look up |
| 85 |
* \param keyName The key name created by CJoystickUtils::MakeKeyName() |
| 86 |
* |
| 87 |
* \return A list of actions associated with the given key for the given window |
| 88 |
*/ |
| 89 |
virtual const KeymapActionGroup& GetActions(int windowId, const std::string& keyName) const = 0; |
| 90 |
}; |
| 91 |
} // namespace KEYMAP |
| 92 |
} // namespace KODI |