Kodi Documentation 18.0
Kodi is an open source media player and entertainment hub.
kodi::addon::CInstancePeripheral Class Reference

#include <Peripheral.h>

Inheritance diagram for kodi::addon::CInstancePeripheral:
kodi::addon::IAddonInstance

Public Member Functions

 CInstancePeripheral ()
 
 CInstancePeripheral (KODI_HANDLE instance)
 
 ~CInstancePeripheral () override=default
 
Peripheral operations

{

virtual void GetCapabilities (PERIPHERAL_CAPABILITIES &capabilities)
 Get the list of features that this add-on provides. More...
 
virtual PERIPHERAL_ERROR PerformDeviceScan (unsigned int *peripheral_count, PERIPHERAL_INFO **scan_results)
 Perform a scan for joysticks. More...
 
virtual void FreeScanResults (unsigned int peripheral_count, PERIPHERAL_INFO *scan_results)
 Free the memory allocated in PerformDeviceScan() More...
 
virtual PERIPHERAL_ERROR GetEvents (unsigned int *event_count, PERIPHERAL_EVENT **events)
 Get all events that have occurred since the last call to GetEvents() More...
 
virtual void FreeEvents (unsigned int event_count, PERIPHERAL_EVENT *events)
 Free the memory allocated in GetEvents() More...
 
virtual bool SendEvent (const PERIPHERAL_EVENT *event)
 Send an input event to the peripheral. More...
 
- Public Member Functions inherited from kodi::addon::IAddonInstance
 IAddonInstance (ADDON_TYPE type)
 
virtual ~IAddonInstance ()=default
 
virtual ADDON_STATUS CreateInstance (int instanceType, std::string instanceID, KODI_HANDLE instance, KODI_HANDLE &addonInstance)
 
virtual ADDON_STATUS CreateInstanceEx (int instanceType, std::string instanceID, KODI_HANDLE instance, KODI_HANDLE &addonInstance, const std::string &version)
 

Joystick operations

}

