Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
PERIPHERALS::CPeripheralJoystick Class Reference

#include <PeripheralJoystick.h>

Inheritance diagram for PERIPHERALS::CPeripheralJoystick:
PERIPHERALS::CPeripheral KODI::JOYSTICK::IDriverReceiver KODI::JOYSTICK::IInputProvider KODI::KEYBOARD::IKeyboardInputProvider KODI::MOUSE::IMouseInputProvider

Classes

struct  DriverHandler
 

Public Member Functions

 CPeripheralJoystick (CPeripherals &manager, const PeripheralScanResult &scanResult, CPeripheralBus *bus)
 
 ~CPeripheralJoystick (void) override
 
bool InitialiseFeature (const PeripheralFeature feature) override
 Initialise one of the features of this peripheral.
 
void OnUserNotification () override
 Briefly activate a feature to notify the user.
 
bool TestFeature (PeripheralFeature feature) override
 Briefly test one of the features of this peripheral.
 
void RegisterJoystickDriverHandler (KODI::JOYSTICK::IDriverHandler *handler, bool bPromiscuous) override
 
void UnregisterJoystickDriverHandler (KODI::JOYSTICK::IDriverHandler *handler) override
 
KODI::JOYSTICK::IDriverReceiverGetDriverReceiver () override
 
KODI::KEYMAP::IKeymapGetKeymap (const std::string &controllerId) override
 
CDateTime LastActive () const override
 Return the last time this peripheral was active.
 
KODI::GAME::ControllerPtr ControllerProfile () const override
 Get the controller profile that best represents this peripheral.
 
void SetControllerProfile (const KODI::GAME::ControllerPtr &controller) override
 Set the controller profile for this peripheral.
 
bool OnButtonMotion (unsigned int buttonIndex, bool bPressed)
 
bool OnHatMotion (unsigned int hatIndex, KODI::JOYSTICK::HAT_STATE state)
 
bool OnAxisMotion (unsigned int axisIndex, float position)
 
void OnInputFrame (void)
 
bool SetMotorState (unsigned int motorIndex, float magnitude) override
 Set the value of a rumble motor.
 
const std::string & Provider (void) const
 Get the name of the driver or API providing this joystick.
 
int RequestedPort (void) const
 Get the specific port number requested by this joystick.
 
unsigned int ButtonCount (void) const
 Get the number of elements reported by the driver.
 
unsigned int HatCount (void) const
 
unsigned int AxisCount (void) const
 
unsigned int MotorCount (void) const
 
bool SupportsPowerOff (void) const
 
void SetProvider (const std::string &provider)
 Set joystick properties.
 
void SetRequestedPort (int port)
 
void SetButtonCount (unsigned int buttonCount)
 
void SetHatCount (unsigned int hatCount)
 
void SetAxisCount (unsigned int axisCount)
 
void SetMotorCount (unsigned int motorCount)
 
void SetSupportsPowerOff (bool bSupportsPowerOff)
 
- Public Member Functions inherited from PERIPHERALS::CPeripheral
 CPeripheral (CPeripherals &manager, const PeripheralScanResult &scanResult, CPeripheralBus *bus)
 
 ~CPeripheral (void) override
 
bool operator== (const CPeripheral &right) const
 
bool operator!= (const CPeripheral &right) const
 
bool operator== (const PeripheralScanResult &right) const
 
bool operator!= (const PeripheralScanResult &right) const
 
const std::string & FileLocation (void) const
 
const std::string & Location (void) const
 
int VendorId (void) const
 
const char * VendorIdAsString (void) const
 
int ProductId (void) const
 
const char * ProductIdAsString (void) const
 
PeripheralType Type (void) const
 
PeripheralBusType GetBusType (void) const
 
const std::string & DeviceName (void) const
 
bool IsHidden (void) const
 
void SetHidden (bool bSetTo=true)
 
const std::string & GetVersionInfo (void) const
 
virtual std::string GetIcon () const
 Get an icon for this peripheral.
 
bool HasFeature (const PeripheralFeature feature) const
 Check whether this device has the given feature.
 
void GetFeatures (std::vector< PeripheralFeature > &features) const
 Get all features that are supported by this device.
 
bool Initialise (void)
 Initialises the peripheral.
 
