Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
|
Class to manage game-playing agents for a running game client. More...
#include <AgentInput.h>
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 |
Observable & | operator= (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< bool > | m_bObservableChanged {false} |
std::vector< Observer * > | m_observers |
CCriticalSection | m_obsCritSection |
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.
CAgentInput::CAgentInput | ( | PERIPHERALS::CPeripherals & | peripheralManager, |
CInputManager & | inputManager ) |
|
virtual |
std::vector< std::shared_ptr< const CAgentController > > CAgentInput::GetControllers | ( | ) | const |
std::vector< std::string > CAgentInput::GetGameInputPorts | ( | ) | const |
float CAgentInput::GetGamePortActivation | ( | const std::string & | address | ) | const |
std::string CAgentInput::GetKeyboardAddress | ( | KEYBOARD::IKeyboardInputProvider * | inputProvider | ) | const |
std::string CAgentInput::GetMouseAddress | ( | MOUSE::IMouseInputProvider * | inputProvider | ) | const |
float CAgentInput::GetPeripheralActivation | ( | const std::string & | peripheralLocation | ) | const |
std::string CAgentInput::GetPortAddress | ( | JOYSTICK::IInputProvider * | inputProvider | ) | const |
|
overridevirtual |
Process a message from an observable.
obs | The observable that sends the message. |
msg | The message. |
Implements Observer.
|
overridevirtual |
A mouse button has been pressed.
button | The index of the pressed button |
Implements KODI::MOUSE::IMouseDriverHandler.
|
inlineoverridevirtual |
A mouse button has been released.
button | The index of the released button |
Implements KODI::MOUSE::IMouseDriverHandler.
A key has been pressed.
key | The pressed key |
Implements KODI::KEYBOARD::IKeyboardDriverHandler.
A key has been released.
key | The released key |
Implements KODI::KEYBOARD::IKeyboardDriverHandler.
Handle mouse position updates.
x | The new x coordinate of the pointer |
y | The new y coordinate of the pointer |
The mouse uses a left-handed (graphics) cartesian coordinate system. Positive X is right, positive Y is down.
Implements KODI::MOUSE::IMouseDriverHandler.
void CAgentInput::Refresh | ( | ) |
void CAgentInput::Start | ( | GameClientPtr | gameClient | ) |
void CAgentInput::Stop | ( | ) |