diff --git a/xbmc/input/InputManager.cpp b/xbmc/input/InputManager.cpp index 0efb501168670..645a83bc11dab 100644 --- a/xbmc/input/InputManager.cpp +++ b/xbmc/input/InputManager.cpp @@ -57,6 +57,7 @@ #endif #include "ButtonTranslator.h" #include "peripherals/Peripherals.h" +#include "peripherals/devices/PeripheralImon.h" #include "XBMC_vkeys.h" #include "utils/log.h" #include "utils/StringUtils.h" @@ -70,10 +71,10 @@ #endif #ifdef HAS_EVENT_SERVER -using namespace EVENTSERVER; +using EVENTSERVER::CEventServer; #endif -using namespace PERIPHERALS; +using PERIPHERALS::CPeripherals; CInputManager& CInputManager::Get() { @@ -783,3 +784,19 @@ void CInputManager::SetRemoteControlName(const std::string& name) m_RemoteControl.setDeviceName(name); #endif } + +void CInputManager::OnSettingChanged(const CSetting *setting) +{ + if (setting == nullptr) + return; + + const std::string &settingId = setting->GetId(); + if (settingId == "input.enablemouse") + m_Mouse.SetEnabled(dynamic_cast(setting)->GetValue()); + +#if defined(HAS_SDL_JOYSTICK) + if (settingId == "input.enablejoystick") + m_Joystick.SetEnabled(dynamic_cast(setting)->GetValue() && + PERIPHERALS::CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0); +#endif +} diff --git a/xbmc/input/InputManager.h b/xbmc/input/InputManager.h index a2e75128f8289..93002ef4e0d99 100644 --- a/xbmc/input/InputManager.h +++ b/xbmc/input/InputManager.h @@ -39,8 +39,9 @@ #include "guilib/Key.h" #include "input/KeyboardStat.h" #include "input/MouseStat.h" +#include "settings/lib/ISettingCallback.h" -class CInputManager +class CInputManager : public ISettingCallback { private: CInputManager() { } @@ -48,8 +49,6 @@ class CInputManager CInputManager const& operator=(CInputManager const&); virtual ~CInputManager() { }; - friend class CSettings; - public: /*! \brief static method to get the current instance of the class. Creates a new instance the first time it's called. */ @@ -212,6 +211,8 @@ class CInputManager */ int ExecuteBuiltin(const std::string& execute, const std::vector& params); + virtual void OnSettingChanged(const CSetting *setting); + private: /*! \brief Process keyboard event and translate into an action diff --git a/xbmc/input/MouseStat.cpp b/xbmc/input/MouseStat.cpp index 8167741a38c19..8cb6b4c81e13e 100644 --- a/xbmc/input/MouseStat.cpp +++ b/xbmc/input/MouseStat.cpp @@ -38,16 +38,6 @@ CMouseStat::~CMouseStat() { } -void CMouseStat::OnSettingChanged(const CSetting *setting) -{ - if (setting == NULL) - return; - - const std::string &settingId = setting->GetId(); - if (settingId == "input.enablemouse") - SetEnabled(((CSettingBool*)setting)->GetValue()); -} - void CMouseStat::Initialize() { // Set the default resolution (PAL) diff --git a/xbmc/input/MouseStat.h b/xbmc/input/MouseStat.h index 8fd76ab8013ac..900c3a1507cae 100644 --- a/xbmc/input/MouseStat.h +++ b/xbmc/input/MouseStat.h @@ -21,7 +21,6 @@ * */ -#include "settings/lib/ISettingCallback.h" #include "windowing/XBMC_events.h" #define XBMC_BUTTON(X) (1 << ((X)-1)) @@ -73,14 +72,12 @@ struct MousePosition class CAction; -class CMouseStat : public ISettingCallback +class CMouseStat { public: CMouseStat(); virtual ~CMouseStat(); - virtual void OnSettingChanged(const CSetting *setting); - void Initialize(); void HandleEvent(XBMC_Event& newEvent); void SetResolution(int maxX, int maxY, float speedX, float speedY); diff --git a/xbmc/input/SDLJoystick.cpp b/xbmc/input/SDLJoystick.cpp index 306bc93356171..d6e513ff24c5d 100644 --- a/xbmc/input/SDLJoystick.cpp +++ b/xbmc/input/SDLJoystick.cpp @@ -21,7 +21,6 @@ #include "system.h" #include "SDLJoystick.h" #include "input/ButtonTranslator.h" -#include "peripherals/devices/PeripheralImon.h" #include "settings/AdvancedSettings.h" #include "settings/lib/Setting.h" #include "utils/log.h" @@ -42,16 +41,6 @@ CJoystick::CJoystick() Reset(); } -void CJoystick::OnSettingChanged(const CSetting *setting) -{ - if (setting == NULL) - return; - - const std::string &settingId = setting->GetId(); - if (settingId == "input.enablejoystick") - SetEnabled(((CSettingBool*)setting)->GetValue() && PERIPHERALS::CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0); -} - void CJoystick::Reset() { m_AxisIdx = -1; diff --git a/xbmc/input/SDLJoystick.h b/xbmc/input/SDLJoystick.h index ee8488434d31b..02221c880b11b 100644 --- a/xbmc/input/SDLJoystick.h +++ b/xbmc/input/SDLJoystick.h @@ -22,7 +22,6 @@ #define SDL_JOYSTICK_H #include "system.h" // for HAS_SDL_JOYSTICK -#include "settings/lib/ISettingCallback.h" #include #include #include @@ -67,13 +66,11 @@ class CRegExp; // Class to manage all connected joysticks // Note: 'index' always refers to indices specific to this class, // whereas 'ids' always refer to SDL instance id's -class CJoystick : public ISettingCallback +class CJoystick { public: CJoystick(); - virtual void OnSettingChanged(const CSetting *setting); - void Initialize(); void Reset(); void Update(); diff --git a/xbmc/input/windows/WINJoystick.cpp b/xbmc/input/windows/WINJoystick.cpp index 7870c4cab9513..8aa43ea1ba1ca 100644 --- a/xbmc/input/windows/WINJoystick.cpp +++ b/xbmc/input/windows/WINJoystick.cpp @@ -65,16 +65,6 @@ CJoystick::~CJoystick() ReleaseJoysticks(); } -void CJoystick::OnSettingChanged(const CSetting *setting) -{ - if (setting == NULL) - return; - - const std::string &settingId = setting->GetId(); - if (settingId == "input.enablejoystick") - SetEnabled(((CSettingBool*)setting)->GetValue() && PERIPHERALS::CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0); -} - void CJoystick::Reset() { m_AxisIdx = -1; diff --git a/xbmc/input/windows/WINJoystick.h b/xbmc/input/windows/WINJoystick.h index dec177ac8e9fd..84970693ab772 100644 --- a/xbmc/input/windows/WINJoystick.h +++ b/xbmc/input/windows/WINJoystick.h @@ -24,7 +24,6 @@ #include #include #include -#include "settings/lib/ISettingCallback.h" #include "threads/CriticalSection.h" #define JACTIVE_BUTTON 0x00000001 @@ -55,13 +54,12 @@ typedef std::vector AxesConfig; // [UnregisterCallback(&g_charsetConverter); m_settingsManager->UnregisterCallback(&g_graphicsContext); m_settingsManager->UnregisterCallback(&g_langInfo); -#if defined(TARGET_WINDOWS) || defined(HAS_SDL_JOYSTICK) - m_settingsManager->UnregisterCallback(&CInputManager::Get().m_Joystick); -#endif - m_settingsManager->UnregisterCallback(&CInputManager::Get().m_Mouse); + m_settingsManager->UnregisterCallback(&CInputManager::Get()); m_settingsManager->UnregisterCallback(&CNetworkServices::Get()); m_settingsManager->UnregisterCallback(&g_passwordManager); m_settingsManager->UnregisterCallback(&PVR::g_PVRManager); @@ -759,15 +756,10 @@ void CSettings::InitializeISettingCallbacks() settingSet.insert("locale.country"); m_settingsManager->RegisterCallback(&g_langInfo, settingSet); -#if defined(HAS_SDL_JOYSTICK) settingSet.clear(); settingSet.insert("input.enablejoystick"); - m_settingsManager->RegisterCallback(&CInputManager::Get().m_Joystick, settingSet); -#endif - - settingSet.clear(); settingSet.insert("input.enablemouse"); - m_settingsManager->RegisterCallback(&CInputManager::Get().m_Mouse, settingSet); + m_settingsManager->RegisterCallback(&CInputManager::Get(), settingSet); settingSet.clear(); settingSet.insert("services.webserver");