virtual void OnSettingChanged (const std::string &strChangedSetting)
 Called when a setting changed.
 
virtual void OnDeviceRemoved (void)
 Called when this device is removed, before calling the destructor.
 
virtual void GetSubdevices (PeripheralVector &subDevices) const
 Get all subdevices if this device is multifunctional.
 
virtual bool IsMultiFunctional (void) const
 
virtual void AddSetting (const std::string &strKey, const std::shared_ptr< const CSetting > &setting, int order)
 Add a setting to this peripheral. This will overwrite a previous setting with the same key.
 
virtual bool HasSetting (const std::string &strKey) const
 Check whether a setting is known with the given key.
 
virtual bool HasSettings (void) const
 
virtual bool HasConfigurableSettings (void) const
 
virtual const std::string GetSettingString (const std::string &strKey) const
 Get the value of a setting.
 
virtual bool SetSetting (const std::string &strKey, const std::string &strValue)
 
virtual void SetSettingVisible (const std::string &strKey, bool bSetTo)
 
virtual bool IsSettingVisible (const std::string &strKey) const
 
virtual int GetSettingInt (const std::string &strKey) const
 
virtual bool SetSetting (const std::string &strKey, int iValue)
 
virtual bool GetSettingBool (const std::string &strKey) const
 
virtual bool SetSetting (const std::string &strKey, bool bValue)
 
virtual float GetSettingFloat (const std::string &strKey) const
 
virtual bool SetSetting (const std::string &strKey, float fValue)
 
virtual void PersistSettings (bool bExiting=false)
 
virtual void LoadPersistedSettings (void)
 
virtual void ResetDefaultSettings (void)
 
virtual std::vector< std::shared_ptr< CSetting > > GetSettings (void) const
 
virtual bool ErrorOccured (void) const
 
virtual void RegisterKeyboardDriverHandler (KODI::KEYBOARD::IKeyboardDriverHandler *handler, bool bPromiscuous)
 
virtual void UnregisterKeyboardDriverHandler (KODI::KEYBOARD::IKeyboardDriverHandler *handler)
 
virtual void RegisterMouseDriverHandler (KODI::MOUSE::IMouseDriverHandler *handler, bool bPromiscuous)
 
virtual void UnregisterMouseDriverHandler (KODI::MOUSE::IMouseDriverHandler *handler)
 
void RegisterInputHandler (KODI::JOYSTICK::IInputHandler *handler, bool bPromiscuous) override
 Register a handler for the provided input.
 
void UnregisterInputHandler (KODI::JOYSTICK::IInputHandler *handler) override
 Unregister a handler.
 
void RegisterKeyboardHandler (KODI::KEYBOARD::IKeyboardInputHandler *handler, bool bPromiscuous, bool forceDefaultMap) override
 Registers a handler to be called on keyboard input.
 
void UnregisterKeyboardHandler (KODI::KEYBOARD::IKeyboardInputHandler *handler) override
 Unregisters handler from keyboard input.
 
void RegisterMouseHandler (KODI::MOUSE::IMouseInputHandler *handler, bool bPromiscuous, bool forceDefaultMap) override
 Registers a handler to be called on mouse input.
 
void UnregisterMouseHandler (KODI::MOUSE::IMouseInputHandler *handler) override
 Unregisters handler from mouse input.
 
virtual void RegisterJoystickButtonMapper (KODI::JOYSTICK::IButtonMapper *mapper)
 
virtual void UnregisterJoystickButtonMapper (KODI::JOYSTICK::IButtonMapper *mapper)
 
- Public Member Functions inherited from KODI::JOYSTICK::IInputProvider
virtual ~IInputProvider ()=default
 
- Public Member Functions inherited from KODI::KEYBOARD::IKeyboardInputProvider
virtual ~IKeyboardInputProvider ()=default
 
- Public Member Functions inherited from KODI::MOUSE::IMouseInputProvider
virtual ~IMouseInputProvider ()=default
 
- Public Member Functions inherited from KODI::JOYSTICK::IDriverReceiver
virtual ~IDriverReceiver ()=default
 

Protected Member Functions

void InitializeDeadzoneFiltering (KODI::JOYSTICK::IButtonMap &buttonMap)
 
void InitializeControllerProfile (KODI::JOYSTICK::IButtonMap &buttonMap)
 
