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

Handles game controller events for games. More...

#include <GameClientJoystick.h>

Inheritance diagram for KODI::GAME::CGameClientJoystick:
KODI::JOYSTICK::IInputHandler

Public Member Functions

 CGameClientJoystick (CGameClient &addon, const std::string &portAddress, const ControllerPtr &controller)
 Constructor.
 
 ~CGameClientJoystick () override
 
void RegisterInput (JOYSTICK::IInputProvider *inputProvider)
 
void UnregisterInput (JOYSTICK::IInputProvider *inputProvider)
 
std::string ControllerID () const override
 The add-on ID of the game controller associated with this input handler.
 
bool HasFeature (const std::string &feature) const override
 Return true if the input handler accepts the given feature.
 
bool AcceptsInput (const std::string &feature) const override
 Return true if the input handler is currently accepting input for the given feature.
 
bool OnButtonPress (const std::string &feature, bool bPressed) override
 A digital button has been pressed or released.
 
void OnButtonHold (const std::string &feature, unsigned int holdTimeMs) override
 A digital button has been pressed for more than one event frame.
 
bool OnButtonMotion (const std::string &feature, float magnitude, unsigned int motionTimeMs) override
 An analog button (trigger or a pressure-sensitive button) has changed state.
 
bool OnAnalogStickMotion (const std::string &feature, float x, float y, unsigned int motionTimeMs) override
 An analog stick has moved.
 
bool OnAccelerometerMotion (const std::string &feature, float x, float y, float z) override
 An accelerometer's state has changed.
 
bool OnWheelMotion (const std::string &feature, float position, unsigned int motionTimeMs) override
 A wheel has changed state.
 
bool OnThrottleMotion (const std::string &feature, float position, unsigned int motionTimeMs) override
 A throttle has changed state.
 
void OnInputFrame () override
 Called at the end of the frame that provided input.
 
const std::string & GetPortAddress () const
 
ControllerPtr GetController () const
 
std::string GetControllerAddress () const
 
PERIPHERALS::PeripheralPtr GetSource () const
 
std::string GetSourceLocation () const
 
float GetActivation () const
 
void SetSource (PERIPHERALS::PeripheralPtr sourcePeripheral)
 
void ClearSource ()
 
bool SetRumble (const std::string &feature, float magnitude)
 
- Public Member Functions inherited from KODI::JOYSTICK::IInputHandler
virtual ~IInputHandler ()=default
 
void SetInputReceiver (IInputReceiver *receiver)
 
void ResetInputReceiver (void)
 
IInputReceiverInputReceiver (void)
 

Detailed Description

Handles game controller events for games.

Listens to game controller events and forwards them to the games (as game_input_event).

Constructor & Destructor Documentation

◆ CGameClientJoystick()

CGameClientJoystick::CGameClientJoystick ( CGameClient & addon,
const std::string & portAddress,
const ControllerPtr & controller )

Constructor.

Parameters
addonThe game client implementation.
portThe port this game controller is associated with.
controllerThe game controller which is used (for controller mapping).
dllStructThe emulator or game to which the events are sent.

◆ ~CGameClientJoystick()

CGameClientJoystick::~CGameClientJoystick ( )
overridedefault

Member Function Documentation

◆ AcceptsInput()

bool CGameClientJoystick::AcceptsInput ( const std::string & feature) const
overridevirtual

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.

Implements KODI::JOYSTICK::IInputHandler.

◆ ClearSource()

void CGameClientJoystick::ClearSource ( )

◆ ControllerID()

std::string CGameClientJoystick::ControllerID ( ) const
overridevirtual

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

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

Implements KODI::JOYSTICK::IInputHandler.

◆ GetActivation()

float CGameClientJoystick::GetActivation ( ) const

◆ GetController()

ControllerPtr KODI::GAME::CGameClientJoystick::GetController ( ) const
inline

◆ GetControllerAddress()

std::string CGameClientJoystick::GetControllerAddress ( ) const

◆ GetPortAddress()

const std::string & KODI::GAME::CGameClientJoystick::GetPortAddress ( ) const
inline

◆ GetSource()

PERIPHERALS::PeripheralPtr KODI::GAME::CGameClientJoystick::GetSource ( ) const
inline

◆ GetSourceLocation()

std::string CGameClientJoystick::GetSourceLocation ( ) const

◆ HasFeature()

bool CGameClientJoystick::HasFeature ( const std::string & feature) const
overridevirtual

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

Implements KODI::JOYSTICK::IInputHandler.

◆ OnAccelerometerMotion()

bool CGameClientJoystick::OnAccelerometerMotion ( const std::string & feature,
float x,
float y,
float z )
overridevirtual

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 from KODI::JOYSTICK::IInputHandler.

◆ OnAnalogStickMotion()

bool CGameClientJoystick::OnAnalogStickMotion ( const std::string & feature,
float x,
float y,
unsigned int motionTimeMs )
overridevirtual

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

Implements KODI::JOYSTICK::IInputHandler.

◆ OnButtonHold()

void KODI::GAME::CGameClientJoystick::OnButtonHold ( const std::string & feature,
unsigned int holdTimeMs )
inlineoverridevirtual

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.

Implements KODI::JOYSTICK::IInputHandler.

◆ OnButtonMotion()

bool CGameClientJoystick::OnButtonMotion ( const std::string & feature,
float magnitude,
unsigned int motionTimeMs )
overridevirtual

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

Implements KODI::JOYSTICK::IInputHandler.

◆ OnButtonPress()

bool CGameClientJoystick::OnButtonPress ( const std::string & feature,
bool bPressed )
overridevirtual

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

Implements KODI::JOYSTICK::IInputHandler.

◆ OnInputFrame()

void KODI::GAME::CGameClientJoystick::OnInputFrame ( )
inlineoverridevirtual

Called at the end of the frame that provided input.

Implements KODI::JOYSTICK::IInputHandler.

◆ OnThrottleMotion()

bool CGameClientJoystick::OnThrottleMotion ( const std::string & feature,
float position,
unsigned int motionTimeMs )
overridevirtual

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

Implements KODI::JOYSTICK::IInputHandler.

◆ OnWheelMotion()

bool CGameClientJoystick::OnWheelMotion ( const std::string & feature,
float position,
unsigned int motionTimeMs )
overridevirtual

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

Implements KODI::JOYSTICK::IInputHandler.

◆ RegisterInput()

void CGameClientJoystick::RegisterInput ( JOYSTICK::IInputProvider * inputProvider)

◆ SetRumble()

bool CGameClientJoystick::SetRumble ( const std::string & feature,
float magnitude )

◆ SetSource()

void CGameClientJoystick::SetSource ( PERIPHERALS::PeripheralPtr sourcePeripheral)

◆ UnregisterInput()

void CGameClientJoystick::UnregisterInput ( JOYSTICK::IInputProvider * inputProvider)

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