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

Class to manage game-playing agents for a running game client. More...

#include <AgentInput.h>

Inheritance diagram for KODI::GAME::CAgentInput:
Observable Observer KODI::KEYBOARD::IKeyboardDriverHandler KODI::MOUSE::IMouseDriverHandler

Public Member Functions

 CAgentInput (PERIPHERALS::CPeripherals &peripheralManager, CInputManager &inputManager)
virtual ~CAgentInput ()
void Start (GameClientPtr gameClient)
void Stop ()
void Refresh ()
void Notify (const Observable &obs, const ObservableMessage msg) override
 Process a message from an observable.
bool OnKeyPress (const CKey &key) override
 A key has been pressed.
void OnKeyRelease (const CKey &key) override
 A key has been released.
bool OnPosition (int x, int y) override
 Handle mouse position updates.
bool OnButtonPress (MOUSE::BUTTON_ID button) override
 A mouse button has been pressed.
void OnButtonRelease (MOUSE::BUTTON_ID button) override
 A mouse button has been released.
std::vector< std::shared_ptr< const CAgentController > > GetControllers () const
std::string GetPortAddress (JOYSTICK::IInputProvider *inputProvider) const
std::string GetKeyboardAddress (KEYBOARD::IKeyboardInputProvider *inputProvider) const
std::string GetMouseAddress (MOUSE::IMouseInputProvider *inputProvider) const
std::vector< std::string > GetGameInputPorts () const
float GetGamePortActivation (const std::string &address) const
float GetPeripheralActivation (const std::string &peripheralLocation) const
- Public Member Functions inherited from Observable
 Observable ()=default
virtual ~Observable ()=default
Observableoperator= (const Observable &observable)
virtual void RegisterObserver (Observer *obs)
 Register an observer.
virtual void UnregisterObserver (Observer *obs)
 Unregister an observer.
virtual void NotifyObservers (const ObservableMessage message=ObservableMessageNone)
 Send a message to all observers when m_bObservableChanged is true.
virtual void SetChanged (bool bSetTo=true)
 Mark an observable changed.
virtual bool IsObserving (const Observer &obs) const
 Check whether this observable is being observed by an observer.
- Public Member Functions inherited from Observer
 Observer ()=default
virtual ~Observer ()=default

Additional Inherited Members

- Protected Member Functions inherited from Observable
void SendMessage (const ObservableMessage message)
 Send a message to all observer when m_bObservableChanged is true.
- Protected Attributes inherited from Observable
std::atomic< boolm_bObservableChanged {false}
std::vector< Observer * > m_observers
CCriticalSection m_obsCritSection

Detailed Description

Class to manage game-playing agents for a running game client.

Currently, port mapping is controller-based and does not take into account the human belonging to the controller. In the future, humans and possibly bots will be managed here.

To map ports to controllers, a list of controllers is retrieved in ProcessJoysticks(). After expired controllers are removed, the port mapping occurs in the static function MapJoysticks(). The strategy is to simply sort controllers by heuristics and greedily assign to game ports.

Constructor & Destructor Documentation

◆ CAgentInput()

CAgentInput::CAgentInput ( PERIPHERALS::CPeripherals & peripheralManager,
CInputManager & inputManager )

◆ ~CAgentInput()

CAgentInput::~CAgentInput ( )

Member Function Documentation

◆ GetControllers()

std::vector< std::shared_ptr< const CAgentController > > CAgentInput::GetControllers ( ) const

◆ GetGameInputPorts()

std::vector< std::string > CAgentInput::GetGameInputPorts ( ) const

◆ GetGamePortActivation()

float CAgentInput::GetGamePortActivation ( const std::string & address) const

◆ GetKeyboardAddress()

std::string CAgentInput::GetKeyboardAddress ( KEYBOARD::IKeyboardInputProvider * inputProvider) const

◆ GetMouseAddress()

std::string CAgentInput::GetMouseAddress ( MOUSE::IMouseInputProvider * inputProvider) const

◆ GetPeripheralActivation()

float CAgentInput::GetPeripheralActivation ( const std::string & peripheralLocation) const

◆ GetPortAddress()

std::string CAgentInput::GetPortAddress ( JOYSTICK::IInputProvider * inputProvider) const

◆ Notify()

void CAgentInput::Notify ( const Observable & obs,
const ObservableMessage msg )

Process a message from an observable.

obsThe observable that sends the message.
msgThe message.

Implements Observer.

◆ OnButtonPress()

bool CAgentInput::OnButtonPress ( MOUSE::BUTTON_ID button)

A mouse button has been pressed.

buttonThe index of the pressed button
True if the event was handled, otherwise false

Implements KODI::MOUSE::IMouseDriverHandler.

◆ OnButtonRelease()

void KODI::GAME::CAgentInput::OnButtonRelease ( MOUSE::BUTTON_ID button)

A mouse button has been released.

buttonThe index of the released button

Implements KODI::MOUSE::IMouseDriverHandler.

◆ OnKeyPress()

bool CAgentInput::OnKeyPress ( const CKey & key)

A key has been pressed.

keyThe pressed key
True if the event was handled, false otherwise

Implements KODI::KEYBOARD::IKeyboardDriverHandler.

◆ OnKeyRelease()

void KODI::GAME::CAgentInput::OnKeyRelease ( const CKey & key)

A key has been released.

keyThe released key

Implements KODI::KEYBOARD::IKeyboardDriverHandler.

◆ OnPosition()

bool CAgentInput::OnPosition ( int x,
int y )

Handle mouse position updates.

xThe new x coordinate of the pointer
yThe new y coordinate of the pointer

The mouse uses a left-handed (graphics) cartesian coordinate system. Positive X is right, positive Y is down.

True if the event was handled, false otherwise

Implements KODI::MOUSE::IMouseDriverHandler.

◆ Refresh()

void CAgentInput::Refresh ( )

◆ Start()

void CAgentInput::Start ( GameClientPtr gameClient)

◆ Stop()

void CAgentInput::Stop ( )

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