void PowerOff ()
 
KODI::GAME::ControllerPtr InstallAsync (const std::string &controllerId)
 
- Protected Member Functions inherited from PERIPHERALS::CPeripheral
virtual void ClearSettings (void)
 

Static Protected Member Functions

static bool InstallSync (const std::string &controllerId)
 

Protected Attributes

std::string m_strProvider
 
int m_requestedPort {JOYSTICK_NO_PORT_REQUESTED}
 
unsigned int m_buttonCount = 0
 
unsigned int m_hatCount = 0
 
unsigned int m_axisCount = 0
 
unsigned int m_motorCount = 0
 
bool m_supportsPowerOff = false
 
CDateTime m_lastActive
 
std::queue< std::string > m_controllersToInstall
 
std::vector< std::future< void > > m_installTasks
 
std::unique_ptr< KODI::KEYMAP::CKeymapHandlingm_appInput
 
std::unique_ptr< KODI::JOYSTICK::CRumbleGeneratorm_rumbleGenerator
 
std::unique_ptr< KODI::JOYSTICK::IInputHandlerm_joystickMonitor
 
std::unique_ptr< KODI::JOYSTICK::IButtonMapm_buttonMap
 
std::unique_ptr< KODI::JOYSTICK::CDeadzoneFilterm_deadzoneFilter
 
std::vector< DriverHandlerm_driverHandlers
 
CCriticalSection m_handlerMutex
 
CCriticalSection m_controllerInstallMutex
 
- Protected Attributes inherited from PERIPHERALS::CPeripheral
CPeripheralsm_manager
 
PeripheralType m_type
 
PeripheralBusType m_busType
 
PeripheralBusType m_mappedBusType
 
std::string m_strLocation
 
std::string m_strDeviceName
 
std::string m_strSettingsFile
 
std::string m_strFileLocation
 
int m_iVendorId
 
std::string m_strVendorId
 
int m_iProductId
 
std::string m_strProductId
 
std::string m_strVersionInfo
 
bool m_bInitialised = false
 
bool m_bHidden = false
 
bool m_bError = false
 
std::vector< PeripheralFeaturem_features
 
PeripheralVector m_subDevices
 
std::map< std::string, PeripheralDeviceSettingm_settings
 
std::set< std::string > m_changedSettings
 
CPeripheralBusm_bus
 
std::map< KODI::JOYSTICK::IInputHandler *, std::unique_ptr< KODI::JOYSTICK::IDriverHandler > > m_inputHandlers
 
std::map< KODI::KEYBOARD::IKeyboardInputHandler *, std::unique_ptr< KODI::KEYBOARD::IKeyboardDriverHandler > > m_keyboardHandlers
 
std::map< KODI::MOUSE::IMouseInputHandler *, std::unique_ptr< KODI::MOUSE::IMouseDriverHandler > > m_mouseHandlers
 
std::map< KODI::JOYSTICK::IButtonMapper *, std::unique_ptr< CAddonButtonMapping > > m_buttonMappers
 
KODI::GAME::ControllerPtr m_controllerProfile
 

Constructor & Destructor Documentation

◆ CPeripheralJoystick()

CPeripheralJoystick::CPeripheralJoystick ( CPeripherals & manager,
const PeripheralScanResult & scanResult,
CPeripheralBus * bus )

◆ ~CPeripheralJoystick()

CPeripheralJoystick::~CPeripheralJoystick ( void )
override

Member Function Documentation

◆ AxisCount()

unsigned int PERIPHERALS::CPeripheralJoystick::AxisCount ( void ) const
inline

◆ ButtonCount()

unsigned int PERIPHERALS::CPeripheralJoystick::ButtonCount ( void ) const
inline

Get the number of elements reported by the driver.

◆ ControllerProfile()

GAME::ControllerPtr CPeripheralJoystick::ControllerProfile ( ) const
overridevirtual

Get the controller profile that best represents this peripheral.

Returns
The controller profile, or empty if unknown

Reimplemented from PERIPHERALS::CPeripheral.

◆ GetDriverReceiver()

KODI::JOYSTICK::IDriverReceiver * PERIPHERALS::CPeripheralJoystick::GetDriverReceiver ( )
inlineoverridevirtual

