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:775
Definition Peripheral.h:210
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
virtual void GetCapabilities(kodi::addon::PeripheralCapabilities &capabilities)
Get the list of features that this add-on provides.
Definition Peripheral.h:323
- 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:
...
};
: CInstancePeripheral(instance)
{
...
}
{
...
}
{
public:
CMyAddon() = default;
KODI_ADDON_INSTANCE_HDL& hdl) override;
};
KODI_ADDON_INSTANCE_HDL& hdl)
{
{
addonInstance = new CMyPeripheralAddon(instance);
}
else if (...)
{
...
}
}
ADDONCREATOR(CMyAddon)
Definition AddonBase.h:498
@ ADDON_LOG_INFO
1 : To include information messages in the log file.
Definition addon_base.h:187
ADDON_STATUS
Definition addon_base.h:138
@ ADDON_STATUS_OK
For everything OK and no error.
Definition addon_base.h:140
@ ADDON_STATUS_UNKNOWN
Unknown and incomprehensible error.
Definition addon_base.h:152
@ ADDON_INSTANCE_PERIPHERAL
Peripheral instance, see kodi::addon::CInstancePeripheral.
Definition versions.h:231
bool IsType(KODI_ADDON_INSTANCE_TYPE type) const
Check asked type used on this class.
Definition AddonBase.h:525
virtual ADDON_STATUS CreateInstance(const kodi::addon::IInstanceInfo &instance, KODI_ADDON_INSTANCE_HDL &hdl)
Instance created.
Definition AddonBase.h:924
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition AddonBase.h:1938
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(...) . |
◆ ~CInstancePeripheral()