#pragma once #include "stdafx.h" #include #include "GameConnection.h" #include "../Utilities/AutoResetEvent.h" #include "../Utilities/SimpleLock.h" #include "BaseControlDevice.h" #include "IInputProvider.h" #include "ControlDeviceState.h" class ClientConnectionData; class GameClientConnection : public GameConnection, public INotificationListener, public IInputProvider { private: std::deque _inputData[BaseControlDevice::PortCount]; atomic _inputSize[BaseControlDevice::PortCount]; AutoResetEvent _waitForInput[BaseControlDevice::PortCount]; SimpleLock _writeLock; atomic _shutdown; atomic _enableControllers; atomic _minimumQueueSize; vector _playerList; shared_ptr _controlDevice; shared_ptr _newControlDevice; ControlDeviceState _lastInputSent; bool _gameLoaded = false; uint8_t _controllerPort = GameConnection::SpectatorPort; private: void SendHandshake(); void SendControllerSelection(uint8_t port); void ClearInputData(); void PushControllerState(uint8_t port, ControlDeviceState state); void DisableControllers(); protected: void ProcessMessage(NetMessage* message) override; public: GameClientConnection(shared_ptr socket, shared_ptr connectionData); ~GameClientConnection(); void Shutdown(); void ProcessNotification(ConsoleNotificationType type, void* parameter) override; bool SetInput(BaseControlDevice *device) override; void InitControlDevice(); void SendInput(); void SelectController(uint8_t port); uint8_t GetAvailableControllers(); uint8_t GetControllerPort(); };