virtual PERIPHERAL_ERROR GetJoystickInfo (unsigned int index, JOYSTICK_INFO *info)
 { More...
 
virtual void FreeJoystickInfo (JOYSTICK_INFO *info)
 Free the memory allocated in GetJoystickInfo() More...
 
virtual PERIPHERAL_ERROR GetFeatures (const JOYSTICK_INFO *joystick, const char *controller_id, unsigned int *feature_count, JOYSTICK_FEATURE **features)
 Get the features that allow translating the joystick into the controller profile. More...
 
virtual void FreeFeatures (unsigned int feature_count, JOYSTICK_FEATURE *features)
 Free the memory allocated in GetFeatures() More...
 
virtual PERIPHERAL_ERROR MapFeatures (const JOYSTICK_INFO *joystick, const char *controller_id, unsigned int feature_count, const JOYSTICK_FEATURE *features)
 Add or update joystick features. More...
 
virtual PERIPHERAL_ERROR GetIgnoredPrimitives (const JOYSTICK_INFO *joystick, unsigned int *primitive_count, JOYSTICK_DRIVER_PRIMITIVE **primitives)
 Get the driver primitives that should be ignored while mapping the device. More...
 
virtual void FreePrimitives (unsigned int primitive_count, JOYSTICK_DRIVER_PRIMITIVE *primitives)
 Free the memory allocated in GetIgnoredPrimitives() More...
 
virtual PERIPHERAL_ERROR SetIgnoredPrimitives (const JOYSTICK_INFO *joystick, unsigned int primitive_count, const JOYSTICK_DRIVER_PRIMITIVE *primitives)
 Set the list of driver primitives that are ignored for the device. More...
 
virtual void SaveButtonMap (const JOYSTICK_INFO *joystick)
 Save the button map for the given joystick. More...
 
virtual void RevertButtonMap (const JOYSTICK_INFO *joystick)
 Revert the button map to the last time it was loaded or committed to disk. More...
 
virtual void ResetButtonMap (const JOYSTICK_INFO *joystick, const char *controller_id)
 Reset the button map for the given joystick and controller profile ID. More...
 
virtual void PowerOffJoystick (unsigned int index)
 Powers off the given joystick if supported. More...
 
const std::string AddonPath () const
 
const std::string UserPath () const
 
void TriggerScan (void)
 Trigger a scan for peripherals. More...
 
void RefreshButtonMaps (const std::string &deviceName="", const std::string &controllerId="")
 Notify the frontend that button maps have changed. More...
 
unsigned int FeatureCount (const std::string &controllerId, JOYSTICK_FEATURE_TYPE type=JOYSTICK_FEATURE_TYPE_UNKNOWN)
 Return the number of features belonging to the specified controller. More...
 
JOYSTICK_FEATURE_TYPE FeatureType (const std::string &controllerId, const std::string &featureName)
 Return the type of the feature. More...
 

Additional Inherited Members

- Public Attributes inherited from kodi::addon::IAddonInstance
const ADDON_TYPE m_type
 

Constructor & Destructor Documentation

◆ CInstancePeripheral() [1/2]

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

◆ CInstancePeripheral() [2/2]

kodi::addon::CInstancePeripheral::CInstancePeripheral ( KODI_HANDLE  instance)
inlineexplicit

◆ ~CInstancePeripheral()

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

Member Function Documentation

◆ AddonPath()

const std::string kodi::addon::CInstancePeripheral::AddonPath ( ) const
inline

◆ FeatureCount()

unsigned int kodi::addon::CInstancePeripheral::FeatureCount ( const std::string &  controllerId,
JOYSTICK_FEATURE_TYPE  type = JOYSTICK_FEATURE_TYPE_UNKNOWN 
)
inline

Return the number of features belonging to the specified controller.

Parameters
controllerIdThe controller ID to enumerate
type[optional]Type to filter by, or JOYSTICK_FEATURE_TYPE_UNKNOWN for all features
Returns
The number of features matching the request parameters

◆ FeatureType()

JOYSTICK_FEATURE_TYPE kodi::addon::CInstancePeripheral::FeatureType ( const std::string &  controllerId,
const std::string &  featureName 
)
inline

Return the type of the feature.

Parameters
controllerIdThe controller ID to check
featureNameThe feature to check
Returns
The type of the specified feature, or JOYSTICK_FEATURE_TYPE_UNKNOWN if unknown

◆ FreeEvents()

virtual void kodi::addon::CInstancePeripheral::FreeEvents ( unsigned int  event_count,
PERIPHERAL_EVENT events 
)
inlinevirtual

Free the memory allocated in GetEvents()

Must be called if GetEvents() returns PERIPHERAL_NO_ERROR.

Parameters
event_countThe number of events allocated for the events array
eventsThe array of allocated events

◆ FreeFeatures()

virtual void kodi::addon::CInstancePeripheral::FreeFeatures ( unsigned int  feature_count,
JOYSTICK_FEATURE features 
)
inlinevirtual

Free the memory allocated in GetFeatures()

Must be called if GetFeatures() returns PERIPHERAL_NO_ERROR.

Parameters
feature_countThe number of features allocated for the features array
featuresThe array of allocated features

◆ FreeJoystickInfo()

virtual void kodi::addon::CInstancePeripheral::FreeJoystickInfo ( JOYSTICK_INFO info)
inlinevirtual

Free the memory allocated in GetJoystickInfo()

◆ FreePrimitives()

virtual void kodi::addon::CInstancePeripheral::FreePrimitives ( unsigned int  primitive_count,
JOYSTICK_DRIVER_PRIMITIVE primitives 
)
inlinevirtual

Free the memory allocated in GetIgnoredPrimitives()

Must be called if GetIgnoredPrimitives() returns PERIPHERAL_NO_ERROR.

Parameters
primitive_countThe number of driver primitives allocated for the primitives array
primitivesThe array of allocated driver primitives

◆ FreeScanResults()

virtual void kodi::addon::CInstancePeripheral::FreeScanResults ( unsigned int  peripheral_count,
PERIPHERAL_INFO scan_results 
)
inlinevirtual

Free the memory allocated in PerformDeviceScan()

Must be called if PerformDeviceScan() returns PERIPHERAL_NO_ERROR.

Parameters
peripheral_countThe number of events allocated for the events array
scan_resultsThe array of allocated peripherals

◆ GetCapabilities()

virtual void kodi::addon::CInstancePeripheral::GetCapabilities ( PERIPHERAL_CAPABILITIES capabilities)
inlinevirtual

Get the list of features that this add-on provides.

Parameters
capabilitiesThe add-on's capabilities.
Remarks
Valid implementation required.

Called by the frontend to query the add-on's capabilities and supported peripherals. All capabilities that the add-on supports should be set to true.

◆ GetEvents()

virtual PERIPHERAL_ERROR kodi::addon::CInstancePeripheral::GetEvents ( unsigned int *  event_count,
PERIPHERAL_EVENT **  events 
)
inlinevirtual

Get all events that have occurred since the last call to GetEvents()

Returns
PERIPHERAL_NO_ERROR if successful; events must be freed using FreeEvents() in this case

◆ GetFeatures()

virtual PERIPHERAL_ERROR kodi::addon::CInstancePeripheral::GetFeatures ( const JOYSTICK_INFO joystick,
const char *  controller_id,
unsigned int *  feature_count,
JOYSTICK_FEATURE **  features 
)
inlinevirtual

Get the features that allow translating the joystick into the controller profile.

Parameters
joystickThe device's joystick properties; unknown values may be left at their default
controller_idThe controller profile being requested, e.g. game.controller.default
feature_countThe number of features allocated for the features array
featuresThe array of allocated features
Returns
PERIPHERAL_NO_ERROR if successful; array must be freed using FreeButtonMap() in this case

◆ GetIgnoredPrimitives()

virtual PERIPHERAL_ERROR kodi::addon::CInstancePeripheral::GetIgnoredPrimitives ( const JOYSTICK_INFO joystick,
unsigned int *  primitive_count,
JOYSTICK_DRIVER_PRIMITIVE **  primitives 
)
inlinevirtual

Get the driver primitives that should be ignored while mapping the device.

Parameters
joystickThe device's joystick properties; unknown values may be left at their default
primitive_countThe number of features allocated for the primitives array
primitivesThe array of allocated driver primitives to be ignored
Returns
PERIPHERAL_NO_ERROR if successful; array must be freed using FreePrimitives() in this case

◆ GetJoystickInfo()

virtual PERIPHERAL_ERROR kodi::addon::CInstancePeripheral::GetJoystickInfo ( unsigned int  index,
JOYSTICK_INFO info 
)
inlinevirtual

{

Note
#define PERIPHERAL_ADDON_JOYSTICKS before including kodi_peripheral_dll.h in the add-on if the add-on provides joysticks and add provides_joysticks="true" to the kodi.peripheral extension point node in addon.xml.

Get extended info about an attached joystick

Parameters
indexThe joystick's driver index
infoThe container for the allocated joystick info
Returns
PERIPHERAL_NO_ERROR if successful; array must be freed using FreeJoystickInfo() in this case

◆ MapFeatures()

virtual PERIPHERAL_ERROR kodi::addon::CInstancePeripheral::MapFeatures ( const JOYSTICK_INFO joystick,
const char *  controller_id,
unsigned int  feature_count,
const JOYSTICK_FEATURE features 
)
inlinevirtual

Add or update joystick features.

Parameters
joystickThe device's joystick properties; unknown values may be left at their default
controller_idThe game controller profile being updated
feature_countThe number of features in the features array
featuresThe array of features
Returns
PERIPHERAL_NO_ERROR if successful

◆ PerformDeviceScan()

virtual PERIPHERAL_ERROR kodi::addon::CInstancePeripheral::PerformDeviceScan ( unsigned int *  peripheral_count,
PERIPHERAL_INFO **  scan_results 
)
inlinevirtual

Perform a scan for joysticks.

Parameters
peripheral_countAssigned to the number of peripherals allocated
scan_resultsAssigned to allocated memory
Returns
PERIPHERAL_NO_ERROR if successful; peripherals must be freed using FreeScanResults() in this case

The frontend calls this when a hardware change is detected. If an add-on detects a hardware change, it can trigger this function using the TriggerScan() callback.

◆ PowerOffJoystick()

virtual void kodi::addon::CInstancePeripheral::PowerOffJoystick ( unsigned int  index)
inlinevirtual

Powers off the given joystick if supported.

Parameters
indexThe joystick's driver index

◆ RefreshButtonMaps()

void kodi::addon::CInstancePeripheral::RefreshButtonMaps ( const std::string &  deviceName = "",
const std::string &  controllerId = "" 
)
inline

Notify the frontend that button maps have changed.

Parameters
[optional]deviceName The name of the device to refresh, or empty/null for all devices
[optional]controllerId The controller ID to refresh, or empty/null for all controllers

◆ ResetButtonMap()

virtual void kodi::addon::CInstancePeripheral::ResetButtonMap ( const JOYSTICK_INFO joystick,
const char *  controller_id 
)
inlinevirtual

Reset the button map for the given joystick and controller profile ID.

Parameters
joystickThe device's joystick properties
controller_idThe game controller profile being reset

◆ RevertButtonMap()

virtual void kodi::addon::CInstancePeripheral::RevertButtonMap ( const JOYSTICK_INFO joystick)
inlinevirtual

Revert the button map to the last time it was loaded or committed to disk.

Parameters
joystickThe device's joystick properties

◆ SaveButtonMap()

virtual void kodi::addon::CInstancePeripheral::SaveButtonMap ( const JOYSTICK_INFO joystick)
inlinevirtual

Save the button map for the given joystick.

Parameters
joystickThe device's joystick properties

◆ SendEvent()

virtual bool kodi::addon::CInstancePeripheral::SendEvent ( const PERIPHERAL_EVENT event)
inlinevirtual

Send an input event to the peripheral.

Parameters
eventThe input event
Returns
true if the event was handled, false otherwise

◆ SetIgnoredPrimitives()

virtual PERIPHERAL_ERROR kodi::addon::CInstancePeripheral::SetIgnoredPrimitives ( const JOYSTICK_INFO joystick,
unsigned int  primitive_count,
const JOYSTICK_DRIVER_PRIMITIVE primitives 
)
inlinevirtual

Set the list of driver primitives that are ignored for the device.

Parameters
joystickThe device's joystick properties; unknown values may be left at their default
primitive_countThe number of driver features in the primitives array
primitivesThe array of driver primitives to ignore
Returns
PERIPHERAL_NO_ERROR if successful

◆ TriggerScan()

void kodi::addon::CInstancePeripheral::TriggerScan ( void  )
inline

Trigger a scan for peripherals.

The add-on calls this if a change in hardware is detected.

◆ UserPath()

const std::string kodi::addon::CInstancePeripheral::UserPath ( ) const
inline

The documentation for this class was generated from the following file: