Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
KODI::JOYSTICK::IInputHandler Class Referenceabstract

Interface for handling input events for game controllers. More...

#include <IInputHandler.h>

Inheritance diagram for KODI::JOYSTICK::IInputHandler:
KODI::GAME::CAgentJoystick KODI::GAME::CGameClientJoystick KODI::GAME::CInputSink KODI::GAME::CPortInput KODI::JOYSTICK::CJoystickMonitor KODI::KEYMAP::CKeymapHandler

Public Member Functions

virtual ~IInputHandler ()=default
 
virtual std::string ControllerID (void) const =0
 The add-on ID of the game controller associated with this input handler.
 
virtual bool HasFeature (const FeatureName &feature) const =0
 Return true if the input handler accepts the given feature.
 
virtual bool AcceptsInput (const FeatureName &feature) const =0
 Return true if the input handler is currently accepting input for the given feature.
 
virtual bool OnButtonPress (const FeatureName &feature, bool bPressed)=0
 A digital button has been pressed or released.
 
virtual void OnButtonHold (const FeatureName &feature, unsigned int holdTimeMs)=0
 A digital button has been pressed for more than one event frame.
 
virtual bool OnButtonMotion (const FeatureName &feature, float magnitude, unsigned int motionTimeMs)=0
 An analog button (trigger or a pressure-sensitive button) has changed state.
 
virtual bool OnAnalogStickMotion (const FeatureName &feature, float x, float y, unsigned int motionTimeMs)=0
 An analog stick has moved.
 
virtual bool OnAccelerometerMotion (const FeatureName &feature, float x, float y, float z)
 An accelerometer's state has changed.
 
virtual bool OnWheelMotion (const FeatureName &feature, float position, unsigned int motionTimeMs)=0
 A wheel has changed state.
 
virtual bool OnThrottleMotion (const FeatureName &feature, float position, unsigned int motionTimeMs)=0
 A throttle has changed state.
 
virtual void OnInputFrame ()=0
 Called at the end of the frame that provided input.
 
void SetInputReceiver (IInputReceiver *receiver)
 
void ResetInputReceiver (void)
 
IInputReceiverInputReceiver (void)
 

Detailed Description

Interface for handling input events for game controllers.

Constructor & Destructor Documentation

◆ ~IInputHandler()

virtual KODI::JOYSTICK::IInputHandler::~IInputHandler ( )
virtualdefault

Member Function Documentation

◆ AcceptsInput()

virtual bool KODI::JOYSTICK::IInputHandler::AcceptsInput ( const FeatureName & feature) const
pure virtual

Return true if the input handler is currently accepting input for the given feature.

Parameters
featureA feature belonging to the controller specified by ControllerID()
Returns
True if the feature is currently accepting input, false otherwise

This does not prevent the input events from being called, but can return false to indicate that input wasn't handled for the specified feature.

Implemented in KODI::JOYSTICK::CJoystickMonitor, KODI::KEYMAP::CKeymapHandler, KODI::GAME::CGameClientJoystick, KODI::GAME::CAgentJoystick, KODI::GAME::CInputSink, and KODI::GAME::CPortInput.

◆ ControllerID()

virtual std::string KODI::JOYSTICK::IInputHandler::ControllerID ( void ) const
pure virtual

The add-on ID of the game controller associated with this input handler.

Returns
The ID of the add-on extending kodi.game.controller

Implemented in KODI::GAME::CGameClientJoystick, KODI::GAME::CAgentJoystick, KODI::GAME::CInputSink, KODI::GAME::CPortInput, KODI::JOYSTICK::CJoystickMonitor, and KODI::KEYMAP::CKeymapHandler.

◆ HasFeature()

virtual bool KODI::JOYSTICK::IInputHandler::HasFeature ( const FeatureName & feature) const
pure virtual

Return true if the input handler accepts the given feature.

Parameters
featureA feature belonging to the controller specified by ControllerID()
Returns
True if the feature is used for input, false otherwise

Implemented in KODI::JOYSTICK::CJoystickMonitor, KODI::KEYMAP::CKeymapHandler, KODI::GAME::CGameClientJoystick, KODI::GAME::CAgentJoystick, KODI::GAME::CInputSink, and KODI::GAME::CPortInput.

◆ InputReceiver()

IInputReceiver * KODI::JOYSTICK::IInputHandler::InputReceiver ( void )
inline

◆ OnAccelerometerMotion()

virtual bool KODI::JOYSTICK::IInputHandler::OnAccelerometerMotion ( const FeatureName & feature,
float x,
float y,
float z )
inlinevirtual

An accelerometer's state has changed.

Parameters
featureThe accelerometer being accelerated
xThe x coordinate in the closed interval [-1, 1]
yThe y coordinate in the closed interval [-1, 1]
zThe z coordinate in the closed interval [-1, 1]
Returns
True if the event was handled otherwise false

