diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
commit | c04dcc2e7d834218ef2d4194331e383402495ae1 (patch) | |
tree | 7333e38d10d75386e60f336b80c2443c1166031d /xbmc/peripherals/devices/PeripheralImon.cpp | |
parent | Initial commit. (diff) | |
download | kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip |
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/peripherals/devices/PeripheralImon.cpp')
-rw-r--r-- | xbmc/peripherals/devices/PeripheralImon.cpp | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/xbmc/peripherals/devices/PeripheralImon.cpp b/xbmc/peripherals/devices/PeripheralImon.cpp new file mode 100644 index 0000000..6683f8b --- /dev/null +++ b/xbmc/peripherals/devices/PeripheralImon.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2012-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "PeripheralImon.h" + +#include "input/InputManager.h" +#include "settings/Settings.h" +#include "utils/log.h" + +using namespace PERIPHERALS; + +std::atomic<long> CPeripheralImon::m_lCountOfImonsConflictWithDInput(0L); + +CPeripheralImon::CPeripheralImon(CPeripherals& manager, + const PeripheralScanResult& scanResult, + CPeripheralBus* bus) + : CPeripheralHID(manager, scanResult, bus) +{ + m_features.push_back(FEATURE_IMON); + m_bImonConflictsWithDInput = false; +} + +void CPeripheralImon::OnDeviceRemoved() +{ + if (m_bImonConflictsWithDInput) + { + if (--m_lCountOfImonsConflictWithDInput == 0) + ActionOnImonConflict(false); + } +} + +bool CPeripheralImon::InitialiseFeature(const PeripheralFeature feature) +{ + if (feature == FEATURE_IMON) + { +#if defined(TARGET_WINDOWS) + if (HasSetting("disable_winjoystick") && GetSettingBool("disable_winjoystick")) + m_bImonConflictsWithDInput = true; + else +#endif // TARGET_WINDOWS + m_bImonConflictsWithDInput = false; + + if (m_bImonConflictsWithDInput) + { + ++m_lCountOfImonsConflictWithDInput; + ActionOnImonConflict(true); + } + return CPeripheral::InitialiseFeature(feature); + } + + return CPeripheralHID::InitialiseFeature(feature); +} + +void CPeripheralImon::AddSetting(const std::string& strKey, + const std::shared_ptr<const CSetting>& setting, + int order) +{ +#if !defined(TARGET_WINDOWS) + if (strKey.compare("disable_winjoystick") != 0) +#endif // !TARGET_WINDOWS + CPeripheralHID::AddSetting(strKey, setting, order); +} + +void CPeripheralImon::OnSettingChanged(const std::string& strChangedSetting) +{ + if (strChangedSetting.compare("disable_winjoystick") == 0) + { + if (m_bImonConflictsWithDInput && !GetSettingBool("disable_winjoystick")) + { + m_bImonConflictsWithDInput = false; + if (--m_lCountOfImonsConflictWithDInput == 0) + ActionOnImonConflict(false); + } + else if (!m_bImonConflictsWithDInput && GetSettingBool("disable_winjoystick")) + { + m_bImonConflictsWithDInput = true; + ++m_lCountOfImonsConflictWithDInput; + ActionOnImonConflict(true); + } + } +} + +void CPeripheralImon::ActionOnImonConflict(bool deviceInserted /*= true*/) +{ +} |