aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett Brown <themagnificentmrb@gmail.com>2018-01-09 15:32:03 -0800
committerGarrett Brown <themagnificentmrb@gmail.com>2018-02-15 15:59:56 -0800
commit502c46c81a89817d427f766034974a583317ecc4 (patch)
tree83909d727a9ad7c01e50983ddbe4af9c8d337a3c
parentb37fbf3c4315bb134be84a99b1e38609f96bfda0 (diff)
Games: Remove port manager
Will be replaced by new player manager.
-rw-r--r--xbmc/cores/RetroPlayer/RetroPlayer.cpp3
-rw-r--r--xbmc/games/GameServices.cpp9
-rw-r--r--xbmc/games/GameServices.h3
-rw-r--r--xbmc/games/addons/GameClient.cpp1
-rw-r--r--xbmc/games/addons/input/GameClientInput.cpp12
-rw-r--r--xbmc/games/ports/CMakeLists.txt9
-rw-r--r--xbmc/games/ports/InputSink.cpp8
-rw-r--r--xbmc/games/ports/InputSink.h7
-rw-r--r--xbmc/games/ports/Port.cpp19
-rw-r--r--xbmc/games/ports/Port.h7
-rw-r--r--xbmc/games/ports/PortManager.cpp225
-rw-r--r--xbmc/games/ports/PortManager.h126
-rw-r--r--xbmc/games/ports/PortMapper.cpp104
-rw-r--r--xbmc/games/ports/PortMapper.h59
-rw-r--r--xbmc/games/ports/PortTypes.h33
-rw-r--r--xbmc/utils/Observer.h1
16 files changed, 25 insertions, 601 deletions
diff --git a/xbmc/cores/RetroPlayer/RetroPlayer.cpp b/xbmc/cores/RetroPlayer/RetroPlayer.cpp
index 23af0b50ae..99702c4a6e 100644
--- a/xbmc/cores/RetroPlayer/RetroPlayer.cpp
+++ b/xbmc/cores/RetroPlayer/RetroPlayer.cpp
@@ -36,7 +36,6 @@
#include "games/addons/GameClient.h"
#include "games/addons/GameClientTiming.h" //! @todo
#include "games/dialogs/osd/DialogGameVideoSelect.h"
-#include "games/ports/PortManager.h"
#include "games/tags/GameInfoTag.h"
#include "games/GameServices.h"
#include "games/GameUtils.h"
@@ -404,7 +403,7 @@ bool CRetroPlayer::OnAction(const CAction &action)
m_gameClient->GetPlayback()->SetSpeed(0.0);
CLog::Log(LOGDEBUG, "RetroPlayer[PLAYER]: Sending reset command via ACTION_PLAYER_RESET");
- m_gameServices.PortManager().HardwareReset();
+ //m_gameServices.PortManager().HardwareReset();
// If rewinding or paused, begin playback
if (speed <= 0.0f)
diff --git a/xbmc/games/GameServices.cpp b/xbmc/games/GameServices.cpp
index b58a620b6f..c658a47382 100644
--- a/xbmc/games/GameServices.cpp
+++ b/xbmc/games/GameServices.cpp
@@ -21,7 +21,6 @@
#include "GameServices.h"
#include "controllers/Controller.h"
#include "controllers/ControllerManager.h"
-#include "games/ports/PortManager.h"
#include "games/GameSettings.h"
#include "profiles/ProfilesManager.h"
@@ -36,8 +35,7 @@ CGameServices::CGameServices(CControllerManager &controllerManager,
m_controllerManager(controllerManager),
m_gameRenderManager(renderManager),
m_profileManager(profileManager),
- m_gameSettings(new CGameSettings(settings)),
- m_portManager(new CPortManager(peripheralManager))
+ m_gameSettings(new CGameSettings(settings))
{
}
@@ -72,8 +70,3 @@ std::string CGameServices::GetSavestatesFolder() const
{
return m_profileManager.GetSavestatesFolder();
}
-
-CPortManager& CGameServices::PortManager()
-{
- return *m_portManager;
-}
diff --git a/xbmc/games/GameServices.h b/xbmc/games/GameServices.h
index 466c3f0e88..f1c8a37b87 100644
--- a/xbmc/games/GameServices.h
+++ b/xbmc/games/GameServices.h
@@ -43,7 +43,6 @@ namespace GAME
{
class CControllerManager;
class CGameSettings;
- class CPortManager;
class CGameServices
{
@@ -64,7 +63,6 @@ namespace GAME
std::string GetSavestatesFolder() const;
CGameSettings& GameSettings() { return *m_gameSettings; }
- CPortManager& PortManager();
RETRO::CGUIGameRenderManager &GameRenderManager() { return m_gameRenderManager; }
@@ -76,7 +74,6 @@ namespace GAME
// Game services
std::unique_ptr<CGameSettings> m_gameSettings;
- std::unique_ptr<CPortManager> m_portManager;
};
}
}
diff --git a/xbmc/games/addons/GameClient.cpp b/xbmc/games/addons/GameClient.cpp
index 09b3fb3bd9..144f939f1d 100644
--- a/xbmc/games/addons/GameClient.cpp
+++ b/xbmc/games/addons/GameClient.cpp
@@ -33,7 +33,6 @@
#include "games/addons/playback/GameClientRealtimePlayback.h"
#include "games/addons/playback/GameClientReversiblePlayback.h"
#include "games/controllers/Controller.h"
-#include "games/ports/PortManager.h"
#include "games/GameServices.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/LocalizeStrings.h"
diff --git a/xbmc/games/addons/input/GameClientInput.cpp b/xbmc/games/addons/input/GameClientInput.cpp
index a1809ae73a..87c1852e7a 100644
--- a/xbmc/games/addons/input/GameClientInput.cpp
+++ b/xbmc/games/addons/input/GameClientInput.cpp
@@ -26,7 +26,6 @@
#include "addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h"
#include "games/addons/GameClient.h"
#include "games/controllers/Controller.h"
-#include "games/ports/PortManager.h"
#include "games/GameServices.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/WindowIDs.h"
@@ -96,12 +95,8 @@ bool CGameClientInput::OpenPort(unsigned int port)
m_joysticks[port].reset(new CGameClientJoystick(m_gameClient, port, controller, m_struct.toAddon));
- // If keyboard input is being captured by this add-on, force the port type to PERIPHERAL_JOYSTICK
- PERIPHERALS::PeripheralType device = PERIPHERALS::PERIPHERAL_UNKNOWN;
- if (m_gameClient.SupportsKeyboard())
- device = PERIPHERALS::PERIPHERAL_JOYSTICK;
-
- CServiceBroker::GetGameServices().PortManager().OpenPort(m_joysticks[port].get(), m_hardware.get(), &m_gameClient, port, device);
+ //! @todo
+ //CServiceBroker::GetGameServices().PortManager().OpenPort(m_joysticks[port].get(), m_hardware.get(), &m_gameClient, port, device);
UpdatePort(port, controller);
@@ -117,7 +112,8 @@ void CGameClientInput::ClosePort(unsigned int port)
if (m_joysticks.find(port) == m_joysticks.end())
return;
- CServiceBroker::GetGameServices().PortManager().ClosePort(m_joysticks[port].get());
+ //! @todo
+ //CServiceBroker::GetGameServices().PortManager().ClosePort(m_joysticks[port].get());
m_joysticks.erase(port);
diff --git a/xbmc/games/ports/CMakeLists.txt b/xbmc/games/ports/CMakeLists.txt
index 9bdd9de0c0..d9c6db3045 100644
--- a/xbmc/games/ports/CMakeLists.txt
+++ b/xbmc/games/ports/CMakeLists.txt
@@ -1,12 +1,7 @@
set(SOURCES InputSink.cpp
- Port.cpp
- PortManager.cpp
- PortMapper.cpp)
+ Port.cpp)
set(HEADERS InputSink.h
- Port.h
- PortManager.h
- PortMapper.h
- PortTypes.h)
+ Port.h)
core_add_library(gameports)
diff --git a/xbmc/games/ports/InputSink.cpp b/xbmc/games/ports/InputSink.cpp
index 61b64e5533..2633edec8a 100644
--- a/xbmc/games/ports/InputSink.cpp
+++ b/xbmc/games/ports/InputSink.cpp
@@ -19,15 +19,13 @@
*/
#include "InputSink.h"
-#include "games/addons/GameClient.h"
#include "games/controllers/ControllerIDs.h"
-#include "games/addons/input/GameClientInput.h"
using namespace KODI;
using namespace GAME;
-CInputSink::CInputSink(CGameClient &gameClient) :
- m_gameClient(gameClient)
+CInputSink::CInputSink(JOYSTICK::IInputHandler* gameInput) :
+ m_gameInput(gameInput)
{
}
@@ -38,7 +36,7 @@ std::string CInputSink::ControllerID(void) const
bool CInputSink::AcceptsInput(const std::string& feature) const
{
- return m_gameClient.Input().AcceptsInput();
+ return m_gameInput->AcceptsInput(feature);
}
bool CInputSink::OnButtonPress(const std::string& feature, bool bPressed)
diff --git a/xbmc/games/ports/InputSink.h b/xbmc/games/ports/InputSink.h
index bf70838f82..fefec129a4 100644
--- a/xbmc/games/ports/InputSink.h
+++ b/xbmc/games/ports/InputSink.h
@@ -19,7 +19,6 @@
*/
#pragma once
-#include "games/controllers/ControllerTypes.h"
#include "input/joysticks/interfaces/IInputHandler.h"
namespace KODI
@@ -31,7 +30,7 @@ namespace GAME
class CInputSink : public JOYSTICK::IInputHandler
{
public:
- explicit CInputSink(CGameClient &m_gameClient);
+ explicit CInputSink(JOYSTICK::IInputHandler* gameInput);
virtual ~CInputSink() = default;
@@ -48,8 +47,8 @@ namespace GAME
virtual bool OnThrottleMotion(const std::string& feature, float position, unsigned int motionTimeMs) override;
private:
- const CGameClient &m_gameClient;
- const ControllerPtr m_controller;
+ // Construction parameters
+ JOYSTICK::IInputHandler* m_gameInput;
};
}
}
diff --git a/xbmc/games/ports/Port.cpp b/xbmc/games/ports/Port.cpp
index d3cdaa6702..6c8ca0b080 100644
--- a/xbmc/games/ports/Port.cpp
+++ b/xbmc/games/ports/Port.cpp
@@ -29,10 +29,9 @@
using namespace KODI;
using namespace GAME;
-CPort::CPort(JOYSTICK::IInputHandler *gameInput, CGameClient &gameClient) :
+CPort::CPort(JOYSTICK::IInputHandler *gameInput) :
m_gameInput(gameInput),
- m_gameClient(gameClient),
- m_inputSink(new CInputSink(gameClient))
+ m_inputSink(new CInputSink(gameInput))
{
}
@@ -66,12 +65,12 @@ std::string CPort::ControllerID() const
bool CPort::AcceptsInput(const std::string& feature) const
{
- return m_gameClient.Input().AcceptsInput();
+ return m_gameInput->AcceptsInput(feature);
}
bool CPort::OnButtonPress(const std::string& feature, bool bPressed)
{
- if (bPressed && !m_gameClient.Input().AcceptsInput())
+ if (bPressed && !m_gameInput->AcceptsInput(feature))
return false;
return m_gameInput->OnButtonPress(feature, bPressed);
@@ -84,7 +83,7 @@ void CPort::OnButtonHold(const std::string& feature, unsigned int holdTimeMs)
bool CPort::OnButtonMotion(const std::string& feature, float magnitude, unsigned int motionTimeMs)
{
- if (magnitude > 0.0f && !m_gameClient.Input().AcceptsInput())
+ if (magnitude > 0.0f && !m_gameInput->AcceptsInput(feature))
return false;
return m_gameInput->OnButtonMotion(feature, magnitude, motionTimeMs);
@@ -92,7 +91,7 @@ bool CPort::OnButtonMotion(const std::string& feature, float magnitude, unsigned
bool CPort::OnAnalogStickMotion(const std::string& feature, float x, float y, unsigned int motionTimeMs)
{
- if ((x != 0.0f || y != 0.0f) && !m_gameClient.Input().AcceptsInput())
+ if ((x != 0.0f || y != 0.0f) && !m_gameInput->AcceptsInput(feature))
return false;
return m_gameInput->OnAnalogStickMotion(feature, x, y, motionTimeMs);
@@ -100,7 +99,7 @@ bool CPort::OnAnalogStickMotion(const std::string& feature, float x, float y, un
bool CPort::OnAccelerometerMotion(const std::string& feature, float x, float y, float z)
{
- if (!m_gameClient.Input().AcceptsInput())
+ if (!m_gameInput->AcceptsInput(feature))
return false;
return m_gameInput->OnAccelerometerMotion(feature, x, y, z);
@@ -108,7 +107,7 @@ bool CPort::OnAccelerometerMotion(const std::string& feature, float x, float y,
bool CPort::OnWheelMotion(const std::string& feature, float position, unsigned int motionTimeMs)
{
- if ((position != 0.0f) && !m_gameClient.Input().AcceptsInput())
+ if ((position != 0.0f) && !m_gameInput->AcceptsInput(feature))
return false;
return m_gameInput->OnWheelMotion(feature, position, motionTimeMs);
@@ -116,7 +115,7 @@ bool CPort::OnWheelMotion(const std::string& feature, float position, unsigned i
bool CPort::OnThrottleMotion(const std::string& feature, float position, unsigned int motionTimeMs)
{
- if ((position != 0.0f) && !m_gameClient.Input().AcceptsInput())
+ if ((position != 0.0f) && !m_gameInput->AcceptsInput(feature))
return false;
return m_gameInput->OnThrottleMotion(feature, position, motionTimeMs);
diff --git a/xbmc/games/ports/Port.h b/xbmc/games/ports/Port.h
index e97617035d..02aee44445 100644
--- a/xbmc/games/ports/Port.h
+++ b/xbmc/games/ports/Port.h
@@ -34,14 +34,12 @@ namespace JOYSTICK
namespace GAME
{
- class CGameClient;
-
class CPort : public JOYSTICK::IInputHandler,
public IKeymapEnvironment
{
public:
- CPort(JOYSTICK::IInputHandler* gameInput, CGameClient& gameClient);
- ~CPort();
+ CPort(JOYSTICK::IInputHandler* gameInput);
+ ~CPort() override;
void RegisterInput(JOYSTICK::IInputProvider *provider);
void UnregisterInput(JOYSTICK::IInputProvider *provider);
@@ -70,7 +68,6 @@ namespace GAME
private:
// Construction parameters
JOYSTICK::IInputHandler* const m_gameInput;
- CGameClient& m_gameClient;
// Handles input to Kodi
std::unique_ptr<JOYSTICK::CKeymapHandling> m_appInput;
diff --git a/xbmc/games/ports/PortManager.cpp b/xbmc/games/ports/PortManager.cpp
deleted file mode 100644
index 2dbc9f5637..0000000000
--- a/xbmc/games/ports/PortManager.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (C) 2015-2017 Team Kodi
- * http://kodi.tv
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this Program; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "PortManager.h"
-#include "PortMapper.h"
-#include "input/hardware/IHardwareInput.h"
-#include "input/joysticks/interfaces/IInputHandler.h"
-#include "peripherals/devices/Peripheral.h"
-#include "peripherals/devices/PeripheralJoystick.h"
-#include "peripherals/Peripherals.h"
-#include "utils/log.h"
-
-#include <algorithm>
-
-using namespace KODI;
-using namespace GAME;
-using namespace JOYSTICK;
-using namespace PERIPHERALS;
-
-// --- GetRequestedPort() -----------------------------------------------------
-
-namespace
-{
- int GetRequestedPort(const PERIPHERALS::PeripheralPtr& device)
- {
- if (device->Type() == PERIPHERAL_JOYSTICK)
- return std::static_pointer_cast<CPeripheralJoystick>(device)->RequestedPort();
- return JOYSTICK_PORT_UNKNOWN;
- }
-}
-
-// --- CPortManager -----------------------------------------------------------
-
-CPortManager::CPortManager(PERIPHERALS::CPeripherals& peripheralManager) :
- m_portMapper(new CPortMapper(peripheralManager, *this))
-{
-}
-
-CPortManager::~CPortManager() = default;
-
-void CPortManager::OpenPort(IInputHandler* handler,
- HARDWARE::IHardwareInput *hardwareInput,
- CGameClient* gameClient,
- unsigned int port,
- PERIPHERALS::PeripheralType requiredType /* = PERIPHERALS::PERIPHERAL_UNKNOWN) */)
-{
- CExclusiveLock lock(m_mutex);
-
- SPort newPort = { };
- newPort.handler = handler;
- newPort.hardwareInput = hardwareInput;
- newPort.port = port;
- newPort.requiredType = requiredType;
- newPort.gameClient = gameClient;
- m_ports.push_back(newPort);
-
- SetChanged();
- NotifyObservers(ObservableMessagePortsChanged);
-}
-
-void CPortManager::ClosePort(IInputHandler* handler)
-{
- CExclusiveLock lock(m_mutex);
-
- m_ports.erase(std::remove_if(m_ports.begin(), m_ports.end(),
- [handler](const SPort& port)
- {
- return port.handler == handler;
- }), m_ports.end());
-
- SetChanged();
- NotifyObservers(ObservableMessagePortsChanged);
-}
-
-void CPortManager::MapDevices(const PeripheralVector& devices,
- std::map<CPeripheral*, IInputHandler*>& deviceToPortMap)
-{
- CSharedLock lock(m_mutex);
-
- if (m_ports.empty())
- return; // Nothing to do
-
- // Clear all ports
- for (SPort& port : m_ports)
- port.device = nullptr;
-
- // Prioritize devices by several criteria
- PeripheralVector devicesCopy = devices;
- std::sort(devicesCopy.begin(), devicesCopy.end(),
- [](const PeripheralPtr& lhs, const PeripheralPtr& rhs)
- {
- // Prioritize physical joysticks over emulated ones
- if (lhs->Type() == PERIPHERAL_JOYSTICK && rhs->Type() != PERIPHERAL_JOYSTICK)
- return true;
- if (lhs->Type() != PERIPHERAL_JOYSTICK && rhs->Type() == PERIPHERAL_JOYSTICK)
- return false;
-
- if (lhs->Type() == PERIPHERAL_JOYSTICK && rhs->Type() == PERIPHERAL_JOYSTICK)
- {
- std::shared_ptr<CPeripheralJoystick> i = std::static_pointer_cast<CPeripheralJoystick>(lhs);
- std::shared_ptr<CPeripheralJoystick> j = std::static_pointer_cast<CPeripheralJoystick>(rhs);
-
- // Prioritize requested a port over no port requested
- if (i->RequestedPort() != JOYSTICK_PORT_UNKNOWN && j->RequestedPort() == JOYSTICK_PORT_UNKNOWN)
- return true;
- if (i->RequestedPort() == JOYSTICK_PORT_UNKNOWN && j->RequestedPort() != JOYSTICK_PORT_UNKNOWN)
- return false;
-
- // Sort joystick by requested port
- return i->RequestedPort() < j->RequestedPort();
- }
-
- return false;
- });
-
- // Record mapped devices in output variable
- for (auto& device : devicesCopy)
- {
- IInputHandler* handler = AssignToPort(device);
- if (handler)
- deviceToPortMap[device.get()] = handler;
- }
-}
-
-CGameClient* CPortManager::GameClient(JOYSTICK::IInputHandler* handler)
-{
- CSharedLock lock(m_mutex);
-
- for (const SPort& port : m_ports)
- {
- if (port.handler == handler)
- return port.gameClient;
- }
-
- return nullptr;
-}
-
-void CPortManager::HardwareReset(JOYSTICK::IInputHandler *handler /* = nullptr */)
-{
- CSharedLock lock(m_mutex);
-
- // Find the port to reset
- auto itPort = m_ports.end();
-
- if (handler != nullptr)
- {
- auto FindByHandler = [handler](const SPort& portStruct)
- {
- return portStruct.handler == handler;
- };
-
- itPort = std::find_if(m_ports.begin(), m_ports.end(), FindByHandler);
- }
- else
- {
- auto FindDefaultPort = [](const SPort& portStruct)
- {
- return portStruct.port == 0;
- };
-
- itPort = std::find_if(m_ports.begin(), m_ports.end(), FindDefaultPort);
- }
-
- if (itPort != m_ports.end())
- itPort->hardwareInput->OnResetButton(itPort->port);
- else
- {
- if (handler != nullptr)
- CLog::Log(LOGERROR, "Can't find hardware to reset for controller %s (total ports = %u)", handler->ControllerID().c_str(), m_ports.size());
- else
- CLog::Log(LOGERROR, "Can't find hardware to reset for default port (total ports = %u)", m_ports.size());
- }
-}
-
-IInputHandler* CPortManager::AssignToPort(const PeripheralPtr& device, bool checkPortNumber /* = true */)
-{
- const int requestedPort = GetRequestedPort(device);
- const bool bPortRequested = (requestedPort != JOYSTICK_PORT_UNKNOWN);
-
- for (SPort& port : m_ports)
- {
- // Skip occupied ports
- if (port.device != nullptr)
- continue;
-
- // If specified, check port numbers
- if (checkPortNumber)
- {
- if (bPortRequested && requestedPort != static_cast<int>(port.port))
- continue;
- }
-
- // If required, filter by type
- const bool bTypeRequired = (port.requiredType != PERIPHERAL_UNKNOWN);
- if (bTypeRequired && port.requiredType != device->Type())
- continue;
-
- // Success
- port.device = device.get();
- return port.handler;
- }
-
- // If joystick requested a port but wasn't mapped, try again without checking port numbers
- if (checkPortNumber && bPortRequested)
- return AssignToPort(device, false);
-
- return nullptr;
-}
diff --git a/xbmc/games/ports/PortManager.h b/xbmc/games/ports/PortManager.h
deleted file mode 100644
index faef350815..0000000000
--- a/xbmc/games/ports/PortManager.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2015-2017 Team Kodi
- * http://kodi.tv
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this Program; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-#pragma once
-
-#include "peripherals/PeripheralTypes.h"
-#include "threads/SharedSection.h"
-#include "utils/Observer.h"
-
-#include <map>
-#include <vector>
-
-namespace PERIPHERALS
-{
- class CPeripheral;
- class CPeripherals;
-}
-
-namespace KODI
-{
-namespace HARDWARE
-{
- class IHardwareInput;
-}
-
-namespace JOYSTICK
-{
- class IInputHandler;
-}
-
-namespace GAME
-{
- class CGameClient;
- class CPortMapper;
-
- /*!
- * \brief Class to manage ports opened by game clients
- */
- class CPortManager : public Observable
- {
- public:
- explicit CPortManager(PERIPHERALS::CPeripherals& peripheralManager);
- virtual ~CPortManager();
-
- /*!
- * \brief Request a new port be opened with input on that port sent to the
- * specified handler.
- *
- * \param handler The instance accepting all input delivered to the port
- * \param gameClient The game client opening the port
- * \param port The port number belonging to the game client
- * \param requiredType Used to restrict port to devices of only a certain type
- */
- void OpenPort(JOYSTICK::IInputHandler* handler,
- HARDWARE::IHardwareInput *hardwareInput,
- CGameClient* gameClient,
- unsigned int port,
- PERIPHERALS::PeripheralType requiredType = PERIPHERALS::PERIPHERAL_UNKNOWN);
-
- /*!
- * \brief Close an opened port
- *
- * \param handler The handler used to open the port
- */
- void ClosePort(JOYSTICK::IInputHandler* handler);
-
- /*!
- * \brief Map a list of devices to the available ports
- *
- * \param devices The devices capable of providing input to the ports
- * \param portMap The resulting map of devices to ports
- *
- * If there are more devices than open ports, multiple devices may be assigned
- * to the same port. If a device requests a specific port, this function will
- * attempt to honor that request.
- */
- void MapDevices(const PERIPHERALS::PeripheralVector& devices,
- std::map<PERIPHERALS::CPeripheral*, JOYSTICK::IInputHandler*>& deviceToPortMap);
-
- //! @todo Return game client from MapDevices()
- CGameClient* GameClient(JOYSTICK::IInputHandler* handler);
-
- /*!
- * \brief Send a hardware reset command for the specified input handler
- *
- * \param handler The handler associated the user who pressed reset, or
- * nullptr if it's unknown who presesd reset
- */
- void HardwareReset(JOYSTICK::IInputHandler *handler = nullptr);
-
- private:
- JOYSTICK::IInputHandler* AssignToPort(const PERIPHERALS::PeripheralPtr& device, bool checkPortNumber = true);
-
- std::unique_ptr<CPortMapper> m_portMapper;
-
- struct SPort
- {
- JOYSTICK::IInputHandler* handler; // Input handler for this port
- HARDWARE::IHardwareInput *hardwareInput; // Callbacks for hardware input
- unsigned int port; // Port number belonging to the game client
- PERIPHERALS::PeripheralType requiredType;
- void* device;
- CGameClient* gameClient;
- };
-
- std::vector<SPort> m_ports;
- CSharedSection m_mutex;
- };
-}
-}
diff --git a/xbmc/games/ports/PortMapper.cpp b/xbmc/games/ports/PortMapper.cpp
deleted file mode 100644
index 95de00a36b..0000000000
--- a/xbmc/games/ports/PortMapper.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2015-2017 Team Kodi
- * http://kodi.tv
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this Program; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "PortMapper.h"
-#include "Port.h"
-#include "PortManager.h"
-#include "peripherals/devices/Peripheral.h"
-#include "peripherals/Peripherals.h"
-
-using namespace KODI;
-using namespace GAME;
-using namespace JOYSTICK;
-using namespace PERIPHERALS;
-
-CPortMapper::CPortMapper(PERIPHERALS::CPeripherals& peripheralManager, CPortManager& portManager) :
- m_peripheralManager(peripheralManager),
- m_portManager(portManager)
-{
- m_peripheralManager.RegisterObserver(this);
- m_portManager.RegisterObserver(this);
-}
-
-CPortMapper::~CPortMapper()
-{
- m_portManager.UnregisterObserver(this);
- m_peripheralManager.UnregisterObserver(this);
-}
-
-void CPortMapper::Notify(const Observable &obs, const ObservableMessage msg)
-{
- switch (msg)
- {
- case ObservableMessagePeripheralsChanged:
- case ObservableMessagePortsChanged:
- ProcessPeripherals();
- break;
- default:
- break;
- }
-}
-
-void CPortMapper::ProcessPeripherals()
-{
- PeripheralVector joysticks;
- m_peripheralManager.GetPeripheralsWithFeature(joysticks, FEATURE_JOYSTICK);
-
- // Perform the port mapping
- std::map<CPeripheral*, IInputHandler*> newPortMap;
- m_portManager.MapDevices(joysticks, newPortMap);
-
- // Update each joystick
- for (auto& joystick : joysticks)
- {
- auto itConnectedPort = newPortMap.find(joystick.get());
- auto itDisconnectedPort = m_portMap.find(joystick);
-
- IInputHandler* newHandler = itConnectedPort != newPortMap.end() ? itConnectedPort->second : nullptr;
- IInputHandler* oldHandler = itDisconnectedPort != m_portMap.end() ? itDisconnectedPort->second->InputHandler() : nullptr;
-
- if (oldHandler != newHandler)
- {
- // Unregister old handler
- if (oldHandler != nullptr)
- {
- PortPtr& oldPort = itDisconnectedPort->second;
-
- oldPort->UnregisterInput(joystick.get());
-
- m_portMap.erase(itDisconnectedPort);
- }
-
- // Register new handler
- if (newHandler != nullptr)
- {
- CGameClient *gameClient = m_portManager.GameClient(newHandler);
- if (gameClient)
- {
- PortPtr newPort(new CPort(newHandler, *gameClient));
-
- newPort->RegisterInput(joystick.get());
-
- m_portMap.insert(std::make_pair(std::move(joystick), std::move(newPort)));
- }
- }
- }
- }
-}
diff --git a/xbmc/games/ports/PortMapper.h b/xbmc/games/ports/PortMapper.h
deleted file mode 100644
index 37379917fa..0000000000
--- a/xbmc/games/ports/PortMapper.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2015-2017 Team Kodi
- * http://kodi.tv
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this Program; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-#pragma once
-
-#include "PortTypes.h"
-#include "peripherals/PeripheralTypes.h"
-#include "utils/Observer.h"
-
-#include <map>
-
-namespace PERIPHERALS
-{
- class CPeripherals;
-}
-
-namespace KODI
-{
-namespace GAME
-{
- class CPortManager;
-
- class CPortMapper : public Observer
- {
- public:
- CPortMapper(PERIPHERALS::CPeripherals& peripheralManager, CPortManager& portManager);
-
- virtual ~CPortMapper();
-
- virtual void Notify(const Observable& obs, const ObservableMessage msg) override;
-
- private:
- void ProcessPeripherals();
-
- // Construction parameters
- PERIPHERALS::CPeripherals &m_peripheralManager;
- CPortManager &m_portManager;
-
- // Port paremters
- std::map<PERIPHERALS::PeripheralPtr, PortPtr> m_portMap;
- };
-}
-}
diff --git a/xbmc/games/ports/PortTypes.h b/xbmc/games/ports/PortTypes.h
deleted file mode 100644
index 8647a7e56b..0000000000
--- a/xbmc/games/ports/PortTypes.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2017 Team Kodi
- * http://kodi.tv
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this Program; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-#pragma once
-
-#include <memory>
-
-namespace KODI
-{
-namespace GAME
-{
-
-class CPort;
-using PortPtr = std::shared_ptr<CPort>;
-
-}
-}
diff --git a/xbmc/utils/Observer.h b/xbmc/utils/Observer.h
index f72a44ebc0..c1a560844a 100644
--- a/xbmc/utils/Observer.h
+++ b/xbmc/utils/Observer.h
@@ -44,7 +44,6 @@ typedef enum
ObservableMessagePeripheralsChanged,
ObservableMessageChannelGroupsLoaded,
ObservableMessageManagerStopped,
- ObservableMessagePortsChanged,
ObservableMessageSettingsChanged,
ObservableMessageButtonMapsChanged,
} ObservableMessage;