Reimplemented from PERIPHERALS::CPeripheral.

◆ GetKeymap()

KEYMAP::IKeymap * CPeripheralJoystick::GetKeymap ( const std::string & controllerId)
overridevirtual

Reimplemented from PERIPHERALS::CPeripheral.

◆ HatCount()

unsigned int PERIPHERALS::CPeripheralJoystick::HatCount ( void ) const
inline

◆ InitialiseFeature()

bool CPeripheralJoystick::InitialiseFeature ( const PeripheralFeature feature)
overridevirtual

Initialise one of the features of this peripheral.

Parameters
featureThe feature to initialise.
Returns
True when the feature has been initialised successfully, false otherwise.

Reimplemented from PERIPHERALS::CPeripheral.

◆ InitializeControllerProfile()

void CPeripheralJoystick::InitializeControllerProfile ( KODI::JOYSTICK::IButtonMap & buttonMap)
protected

◆ InitializeDeadzoneFiltering()

void CPeripheralJoystick::InitializeDeadzoneFiltering ( KODI::JOYSTICK::IButtonMap & buttonMap)
protected

◆ InstallAsync()

GAME::ControllerPtr CPeripheralJoystick::InstallAsync ( const std::string & controllerId)
protected

◆ InstallSync()

bool CPeripheralJoystick::InstallSync ( const std::string & controllerId)
staticprotected

◆ LastActive()

CDateTime PERIPHERALS::CPeripheralJoystick::LastActive ( ) const
inlineoverridevirtual

Return the last time this peripheral was active.

Returns
The time of last activation, or invalid if unknown/never active

Reimplemented from PERIPHERALS::CPeripheral.

◆ MotorCount()

unsigned int PERIPHERALS::CPeripheralJoystick::MotorCount ( void ) const
inline

◆ OnAxisMotion()

bool CPeripheralJoystick::OnAxisMotion ( unsigned int axisIndex,
float position )

◆ OnButtonMotion()

bool CPeripheralJoystick::OnButtonMotion ( unsigned int buttonIndex,
bool bPressed )

◆ OnHatMotion()

bool CPeripheralJoystick::OnHatMotion ( unsigned int hatIndex,
KODI::JOYSTICK::HAT_STATE state )

◆ OnInputFrame()

void CPeripheralJoystick::OnInputFrame ( void )

◆ OnUserNotification()

void CPeripheralJoystick::OnUserNotification ( )
overridevirtual

Briefly activate a feature to notify the user.

Reimplemented from PERIPHERALS::CPeripheral.

◆ PowerOff()

void CPeripheralJoystick::PowerOff ( )
protected

◆ Provider()

const std::string & PERIPHERALS::CPeripheralJoystick::Provider ( void ) const
inline

Get the name of the driver or API providing this joystick.

◆ RegisterJoystickDriverHandler()

void CPeripheralJoystick::RegisterJoystickDriverHandler ( KODI::JOYSTICK::IDriverHandler * handler,
bool bPromiscuous )
overridevirtual

Reimplemented from PERIPHERALS::CPeripheral.

◆ RequestedPort()

int PERIPHERALS::CPeripheralJoystick::RequestedPort ( void ) const
inline

Get the specific port number requested by this joystick.

This could indicate that the joystick is connected to a hardware port with a number label; some controllers, such as the Xbox 360 controller, also have LEDs that indicate the controller is on a specific port.

Returns
The 0-indexed port number, or JOYSTICK_PORT_UNKNOWN if no port is requested

◆ SetAxisCount()

void PERIPHERALS::CPeripheralJoystick::SetAxisCount ( unsigned int axisCount)
inline

◆ SetButtonCount()

void PERIPHERALS::CPeripheralJoystick::SetButtonCount ( unsigned int buttonCount)
inline

◆ SetControllerProfile()

void CPeripheralJoystick::SetControllerProfile ( const KODI::GAME::ControllerPtr & controller)
overridevirtual

Set the controller profile for this peripheral.

Parameters
controllerThe new controller profile

Reimplemented from PERIPHERALS::CPeripheral.

◆ SetHatCount()

void PERIPHERALS::CPeripheralJoystick::SetHatCount ( unsigned int hatCount)
inline

◆ SetMotorCount()

void CPeripheralJoystick::SetMotorCount ( unsigned int motorCount)

◆ SetMotorState()

bool CPeripheralJoystick::SetMotorState ( unsigned int motorIndex,
float magnitude )
overridevirtual

Set the value of a rumble motor.

Parameters
motorIndexThe driver index of the motor to rumble
magnitudeThe motor's new magnitude of vibration in the closed interval [0, 1]
Returns
True if the event was handled otherwise false

Implements KODI::JOYSTICK::IDriverReceiver.

◆ SetProvider()

void PERIPHERALS::CPeripheralJoystick::SetProvider ( const std::string & provider)
inline

Set joystick properties.

◆ SetRequestedPort()

void PERIPHERALS::CPeripheralJoystick::SetRequestedPort ( int port)
inline

◆ SetSupportsPowerOff()

void CPeripheralJoystick::SetSupportsPowerOff ( bool bSupportsPowerOff)

◆ SupportsPowerOff()

bool PERIPHERALS::CPeripheralJoystick::SupportsPowerOff ( void ) const
inline

◆ TestFeature()

bool CPeripheralJoystick::TestFeature ( PeripheralFeature feature)
overridevirtual

Briefly test one of the features of this peripheral.

Parameters
featureThe feature to test.
Returns
True if the test succeeded, false otherwise.

Reimplemented from PERIPHERALS::CPeripheral.

◆ UnregisterJoystickDriverHandler()

void CPeripheralJoystick::UnregisterJoystickDriverHandler ( KODI::JOYSTICK::IDriverHandler * handler)
overridevirtual

Reimplemented from PERIPHERALS::CPeripheral.

Member Data Documentation

◆ m_appInput

std::unique_ptr<KODI::KEYMAP::CKeymapHandling> PERIPHERALS::CPeripheralJoystick::m_appInput
protected

◆ m_axisCount

unsigned int PERIPHERALS::CPeripheralJoystick::m_axisCount = 0
protected

◆ m_buttonCount

unsigned int PERIPHERALS::CPeripheralJoystick::m_buttonCount = 0
protected

◆ m_buttonMap

std::unique_ptr<KODI::JOYSTICK::IButtonMap> PERIPHERALS::CPeripheralJoystick::m_buttonMap
protected

◆ m_controllerInstallMutex

CCriticalSection PERIPHERALS::CPeripheralJoystick::m_controllerInstallMutex
protected

◆ m_controllersToInstall

std::queue<std::string> PERIPHERALS::CPeripheralJoystick::m_controllersToInstall
protected

◆ m_deadzoneFilter

std::unique_ptr<KODI::JOYSTICK::CDeadzoneFilter> PERIPHERALS::CPeripheralJoystick::m_deadzoneFilter
protected

◆ m_driverHandlers

std::vector<DriverHandler> PERIPHERALS::CPeripheralJoystick::m_driverHandlers
protected

◆ m_handlerMutex

CCriticalSection PERIPHERALS::CPeripheralJoystick::m_handlerMutex
protected

◆ m_hatCount

unsigned int PERIPHERALS::CPeripheralJoystick::m_hatCount = 0
protected

◆ m_installTasks

std::vector<std::future<void> > PERIPHERALS::CPeripheralJoystick::m_installTasks
protected

◆ m_joystickMonitor

std::unique_ptr<KODI::JOYSTICK::IInputHandler> PERIPHERALS::CPeripheralJoystick::m_joystickMonitor
protected

◆ m_lastActive

CDateTime PERIPHERALS::CPeripheralJoystick::m_lastActive
protected

◆ m_motorCount

unsigned int PERIPHERALS::CPeripheralJoystick::m_motorCount = 0
protected

◆ m_requestedPort

int PERIPHERALS::CPeripheralJoystick::m_requestedPort {JOYSTICK_NO_PORT_REQUESTED}
protected

◆ m_rumbleGenerator

std::unique_ptr<KODI::JOYSTICK::CRumbleGenerator> PERIPHERALS::CPeripheralJoystick::m_rumbleGenerator
protected

◆ m_strProvider

std::string PERIPHERALS::CPeripheralJoystick::m_strProvider
protected

◆ m_supportsPowerOff

bool PERIPHERALS::CPeripheralJoystick::m_supportsPowerOff = false
protected

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