mirror of
https://github.com/libretro/Mesen.git
synced 2024-11-23 17:19:39 +00:00
NetPlay: Fixed zapper for clients (did not work at all)
This commit is contained in:
parent
0d6919089a
commit
45eeb0426b
@ -15,6 +15,7 @@
|
||||
|
||||
GameClientConnection::GameClientConnection(shared_ptr<Socket> socket, shared_ptr<ClientConnectionData> connectionData) : GameConnection(socket, connectionData)
|
||||
{
|
||||
MessageManager::RegisterNotificationListener(this);
|
||||
MessageManager::DisplayMessage("Net Play", "Connected to server.");
|
||||
SendHandshake();
|
||||
}
|
||||
@ -26,6 +27,7 @@ GameClientConnection::~GameClientConnection()
|
||||
|
||||
MessageManager::SendNotification(ConsoleNotificationType::DisconnectedFromServer);
|
||||
MessageManager::DisplayMessage("Net Play", "Connection to server lost.");
|
||||
MessageManager::UnregisterNotificationListener(this);
|
||||
}
|
||||
|
||||
void GameClientConnection::SendHandshake()
|
||||
@ -160,9 +162,24 @@ uint8_t GameClientConnection::GetControllerState(uint8_t port)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GameClientConnection::ProcessNotification(ConsoleNotificationType type, void* parameter)
|
||||
{
|
||||
if(type == ConsoleNotificationType::ConfigChanged) {
|
||||
switch(EmulationSettings::GetControllerType(_controllerPort)) {
|
||||
case ControllerType::StandardController: _newControlDevice.reset(new StandardController(0)); break;
|
||||
case ControllerType::Zapper: _newControlDevice = ControlManager::GetControlDevice(_controllerPort); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GameClientConnection::SendInput()
|
||||
{
|
||||
if(_gameLoaded) {
|
||||
if(_newControlDevice) {
|
||||
_controlDevice = _newControlDevice;
|
||||
_newControlDevice.reset();
|
||||
}
|
||||
|
||||
uint32_t inputState = 0;
|
||||
if(std::dynamic_pointer_cast<Zapper>(_controlDevice)) {
|
||||
shared_ptr<Zapper> zapper = std::dynamic_pointer_cast<Zapper>(_controlDevice);
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
class ClientConnectionData;
|
||||
|
||||
class GameClientConnection : public GameConnection
|
||||
class GameClientConnection : public GameConnection, public INotificationListener
|
||||
{
|
||||
private:
|
||||
std::deque<uint8_t> _inputData[4];
|
||||
@ -22,6 +22,7 @@ private:
|
||||
vector<PlayerInfo> _playerList;
|
||||
|
||||
shared_ptr<BaseControlDevice> _controlDevice;
|
||||
shared_ptr<BaseControlDevice> _newControlDevice;
|
||||
uint32_t _lastInputSent = 0x00;
|
||||
bool _gameLoaded = false;
|
||||
uint8_t _controllerPort = GameConnection::SpectatorPort;
|
||||
@ -40,6 +41,8 @@ public:
|
||||
GameClientConnection(shared_ptr<Socket> socket, shared_ptr<ClientConnectionData> connectionData);
|
||||
~GameClientConnection();
|
||||
|
||||
void ProcessNotification(ConsoleNotificationType type, void* parameter);
|
||||
|
||||
uint8_t GetControllerState(uint8_t port);
|
||||
void SendInput();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user