Reimplemented in KODI::JOYSTICK::CJoystickMonitor, KODI::KEYMAP::CKeymapHandler, KODI::GAME::CGameClientJoystick, KODI::GAME::CAgentJoystick, KODI::GAME::CInputSink, and KODI::GAME::CPortInput.

◆ OnAnalogStickMotion()

virtual bool KODI::JOYSTICK::IInputHandler::OnAnalogStickMotion ( const FeatureName & feature,
float x,
float y,
unsigned int motionTimeMs )
pure virtual

An analog stick has moved.

Parameters
featureThe analog stick being moved
xThe x coordinate in the closed interval [-1, 1]
yThe y coordinate in the closed interval [-1, 1]
motionTimeMsThe time elapsed since this analog stick was centered, or 0 if the analog stick is centered
Returns
True if the event was handled otherwise false

Implemented in KODI::JOYSTICK::CJoystickMonitor, KODI::KEYMAP::CKeymapHandler, KODI::GAME::CGameClientJoystick, KODI::GAME::CAgentJoystick, KODI::GAME::CInputSink, and KODI::GAME::CPortInput.

◆ OnButtonHold()

virtual void KODI::JOYSTICK::IInputHandler::OnButtonHold ( const FeatureName & feature,
unsigned int holdTimeMs )
pure virtual

A digital button has been pressed for more than one event frame.

Parameters
featureThe feature being held
holdTimeMsThe time elapsed since the initial press (ms)

If OnButtonPress() returns true for the initial press, then this callback is invoked on subsequent frames until the button is released.

Implemented in KODI::JOYSTICK::CJoystickMonitor, KODI::KEYMAP::CKeymapHandler, KODI::GAME::CGameClientJoystick, KODI::GAME::CAgentJoystick, KODI::GAME::CInputSink, and KODI::GAME::CPortInput.

◆ OnButtonMotion()

virtual bool KODI::JOYSTICK::IInputHandler::OnButtonMotion ( const FeatureName & feature,
float magnitude,
unsigned int motionTimeMs )
pure virtual

An analog button (trigger or a pressure-sensitive button) has changed state.

Parameters
featureThe feature changing state
magnitudeThe button pressure or trigger travel distance in the closed interval [0, 1]
motionTimeMsThe time elapsed since the magnitude was 0
Returns
True if the event was handled otherwise false

Implemented in KODI::JOYSTICK::CJoystickMonitor, KODI::KEYMAP::CKeymapHandler, KODI::GAME::CGameClientJoystick, KODI::GAME::CAgentJoystick, KODI::GAME::CInputSink, and KODI::GAME::CPortInput.

◆ OnButtonPress()

virtual bool KODI::JOYSTICK::IInputHandler::OnButtonPress ( const FeatureName & feature,
bool bPressed )
pure virtual

A digital button has been pressed or released.

Parameters
featureThe feature being pressed
bPressedTrue if pressed, false if released
Returns
True if the event was handled otherwise false

Implemented in KODI::JOYSTICK::CJoystickMonitor, KODI::KEYMAP::CKeymapHandler, KODI::GAME::CGameClientJoystick, KODI::GAME::CAgentJoystick, KODI::GAME::CInputSink, and KODI::GAME::CPortInput.

◆ OnInputFrame()

virtual void KODI::JOYSTICK::IInputHandler::OnInputFrame ( )
pure virtual

◆ OnThrottleMotion()

virtual bool KODI::JOYSTICK::IInputHandler::OnThrottleMotion ( const FeatureName & feature,
float position,
unsigned int motionTimeMs )
pure virtual

A throttle has changed state.

Up is positive position, down is negative position.

Parameters
featureThe wheel changing state
positionThe position in the closed interval [-1, 1]
motionTimeMsThe time elapsed since the position was 0
Returns
True if the event was handled otherwise false

Implemented in KODI::JOYSTICK::CJoystickMonitor, KODI::KEYMAP::CKeymapHandler, KODI::GAME::CGameClientJoystick, KODI::GAME::CAgentJoystick, KODI::GAME::CInputSink, and KODI::GAME::CPortInput.

◆ OnWheelMotion()

virtual bool KODI::JOYSTICK::IInputHandler::OnWheelMotion ( const FeatureName & feature,
float position,
unsigned int motionTimeMs )
pure virtual

A wheel has changed state.

Left is negative position, right is positive position

Parameters
featureThe wheel changing state
positionThe position in the closed interval [-1, 1]
motionTimeMsThe time elapsed since the position was 0
Returns
True if the event was handled otherwise false

Implemented in KODI::JOYSTICK::CJoystickMonitor, KODI::KEYMAP::CKeymapHandler, KODI::GAME::CGameClientJoystick, KODI::GAME::CAgentJoystick, KODI::GAME::CInputSink, and KODI::GAME::CPortInput.

◆ ResetInputReceiver()

void KODI::JOYSTICK::IInputHandler::ResetInputReceiver ( void )
inline

◆ SetInputReceiver()

void KODI::JOYSTICK::IInputHandler::SetInputReceiver ( IInputReceiver * receiver)
inline

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