2014-07-06 20:40:33 -04:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
2016-02-05 23:14:27 -05:00
|
|
|
#include <deque>
|
2014-07-06 20:40:33 -04:00
|
|
|
#include "GameConnection.h"
|
2016-02-05 23:14:27 -05:00
|
|
|
#include "../Utilities/AutoResetEvent.h"
|
|
|
|
#include "../Utilities/SimpleLock.h"
|
|
|
|
#include "StandardController.h"
|
2015-07-01 23:17:14 -04:00
|
|
|
|
|
|
|
class ClientConnectionData;
|
2014-07-06 20:40:33 -04:00
|
|
|
|
|
|
|
class GameClientConnection : public GameConnection
|
|
|
|
{
|
|
|
|
private:
|
2016-02-05 23:14:27 -05:00
|
|
|
std::deque<uint8_t> _inputData[4];
|
|
|
|
atomic<uint32_t> _inputSize[4];
|
|
|
|
AutoResetEvent _waitForInput[4];
|
|
|
|
SimpleLock _writeLock;
|
|
|
|
atomic<bool> _shutdown;
|
|
|
|
atomic<bool> _enableControllers = false;
|
|
|
|
atomic<uint32_t> _minimumQueueSize = 3;
|
|
|
|
|
|
|
|
shared_ptr<BaseControlDevice> _controlDevice;
|
|
|
|
uint32_t _lastInputSent = 0x00;
|
2014-07-09 18:29:07 -04:00
|
|
|
bool _gameLoaded = false;
|
2014-07-09 21:11:02 -04:00
|
|
|
uint8_t _controllerPort = 255;
|
2014-07-06 20:40:33 -04:00
|
|
|
|
|
|
|
private:
|
2014-07-09 19:05:07 -04:00
|
|
|
void SendHandshake();
|
2016-02-05 23:14:27 -05:00
|
|
|
void ClearInputData();
|
|
|
|
void PushControllerState(uint8_t port, uint8_t state);
|
|
|
|
void DisableControllers();
|
2014-07-06 20:40:33 -04:00
|
|
|
|
|
|
|
protected:
|
2014-07-09 19:05:07 -04:00
|
|
|
void ProcessMessage(NetMessage* message);
|
2014-07-06 20:40:33 -04:00
|
|
|
|
|
|
|
public:
|
2015-07-01 23:17:14 -04:00
|
|
|
GameClientConnection(shared_ptr<Socket> socket, shared_ptr<ClientConnectionData> connectionData);
|
2014-07-09 19:05:07 -04:00
|
|
|
~GameClientConnection();
|
2016-02-05 23:14:27 -05:00
|
|
|
|
|
|
|
uint8_t GetControllerState(uint8_t port);
|
2014-07-09 19:05:07 -04:00
|
|
|
void SendInput();
|
2014-07-06 20:40:33 -04:00
|
|
|
};
|