Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches

Class: kodi::addon::CInstancePeripheral

Peripheral add-on instance More...

Topics

 Peripheral system
 System description.
 
 Definitions, structures and enumerators
 Peripheral add-on general variables
 
 1. Peripheral operations
 Peripheral operations to handle control about.
 
 2. Joystick operations
 Joystick operations to handle control about.
 
 3. Callback functions
 Callback to Kodi functions.
 

Functions

 kodi::addon::CInstancePeripheral::CInstancePeripheral ()
 Peripheral class constructor.
 
 kodi::addon::CInstancePeripheral::CInstancePeripheral (const IInstanceInfo &instance)
 Peripheral addon class constructor used to support multiple instance types.
 
 kodi::addon::CInstancePeripheral::~CInstancePeripheral () override=default
 Destructor.
 

Detailed Description

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.
Remarks
For more detailed description of the addon.xml, see also https://kodi.wiki/view/Addon.xml.

Here is an example of how addon can be used as a single:

class CMyPeripheralAddon : public kodi::addon::CAddonBase,
{
public:
CMyPeripheralAddon();
...
};
CMyPeripheralAddon::CMyPeripheralAddon()
{
...
}
void CMyPeripheralAddon::GetCapabilities(kodi::addon::PeripheralCapabilities& capabilities)
{
capabilities.SetProvidesJoysticks(true);
capabilities.SetProvidesButtonmaps(true);
...
}
ADDONCREATOR(CMyPeripheralAddon)
Definition kodi-dev-kit/include/kodi/AddonBase.h:775
Definition addons/kodi-dev-kit/include/kodi/addon-instance/Peripheral.h:210
Definition PeripheralUtils.h:133
void SetProvidesJoysticks(bool providesJoysticks)
Set true if the add-on provides joysticks.
Definition PeripheralUtils.h:167
void SetProvidesButtonmaps(bool providesButtonmaps)
Set true if the add-on provides button maps.
Definition PeripheralUtils.h:194
virtual void GetCapabilities(kodi::addon::PeripheralCapabilities &capabilities)
Get the list of features that this add-on provides.
Definition addons/kodi-dev-kit/include/kodi/addon-instance/Peripheral.h:323
#define ADDONCREATOR(AddonClass)
Definition kodi-dev-kit/include/kodi/AddonBase.h:2047
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:

class CMyPeripheralAddon : public kodi::addon::CInstancePeripheral
{
public:
CMyPeripheralAddon(const kodi::addon::IInstanceInfo& instance);
...
};
CMyPeripheralAddon::CMyPeripheralAddon(const kodi::addon::IInstanceInfo& instance)
: CInstancePeripheral(instance)
{
...
}
void CMyPeripheralAddon::GetCapabilities(kodi::addon::PeripheralCapabilities& capabilities)
{
capabilities.SetProvidesJoysticks(true);
capabilities.SetProvidesButtonmaps(true);
...
}
//----------------------------------------------------------------------
class CMyAddon : public kodi::addon::CAddonBase
{
public:
CMyAddon() = default;
};
// If you use only one instance in your add-on, can be instanceType and
// instanceID ignored
ADDON_STATUS CMyAddon::CreateInstance(const kodi::addon::IInstanceInfo& instance,
{
{
kodi::Log(ADDON_LOG_INFO, "Creating my peripheral addon");
addonInstance = new CMyPeripheralAddon(instance);
}
else if (...)
{
...
}
}
ADDONCREATOR(CMyAddon)
void * KODI_ADDON_INSTANCE_HDL
Definition addon_base.h:121
KODI_ADDON_HDL * hdl
Definition addon_base.h:344
Definition kodi-dev-kit/include/kodi/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
virtual ADDON_STATUS CreateInstance(const kodi::addon::IInstanceInfo &instance, KODI_ADDON_INSTANCE_HDL &hdl)
Instance created.
Definition kodi-dev-kit/include/kodi/AddonBase.h:924
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition kodi-dev-kit/include/kodi/AddonBase.h:1938
Definition addon_base.h:268

The destruction of the example class CMyPeripheralAddon is called from Kodi's header. Manually deleting the add-on instance is not required.

Function Documentation

◆ CInstancePeripheral() [1/2]

kodi::addon::CInstancePeripheral::CInstancePeripheral ( )
inline

Peripheral class constructor.

Used by an add-on that only supports peripheral.

◆ CInstancePeripheral() [2/2]

kodi::addon::CInstancePeripheral::CInstancePeripheral ( const IInstanceInfo & instance)
inlineexplicit

Peripheral addon class constructor used to support multiple instance types.

Parameters
[in]instanceThe instance value given to kodi::addon::CAddonBase::CreateInstance(...).

◆ ~CInstancePeripheral()

kodi::addon::CInstancePeripheral::~CInstancePeripheral ( )
overridedefault

Destructor.