Mesen-X/Core/GameClientConnection.h

57 lines
1.6 KiB
C
Raw Normal View History

2014-07-06 20:40:33 -04:00
#pragma once
#include "stdafx.h"
#include <deque>
2014-07-06 20:40:33 -04:00
#include "GameConnection.h"
#include "../Utilities/AutoResetEvent.h"
#include "../Utilities/SimpleLock.h"
#include "BaseControlDevice.h"
#include "IInputProvider.h"
#include "ControlDeviceState.h"
class ClientConnectionData;
2014-07-06 20:40:33 -04:00
class GameClientConnection : public GameConnection, public INotificationListener, public IInputProvider
2014-07-06 20:40:33 -04:00
{
private:
std::deque<ControlDeviceState> _inputData[BaseControlDevice::PortCount];
atomic<uint32_t> _inputSize[BaseControlDevice::PortCount];
AutoResetEvent _waitForInput[BaseControlDevice::PortCount];
SimpleLock _writeLock;
atomic<bool> _shutdown;
2016-12-11 10:56:23 -05:00
atomic<bool> _enableControllers;
atomic<uint32_t> _minimumQueueSize;
vector<PlayerInfo> _playerList;
shared_ptr<BaseControlDevice> _controlDevice;
shared_ptr<BaseControlDevice> _newControlDevice;
ControlDeviceState _lastInputSent;
bool _gameLoaded = false;
uint8_t _controllerPort = GameConnection::SpectatorPort;
2014-07-06 20:40:33 -04:00
private:
void SendHandshake();
void SendControllerSelection(uint8_t port);
void ClearInputData();
void PushControllerState(uint8_t port, ControlDeviceState state);
void DisableControllers();
2014-07-06 20:40:33 -04:00
protected:
2016-12-17 23:14:47 -05:00
void ProcessMessage(NetMessage* message) override;
2014-07-06 20:40:33 -04:00
public:
GameClientConnection(shared_ptr<Socket> socket, shared_ptr<ClientConnectionData> connectionData);
~GameClientConnection();
void Shutdown();
2016-12-17 23:14:47 -05:00
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();
2014-07-06 20:40:33 -04:00
};