10 #include "AgentController.h" 11 #include "games/GameTypes.h" 12 #include "input/keyboard/interfaces/IKeyboardDriverHandler.h" 13 #include "input/mouse/interfaces/IMouseDriverHandler.h" 14 #include "peripherals/PeripheralTypes.h" 15 #include "utils/Observer.h" 39 class IKeyboardInputProvider;
43 class IMouseInputProvider;
49 class CGameClientJoystick;
81 void Notify(
const Observable& obs,
const ObservableMessage msg)
override;
84 bool OnKeyPress(
const CKey& key)
override;
88 bool OnPosition(
int x,
int y)
override;
93 std::vector<std::shared_ptr<const CAgentController>> GetControllers()
const;
97 std::vector<std::string> GetGameInputPorts()
const;
98 float GetGamePortActivation(
const std::string& address)
const;
99 float GetPeripheralActivation(
const std::string& peripheralLocation)
const;
103 using PortAddress = std::string;
104 using JoystickMap = std::map<PortAddress, std::shared_ptr<CGameClientJoystick>>;
105 using PortMap = std::map<JOYSTICK::IInputProvider*, std::shared_ptr<CGameClientJoystick>>;
107 using PeripheralLocation = std::string;
108 using CurrentPortMap = std::map<PortAddress, PeripheralLocation>;
109 using CurrentPeripheralMap = std::map<PeripheralLocation, PortAddress>;
111 using ControllerAddress = std::string;
112 using PeripheralMap = std::map<ControllerAddress, PERIPHERALS::PeripheralPtr>;
115 void ProcessJoysticks(PERIPHERALS::EventLockHandlePtr& inputHandlingLock);
116 void ProcessKeyboard();
120 void ProcessAgentControllers(
const PERIPHERALS::PeripheralVector& joysticks,
121 PERIPHERALS::EventLockHandlePtr& inputHandlingLock);
122 void UpdateExpiredJoysticks(
const PERIPHERALS::PeripheralVector& joysticks,
123 PERIPHERALS::EventLockHandlePtr& inputHandlingLock);
124 void UpdateConnectedJoysticks(
const PERIPHERALS::PeripheralVector& joysticks,
125 const PortMap& newPortMap,
126 PERIPHERALS::EventLockHandlePtr& inputHandlingLock,
127 std::set<PERIPHERALS::PeripheralPtr>& disconnectedJoysticks);
130 static PortMap MapJoysticks(
const PERIPHERALS::PeripheralVector& peripheralJoysticks,
131 const JoystickMap& gameClientjoysticks,
132 CurrentPortMap& currentPorts,
133 CurrentPeripheralMap& currentPeripherals,
135 static void MapJoystick(PERIPHERALS::PeripheralPtr peripheralJoystick,
136 std::shared_ptr<CGameClientJoystick> gameClientJoystick,
138 static void LogPeripheralMap(
const PeripheralMap& peripheralMap,
139 const std::set<PERIPHERALS::PeripheralPtr>& disconnectedPeripherals);
147 bool m_bHasKeyboard =
false;
148 bool m_bHasMouse =
false;
149 int m_initialMouseX{-1};
150 int m_initialMouseY{-1};
151 std::vector<std::shared_ptr<CAgentController>> m_controllers;
154 mutable std::mutex m_controllerMutex;
173 std::map<KEYBOARD::IKeyboardInputProvider*, PortAddress> m_keyboardPort;
178 std::map<MOUSE::IMouseInputProvider*, PortAddress> m_mousePort;
185 CurrentPortMap m_currentPorts;
192 CurrentPeripheralMap m_currentPeripherals;
199 PeripheralMap m_peripheralMap;
206 std::set<PERIPHERALS::PeripheralPtr> m_disconnectedPeripherals;
BUTTON_ID
Buttons on a mouse.
Definition: MouseTypes.h:26
Definition: RetroPlayerInput.h:15
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:22
Interface for handling keyboard events.
Definition: IKeyboardDriverHandler.h:22
Definition: Observer.h:44
Definition: Peripherals.h:56