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

Peripheral operations to handle control about. More...

Functions

virtual void kodi::addon::CInstancePeripheral::GetCapabilities (kodi::addon::PeripheralCapabilities &capabilities)
 Get the list of features that this add-on provides.
 
virtual PERIPHERAL_ERROR kodi::addon::CInstancePeripheral::PerformDeviceScan (std::vector< std::shared_ptr< kodi::addon::Peripheral > > &scan_results)
 Perform a scan for joysticks.
 
virtual PERIPHERAL_ERROR kodi::addon::CInstancePeripheral::GetEvents (std::vector< kodi::addon::PeripheralEvent > &events)
 Get all events that have occurred since the last call to GetEvents().
 
virtual bool kodi::addon::CInstancePeripheral::SendEvent (const kodi::addon::PeripheralEvent &event)
 Send an input event to the peripheral.
 

Detailed Description

Peripheral operations to handle control about.


Peripheral parts in interface:
Copy this to your project and extend with your parts or leave functions complete away where not used or supported.

Function Documentation

◆ GetCapabilities()

virtual void kodi::addon::CInstancePeripheral::GetCapabilities ( kodi::addon::PeripheralCapabilities & capabilities)
inlinevirtual

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

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.

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

@ingroup cpp_kodi_addon_peripheral_Defs_PeripheralCapabilities

The following table contains values that can be set with class PeripheralCapabilities :

Name Type Set call Get call
Provides joysticks boolean SetProvidesJoysticks GetProvidesJoysticks
Provides joystick rumble boolean SetProvidesJoystickRumble GetProvidesJoystickRumble
Provides joystick power off boolean SetProvidesJoystickPowerOff GetProvidesJoystickPowerOff
Provides button maps boolean SetProvidesButtonmaps GetProvidesButtonmaps

Example:

void CMyPeripheralAddon::GetCapabilities(kodi::addon::PeripheralCapabilities& capabilities)
{
capabilities.SetProvidesJoysticks(true);
capabilities.SetProvidesButtonmaps(true);
}
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

◆ GetEvents()

virtual PERIPHERAL_ERROR kodi::addon::CInstancePeripheral::GetEvents ( std::vector< kodi::addon::PeripheralEvent > & events)
inlinevirtual

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

Parameters
[out]eventsList of available events within addon
Returns
PERIPHERAL_NO_ERROR if successful

@ingroup cpp_kodi_addon_peripheral_Defs_Peripheral_PeripheralEvent

The following table contains values that can be set with class PeripheralEvent :

Name Type Set call Get call
Peripheral event type PERIPHERAL_EVENT_TYPE SetType Type
Peripheral index unsigned int SetPeripheralIndex PeripheralIndex
Peripheral event driver index unsigned int SetDriverIndex DriverIndex
Peripheral event button state JOYSTICK_STATE_BUTTON SetButtonState ButtonState
Peripheral event hat state JOYSTICK_STATE_HAT SetHatState HatState
Peripheral event axis state JOYSTICK_STATE_AXIS (float) SetAxisState AxisState
Peripheral event motor state JOYSTICK_STATE_MOTOR (float) SetMotorState MotorState

Further are several class constructors with values included.

◆ PerformDeviceScan()

virtual PERIPHERAL_ERROR kodi::addon::CInstancePeripheral::PerformDeviceScan ( std::vector< std::shared_ptr< kodi::addon::Peripheral > > & scan_results)
inlinevirtual

Perform a scan for joysticks.

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.

Parameters
[in]scan_resultsAssigned to allocated memory
Returns
PERIPHERAL_NO_ERROR if successful

@ingroup cpp_kodi_addon_peripheral_Defs_Peripheral_Peripheral

The following table contains values that can be set with class Peripheral :

Name Type Set call Get call
Peripheral type PERIPHERAL_TYPE SetType Type
Peripheral name const std::string& SetName Name
Peripheral vendor id uint16_t SetVendorID VendorID
Peripheral product id uint16_t SetProductID ProductID
Peripheral index unsigned int SetIndex Index

Further are following included:

◆ SendEvent()

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

Send an input event to the peripheral.

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