Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Peripheral] Add new class 'PeripheralImon'

  • Loading branch information...
commit 3c1e8867f95ca306a7da9a4ae918545f592cb75e 1 parent cf70586
@Karlson2k Karlson2k authored
View
2  project/VS2010Express/XBMC.vcxproj
@@ -864,6 +864,7 @@
<ClCompile Include="..\..\xbmc\peripherals\devices\PeripheralHID.cpp" />
<ClCompile Include="..\..\xbmc\peripherals\devices\PeripheralNIC.cpp" />
<ClCompile Include="..\..\xbmc\peripherals\devices\PeripheralNyxboard.cpp" />
+ <ClCompile Include="..\..\xbmc\peripherals\devices\PeripheralImon.cpp" />
<ClCompile Include="..\..\xbmc\peripherals\devices\PeripheralTuner.cpp" />
<ClCompile Include="..\..\xbmc\peripherals\dialogs\GUIDialogPeripheralManager.cpp" />
<ClCompile Include="..\..\xbmc\peripherals\dialogs\GUIDialogPeripheralSettings.cpp" />
@@ -1189,6 +1190,7 @@
<ClInclude Include="..\..\xbmc\filesystem\ZipFile.h" />
<ClInclude Include="..\..\xbmc\filesystem\ZipManager.h" />
<ClInclude Include="..\..\xbmc\network\windows\ZeroconfBrowserWIN.h" />
+ <ClInclude Include="..\..\xbmc\peripherals\devices\PeripheralImon.h" />
<ClInclude Include="..\..\xbmc\system_gl.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Testsuite|Win32'">true</ExcludedFromBuild>
View
6 project/VS2010Express/XBMC.vcxproj.filters
@@ -2605,6 +2605,9 @@
<ClCompile Include="..\..\xbmc\dialogs\GUIDialogKeyboardGeneric.cpp">
<Filter>dialogs</Filter>
</ClCompile>
+ <ClCompile Include="..\..\xbmc\peripherals\devices\PeripheralImon.cpp">
+ <Filter>peripherals\devices</Filter>
+ </ClCompile>
<ClCompile Include="..\..\xbmc\video\VideoDbUrl.cpp">
<Filter>video</Filter>
</ClCompile>
@@ -5574,6 +5577,9 @@
<ClInclude Include="..\..\xbmc\dialogs\GUIDialogKeyboardGeneric.h">
<Filter>dialogs</Filter>
</ClInclude>
+ <ClInclude Include="..\..\xbmc\peripherals\devices\PeripheralImon.h">
+ <Filter>peripherals\devices</Filter>
+ </ClInclude>
<ClInclude Include="..\..\xbmc\video\VideoDbUrl.h">
<Filter>video</Filter>
</ClInclude>
View
1  xbmc/peripherals/devices/Makefile.in
@@ -2,6 +2,7 @@ SRCS = Peripheral.cpp
SRCS += PeripheralBluetooth.cpp
SRCS += PeripheralDisk.cpp
SRCS += PeripheralHID.cpp
+SRCS += PeripheralImon.cpp
SRCS += PeripheralNIC.cpp
SRCS += PeripheralNyxboard.cpp
SRCS += PeripheralTuner.cpp
View
92 xbmc/peripherals/devices/PeripheralImon.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2012 Team XBMC
+ * http://xbmc.org
+ *
+ * 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 XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "PeripheralImon.h"
+#include "utils/log.h"
+#include "guilib/LocalizeStrings.h"
+#include "threads/Atomics.h"
+#include "settings/GUISettings.h"
+#if defined (TARGET_WINDOWS)
+#include "system.h" // For HAS_SDL_JOYSTICK
+#if defined (HAS_SDL_JOYSTICK)
+#include "input/windows/WINJoystick.h"
+#endif // HAS_SDL_JOYSTICK
+#endif // TARGET_WINDOWS
+
+
+using namespace PERIPHERALS;
+using namespace std;
+
+volatile long CPeripheralImon::m_CountOfImonsConflictWithDInput = 0;
+
+
+CPeripheralImon::CPeripheralImon(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId) :
+ CPeripheralHID(type, busType, strLocation, strDeviceName.IsEmpty() ? g_localizeStrings.Get(35001) : strDeviceName, iVendorId, iProductId)
+{
+ m_features.push_back(FEATURE_IMON);
+#if defined(TARGET_WINDOWS)
+ if (iProductId >= 0x34 && iProductId <= 0x46)
+ m_ImonConflictsWithDInput = true;
+ else
+#endif // TARGET_WINDOWS
+ m_ImonConflictsWithDInput = false;
+}
+
+void CPeripheralImon::OnDeviceRemoved()
+{
+ if (m_ImonConflictsWithDInput)
+ {
+ if (AtomicDecrement(&m_CountOfImonsConflictWithDInput) == 0)
+ ActionOnImonConflict(false);
+ }
+}
+
+bool CPeripheralImon::InitialiseFeature(const PeripheralFeature feature)
+{
+ if (feature == FEATURE_IMON)
+ {
+ if (m_ImonConflictsWithDInput)
+ {
+ AtomicIncrement(&m_CountOfImonsConflictWithDInput);
+ ActionOnImonConflict(true);
+ }
+ return CPeripheral::InitialiseFeature(feature);
+ }
+
+ return CPeripheralHID::InitialiseFeature(feature);
+}
+
+void CPeripheralImon::ActionOnImonConflict(bool deviceInserted /*= true*/)
+{
+ if (deviceInserted || m_CountOfImonsConflictWithDInput == 0)
+ {
+#if defined(TARGET_WINDOWS) && defined (HAS_SDL_JOYSTICK)
+ bool enableJoystickNow = (!deviceInserted || !g_guiSettings.GetBool("input.disablejoystickwithimon"))
+ && g_guiSettings.GetBool("input.enablejoystick");
+ CLog::Log(LOGNOTICE, "Problematic iMON hardware %s. Joystick usage: %s", (deviceInserted ? "detected" : "was removed"),
+ (enableJoystickNow) ? "enabled." : "disabled." );
+ g_Joystick.SetEnabled(enableJoystickNow);
+ CSetting* setting = g_guiSettings.GetSetting("input.disablejoystickwithimon");
+ if(setting)
+ setting->SetVisible(deviceInserted && !setting->IsAdvanced());
+#endif
+ }
+}
+
View
42 xbmc/peripherals/devices/PeripheralImon.h
@@ -0,0 +1,42 @@
+#pragma once
+/*
+ * Copyright (C) 2012 Team XBMC
+ * http://xbmc.org
+ *
+ * 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 XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "PeripheralHID.h"
+
+namespace PERIPHERALS
+{
+ class CPeripheralImon : public CPeripheralHID
+ {
+ public:
+ CPeripheralImon(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId);
+ virtual ~CPeripheralImon(void) {}
+ virtual bool InitialiseFeature(const PeripheralFeature feature);
+ virtual void OnDeviceRemoved();
+ inline bool IsImonConflictsWithDInput()
+ { return m_ImonConflictsWithDInput;}
+ static inline long GetCountOfImonsConflictWithDInput()
+ { return m_CountOfImonsConflictWithDInput; }
+ static void ActionOnImonConflict(bool deviceInserted = true);
+ private:
+ bool m_ImonConflictsWithDInput;
+ static volatile long m_CountOfImonsConflictWithDInput;
+ };
+}
Please sign in to comment.
Something went wrong with that request. Please try again.