Class: kodi::addon::CInstancePeripheral
Peripheral add-on instance
The peripheral add-ons provides access to many joystick and gamepad interfaces across various platforms. An input addon is used to map the buttons/axis on your physical input device, to the buttons/axis of your virtual system. This is necessary because different retro systems usually have different button layouts. A controller configuration utility is also in the works.
Here is an example of what the addon.xml.in
would look like for an peripheral addon:
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="peripheral.myspecialnamefor"
version="1.0.0"
name="My special peripheral addon"
provider-name="Your Name">
<requires>@ADDON_DEPENDS@</requires>
<extension
point="kodi.peripheral"
provides_joysticks="true"
provides_buttonmaps="true"
library_@PLATFORM@="@LIBRARY_FILENAME@"/>
<extension point="xbmc.addon.metadata">
<summary lang="en_GB">My peripheral addon</summary>
<description lang="en_GB">My peripheral addon description</description>
<platform>@PLATFORM@</platform>
</extension>
</addon>
Description to peripheral related addon.xml values:
Name | Description |
provides_joysticks | Set to "true" if addon provides joystick support. |
provides_buttonmaps | Set to "true" if button map is used and supported by addon. |
point | Addon type specification
At all addon types and for this kind always "kodi.peripheral". |
library_@PLATFORM@ | Sets the used library name, which is automatically set by cmake at addon build. |
Here is an example of how addon can be used as a single:
#include <kodi/addon-instance/Peripheral.h>
{
public:
CMyPeripheralAddon();
...
};
CMyPeripheralAddon::CMyPeripheralAddon()
{
...
}
{
...
}
ADDONCREATOR(CMyPeripheralAddon)
Definition: AddonBase.h:322
Definition: Peripheral.h:216
Definition: PeripheralUtils.h:133
void SetProvidesButtonmaps(bool providesButtonmaps)
Set true if the add-on provides button maps.
Definition: PeripheralUtils.h:194
void SetProvidesJoysticks(bool providesJoysticks)
Set true if the add-on provides joysticks.
Definition: PeripheralUtils.h:167
- Note
- It is imperative to use the necessary functions of this class in the addon.
Here is another example where the peripheral is used together with other instance types:
#include <kodi/addon-instance/Peripheral.h>
{
public:
CMyPeripheralAddon(KODI_HANDLE instance, const std::string& version);
...
};
CMyPeripheralAddon::CMyPeripheralAddon(KODI_HANDLE instance, const std::string& version)
: CInstancePeripheral(instance, version)
{
...
}
{
...
}
{
public:
CMyAddon() = default;
const std::string& instanceID,
KODI_HANDLE instance,
const std::string& version,
KODI_HANDLE& addonInstance) override;
};
const std::string& instanceID,
KODI_HANDLE instance,
const std::string& version,
KODI_HANDLE& addonInstance)
{
{
addonInstance = new CMyPeripheralAddon(instance, version);
}
else if (...)
{
...
}
}
ADDONCREATOR(CMyAddon)
@ ADDON_LOG_INFO
1 : To include information messages in the log file.
Definition: addon_base.h:177
ADDON_STATUS
Definition: addon_base.h:128
@ ADDON_STATUS_OK
For everything OK and no error.
Definition: addon_base.h:130
@ ADDON_STATUS_UNKNOWN
Unknown and incomprehensible error.
Definition: addon_base.h:142
@ ADDON_INSTANCE_PERIPHERAL
Peripheral instance, see kodi::addon::CInstancePeripheral.
Definition: versions.h:229
virtual ADDON_STATUS CreateInstance(int instanceType, const std::string &instanceID, KODI_HANDLE instance, const std::string &version, KODI_HANDLE &addonInstance)
Instance created.
Definition: AddonBase.h:481
void ATTRIBUTE_HIDDEN Log(const AddonLog loglevel, const char *format,...)
Add a message to Kodi's log.
Definition: AddonBase.h:749
The destruction of the example class CMyPeripheralAddon
is called from Kodi's header. Manually deleting the add-on instance is not required.
◆ CInstancePeripheral() [1/2]
Peripheral class constructor.
Used by an add-on that only supports peripheral.
◆ CInstancePeripheral() [2/2]
Peripheral addon class constructor used to support multiple instance types.
- Parameters
-
[in] | instance | The instance value given to kodi::addon::CAddonBase::CreateInstance(...) . |
[in] | kodiVersion | [opt] Version used in Kodi for this instance, to allow compatibility to older Kodi versions. |
- Note
- Recommended to set
kodiVersion
.
◆ ~CInstancePeripheral()