10 #include "games/GameTypes.h" 11 #include "input/keyboard/interfaces/IKeyboardDriverHandler.h" 12 #include "input/mouse/interfaces/IMouseDriverHandler.h" 13 #include "peripherals/PeripheralTypes.h" 14 #include "utils/Observer.h" 39 class CGameClientJoystick;
71 void Notify(
const Observable& obs,
const ObservableMessage msg)
override;
74 bool OnKeyPress(
const CKey& key)
override;
78 bool OnPosition(
int x,
int y)
override;
79 bool OnButtonPress(MOUSE::BUTTON_ID button)
override;
85 std::vector<std::string> GetInputPorts()
const;
86 float GetPortActivation(
const std::string& address)
const;
87 float GetPeripheralActivation(
const std::string& peripheralLocation)
const;
91 using PortAddress = std::string;
92 using JoystickMap = std::map<PortAddress, std::shared_ptr<CGameClientJoystick>>;
93 using PortMap = std::map<JOYSTICK::IInputProvider*, std::shared_ptr<CGameClientJoystick>>;
95 using PeripheralLocation = std::string;
96 using CurrentPortMap = std::map<PortAddress, PeripheralLocation>;
97 using CurrentPeripheralMap = std::map<PeripheralLocation, PortAddress>;
99 using ControllerAddress = std::string;
100 using PeripheralMap = std::map<ControllerAddress, PERIPHERALS::PeripheralPtr>;
103 void ProcessJoysticks(PERIPHERALS::EventLockHandlePtr& inputHandlingLock);
104 void ProcessKeyboard();
108 void ProcessAgents(
const PERIPHERALS::PeripheralVector& joysticks,
109 PERIPHERALS::EventLockHandlePtr& inputHandlingLock);
110 void UpdateExpiredJoysticks(
const PERIPHERALS::PeripheralVector& joysticks,
111 PERIPHERALS::EventLockHandlePtr& inputHandlingLock);
112 void UpdateConnectedJoysticks(
const PERIPHERALS::PeripheralVector& joysticks,
113 const PortMap& newPortMap,
114 PERIPHERALS::EventLockHandlePtr& inputHandlingLock,
115 std::set<PERIPHERALS::PeripheralPtr>& disconnectedJoysticks);
118 static PortMap MapJoysticks(
const PERIPHERALS::PeripheralVector& peripheralJoysticks,
119 const JoystickMap& gameClientjoysticks,
120 CurrentPortMap& currentPorts,
121 CurrentPeripheralMap& currentPeripherals,
123 static void MapJoystick(PERIPHERALS::PeripheralPtr peripheralJoystick,
124 std::shared_ptr<CGameClientJoystick> gameClientJoystick,
126 static void LogPeripheralMap(
const PeripheralMap& peripheralMap,
127 const std::set<PERIPHERALS::PeripheralPtr>& disconnectedPeripherals);
135 bool m_bHasKeyboard =
false;
136 bool m_bHasMouse =
false;
140 mutable std::mutex m_agentMutex;
161 CurrentPortMap m_currentPorts;
168 CurrentPeripheralMap m_currentPeripherals;
175 PeripheralMap m_peripheralMap;
182 std::set<PERIPHERALS::PeripheralPtr> m_disconnectedPeripherals;
std::vector< GameAgentPtr > GameAgentVec
Vector of smart pointers to game-playing agents (CGameAgent)
Definition: GameTypes.h:78
Definition: RetroPlayerInput.h:15
Class to manage game-playing agents for a running game client.
Definition: GameAgentManager.h:55
void OnKeyRelease(const CKey &key) override
A key has been released.
Definition: GameAgentManager.h:75
Definition: AudioDecoder.h:18
Definition: Observer.h:31
std::shared_ptr< CGameClient > GameClientPtr
Smart pointer to a game client (CGameClient)
Definition: GameTypes.h:29
Interface for handling mouse driver events.
Definition: IMouseDriverHandler.h:21
void OnButtonRelease(MOUSE::BUTTON_ID button) override
A mouse button has been released.
Definition: GameAgentManager.h:80
Interface for handling keyboard events.
Definition: IKeyboardDriverHandler.h:21
Definition: Observer.h:44
Definition: Peripherals.h:53