Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[win32] Fix for problematic iMON hardware #1189

Merged
merged 10 commits into from

4 participants

Karlson2k Lars Op den Kamp Zeljko Ametovic Memphiz
Karlson2k
Collaborator

This is a second part for fix #1111.
Abilitity to disable joystick code (which cause a problem with some iMON hardware) was implemented In #1111, but when users will update from Eden to Frodo (or just use clean install), they should at first use keyboard (or mouse) to switch off joystick and only after that they'll be able to use remote control.

With this patch XBMC will try to detect problem iMON hardware and, if some is found, (initially) disable joystick support. User can change this setting from GUI and user choice will be preserved across restarts.

Lars Op den Kamp
Collaborator

oh please no. map it in cperipherals and put your logic in there.

Karlson2k
Collaborator

@opdenkamp Move code to cperipherals? It's platform independ mostly, may be it's better to move code to CPeripheralBusUSB?
But detection function must be called from here, as it should set only default value, which can be overwritten from settings.xml .

Lars Op den Kamp
Collaborator

no, you need to map it to a device in peripherals/devices (create a new joystick one I guess), and query the detected devices where you are now doing a device scan. device scanning will only be done in CPeripherals, and not anywhere else

Karlson2k
Collaborator

But all peripherals/devices are initialized after loading of settings from xml as they deeply depends on settings.
The idea of this patch to supply default value that can be overridden by user's choice so iMON should be detected before loading of settings and, therefore, before any peripherals initialization.
My suggestion is to move detection code to platform specific BusUSB (as this check is needed only for Windows) and call some static function from here to set default value.

Lars Op den Kamp
Collaborator

no, you need to think about another solution for this, e.g. overriding the value via peripheral settings. you can not do any usb device scans in your code. and making the scanning methods public will open a door to introduce more hacks like this.

Karlson2k
Collaborator

OK, thinks about suggested way.

Karlson2k
Collaborator

Dilemma.
It can be implemented as new device type, like 'CPeripheralPromlemImon', but this looks like overkill.
It can be implemented as HID device with configuration in Peripherals.xml, but in this case we need to catch addition/deletion of such devices in CreatePeripheral/OnDeviceAdded and OnDeviceDeleted, but this will looks like a hack.
What could you suggest?

Lars Op den Kamp
Collaborator

there's a number of different approaches possible. e.g. create a setting for each hid peripheral, define a default value for that setting for the generic devices, and use another value for the imon device.

If you think you need to do something on load, override InitialiseFeature() in the class, and do what you think that needs to be done. If something needs to be done when the device is removed, override OnDeviceRemoved().
That's not a hack, but how I designed it to work.

Karlson2k
Collaborator

@opdenkamp Rewrote from the scratch.
With little optimization of old code.

Lars Op den Kamp
Collaborator

this looks a lot more like it. think it would be better to stick it in a separate imon class that inherits from cperipheralhid, and map it to that peripherals.xml. avoids the mapping by name in code

Karlson2k
Collaborator

@opdenkamp OK, I'll convert it to separate imon class.Early this seemed overkill, but now it looks like adequate solution.

Karlson2k
Collaborator

@opdenkamp Rebased and ready to test.

Karlson2k
Collaborator

@opdenkamp Rebased again and still ready for test.

Karlson2k
Collaborator

@opdenkamp Ready for this merge window.

Lars Op den Kamp
Collaborator

yeah need to re-review it but was pretty busy as you can see :)

Karlson2k
Collaborator

@opdenkamp Sorry, pushed rebased version while you was commenting. :(

Lars Op den Kamp
Collaborator

right, you can find the comments in your mailbox or on my timeline thing here. not going to c+p all of them

Zeljko Ametovic

PLEASE dont :)

Karlson2k
Collaborator

@opdenkamp They all are in my notification inbox.

Karlson2k
Collaborator

@amet Don't - what?

Karlson2k
Collaborator

@opdenkamp Is it fine to implement "NumberOfConflictingImons()" in CPeripherals ?
It's needed in a lot of places instead of "HasPeipheralWithFeature(FEATURE_PROBLEMIMON)".

Zeljko Ametovic

please don't c/p all in here... I have hard time dealing with the @ pings coming from here... c/p previous conversations will make me remove myself from github entirely

Karlson2k
Collaborator

@opdenkamp Some code already rewritten by your comments, but before any more push of commits to this PR, I'd like to negotiate the way how it'll be implemented.
We need:

  • some global function that returns presence of conflicting iMON hw (for enabling/disabling joystick in GUI and at startup). Now it's implemented as g_Peripherals.HasPeripheralWithFeature(FEATURE_PROBLEMIMON), my suggestion is to replace it by g_Peripherals.HasConflictImon()
  • check that not other conflicting iMON is present when device is removed. If this should be done in destructor, than we need some cached value in CPeripherals (if we start to enumerate devices, we could cause a deadlock)

If this it OK, I'll implement it this way.

Karlson2k
Collaborator

@opdenkamp Sorry to remind you, but this is a real problem for many iMON users.
I'd like to move forward with it.

Lars Op den Kamp
Collaborator
Lars Op den Kamp
Collaborator

@Karlson2k please update this PR asap if you like to see it included in frodo

Karlson2k
Collaborator

@opdenkamp There was some questions about correct implementation. I can't see any now, that's strange. May be they are still in your inbox?
One of questions was about aditional counters in CPeripherals. It's needed for avoiding deadlocks: when imon is removed we need to check is it last imon or not, but we can't start enumirating as bus is already locked.
So we need to implement ether specific counters for imon in CPeripherals or add code to CPeriphels for switching on/off joystick upon removal/insertion of imon. Or, as alternative use "problem imon" as feature.
What's better?

Lars Op den Kamp
Collaborator

i don't like code specific to imon in cperipherals. if you need to know how many of a certain type are still attached after device removal, pass it along as param in ondeviceremoved() ?

Karlson2k
Collaborator

It's good idea, but some imon devices can be "non-problem". I'd like to implement it later by device setting.
As alternative, it's possible to implement counters as static members of imon class. Is it ok?

Lars Op den Kamp
Collaborator

hm. i'll have another look at this after the week end. maybe fix it up myself if i find the time. sorry, but got no time to do it right now. but we got 10 more days next month to get it in shape ;-)

Karlson2k
Collaborator

But it worth to try it as static members?
Looks like elegant and correct solution.

Lars Op den Kamp
Collaborator

right, go for the static for now, as it's a global thing.

Lars Op den Kamp opdenkamp was assigned
Karlson2k added some commits
Karlson2k Karlson2k [Peripheral] Cosmetics: Update outdated comment in PeripheralBus.h 5465992
Karlson2k Karlson2k [Peripheral] Fix early lock.Leave() in UnregisterRemovedDevices in Pe…
…ripheralBus.cpp and call OnDeviceRemoved for devices with features.

CriticalSection was unlocked inside 'for', could potentially cause problem in case that other thread change list of peripheral.
OnDeviceRemoved wasn't called for devices with type == UNKNOWN even if device is mapped to something with usable feature.
86bf90f
Karlson2k Karlson2k [GUI] Add new setting for disabling Joystick with iMON 2d2e9b8
Karlson2k Karlson2k [win32] Input: Make WINJoystick initialization multithread-safe 97b509b
Karlson2k Karlson2k [Peripheral] Add iMON to PeripheralTypes.h 291e5fc
Karlson2k
Collaborator

@opdenkamp Did my best for removing extra #ifdefs.

Lars Op den Kamp

unrelated change

Collaborator

That was missing in one of my previous commits.
Yes, this is really unrelated.
Needs to be removed?

Karlson2k
Collaborator

New names are little bit hulky, but now they are self-explanatory.

Karlson2k
Collaborator

@opdenkamp Fixed linux build.
Tested on Ubuntu.

Lars Op den Kamp opdenkamp merged commit dfb4679 into from
Memphiz
Owner

@Karlson2k Next time you add a file please remember pinging a osx/ios dev for fixing the xcode projects for preventing build breakage. Thx.

Karlson2k
Collaborator

@Memphiz Thanks for point me to that problem. I'll do that next time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 1, 2012
  1. Karlson2k
  2. Karlson2k

    [Peripheral] Fix early lock.Leave() in UnregisterRemovedDevices in Pe…

    Karlson2k authored
    …ripheralBus.cpp and call OnDeviceRemoved for devices with features.
    
    CriticalSection was unlocked inside 'for', could potentially cause problem in case that other thread change list of peripheral.
    OnDeviceRemoved wasn't called for devices with type == UNKNOWN even if device is mapped to something with usable feature.
  3. Karlson2k
  4. Karlson2k
  5. Karlson2k
Commits on Oct 3, 2012
  1. Karlson2k
  2. Karlson2k
  3. Karlson2k
  4. Karlson2k
  5. Karlson2k
This page is out of date. Refresh to see the latest.
8 language/English/strings.po
View
@@ -10823,11 +10823,17 @@ msgstr ""
#empty strings from id 35010 to 35099
+#: xbmc/settings/GUISettings.cpp
msgctxt "#35100"
msgid "Enable joystick and gamepad support"
msgstr ""
-#empty strings from id 35101 to 35499
+#: xbmc/settings/GUISettings.cpp
+msgctxt "#35101"
+msgid "Disable joystick when iMON is present"
+msgstr ""
+
+#empty strings from id 35102 to 35499
msgctxt "#35500"
msgid "Location"
2  project/VS2010Express/XBMC.vcxproj
View
@@ -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>
6 project/VS2010Express/XBMC.vcxproj.filters
View
@@ -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>
4 system/peripherals.xml
View
@@ -49,4 +49,8 @@
<setting key="device_name" type="string" value="XBMC" configurable="0" />
<setting key="device_type" type="int" value="1" configurable="0" />
</peripheral>
+
+ <peripheral vendor_product="15C2:32,15C2:33,15C2:34,15C2:35,15C2:36,15C2:37,15C2:38,15C2:39,15C2:3A,15C2:3B,15C2:3C,15C2:3D,15C2:3E,15C2:3F,15C2:41,15C2:42,15C2:43,15C2:44,15C2:45,15C2:46" bus="usb" name="iMON HID device" mapTo="imon">
+ <setting key="do_not_use_custom_keymap" type="bool" value="1" label="35009" order="1" configurable="0"/>
+ </peripheral>
</peripherals>
4 xbmc/Application.cpp
View
@@ -176,6 +176,7 @@
#include "peripherals/Peripherals.h"
#include "peripherals/dialogs/GUIDialogPeripheralManager.h"
#include "peripherals/dialogs/GUIDialogPeripheralSettings.h"
+#include "peripherals/devices/PeripheralImon.h"
// Windows includes
#include "guilib/GUIWindowManager.h"
@@ -1417,7 +1418,8 @@ bool CApplication::Initialize()
ResetScreenSaver();
#ifdef HAS_SDL_JOYSTICK
- g_Joystick.SetEnabled(g_guiSettings.GetBool("input.enablejoystick"));
+ g_Joystick.SetEnabled(g_guiSettings.GetBool("input.enablejoystick") &&
+ (CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0 || !g_guiSettings.GetBool("input.disablejoystickwithimon")) );
#endif
return true;
3  xbmc/input/windows/WINJoystick.cpp
View
@@ -50,6 +50,7 @@ extern HWND g_hWnd;
CJoystick::CJoystick()
{
+ CSingleLock lock(m_critSection);
Reset(true);
m_joystickEnabled = false;
m_NumAxes = 0;
@@ -73,6 +74,7 @@ CJoystick::~CJoystick()
void CJoystick::ReleaseJoysticks()
{
+ CSingleLock lock(m_critSection);
// Unacquire the device one last time just in case
// the app tried to exit while the device is still acquired.
for(std::vector<LPDIRECTINPUTDEVICE8>::iterator it = m_pJoysticks.begin(); it != m_pJoysticks.end(); ++it)
@@ -182,6 +184,7 @@ void CJoystick::Initialize()
// clear old joystick names
ReleaseJoysticks();
+ CSingleLock lock(m_critSection);
if( FAILED( hr = DirectInput8Create( GetModuleHandle( NULL ), DIRECTINPUT_VERSION, IID_IDirectInput8, ( VOID** )&m_pDI, NULL ) ) )
{
2  xbmc/input/windows/WINJoystick.h
View
@@ -21,6 +21,7 @@
#include <vector>
#include <string>
+#include "threads/CriticalSection.h"
#define JACTIVE_BUTTON 0x00000001
#define JACTIVE_AXIS 0x00000002
@@ -84,6 +85,7 @@ class CJoystick
uint8_t m_ActiveFlags;
uint32_t m_lastPressTicks;
uint32_t m_lastTicks;
+ CCriticalSection m_critSection;
LPDIRECTINPUT8 m_pDI;
std::vector<LPDIRECTINPUTDEVICE8> m_pJoysticks;
10 xbmc/peripherals/PeripheralTypes.h
View
@@ -47,7 +47,8 @@ namespace PERIPHERALS
FEATURE_NYXBOARD,
FEATURE_CEC,
FEATURE_BLUETOOTH,
- FEATURE_TUNER
+ FEATURE_TUNER,
+ FEATURE_IMON
};
enum PeripheralType
@@ -59,7 +60,8 @@ namespace PERIPHERALS
PERIPHERAL_NYXBOARD,
PERIPHERAL_CEC,
PERIPHERAL_BLUETOOTH,
- PERIPHERAL_TUNER
+ PERIPHERAL_TUNER,
+ PERIPHERAL_IMON
};
struct PeripheralID
@@ -99,6 +101,8 @@ namespace PERIPHERALS
return "nyxboard";
case PERIPHERAL_TUNER:
return "tuner";
+ case PERIPHERAL_IMON:
+ return "imon";
default:
return "unknown";
}
@@ -123,6 +127,8 @@ namespace PERIPHERALS
return PERIPHERAL_NYXBOARD;
else if (strTypeLowerCase.Equals("tuner"))
return PERIPHERAL_TUNER;
+ else if (strTypeLowerCase.Equals("imon"))
+ return PERIPHERAL_IMON;
return PERIPHERAL_UNKNOWN;
};
5 xbmc/peripherals/Peripherals.cpp
View
@@ -27,6 +27,7 @@
#include "devices/PeripheralNyxboard.h"
#include "devices/PeripheralTuner.h"
#include "devices/PeripheralCecAdapter.h"
+#include "devices/PeripheralImon.h"
#include "bus/PeripheralBusUSB.h"
#include "dialogs/GUIDialogPeripheralManager.h"
@@ -286,6 +287,10 @@ CPeripheral *CPeripherals::CreatePeripheral(CPeripheralBus &bus, const Periphera
#endif
break;
+ case PERIPHERAL_IMON:
+ peripheral = new CPeripheralImon(type, bus.Type(), strLocation, strDeviceName, iVendorId, iProductId);
+ break;
+
default:
break;
}
26 xbmc/peripherals/bus/PeripheralBus.cpp
View
@@ -133,6 +133,7 @@ void CPeripheralBus::Clear(void)
void CPeripheralBus::UnregisterRemovedDevices(const PeripheralScanResults &results)
{
CSingleLock lock(m_critSection);
+ vector<CPeripheral *> removedPeripherals;
for (int iDevicePtr = (int) m_peripherals.size() - 1; iDevicePtr >= 0; iDevicePtr--)
{
CPeripheral *peripheral = m_peripherals.at(iDevicePtr);
@@ -141,17 +142,26 @@ void CPeripheralBus::UnregisterRemovedDevices(const PeripheralScanResults &resul
updatedDevice != *peripheral)
{
/* device removed */
- if (peripheral->Type() != PERIPHERAL_UNKNOWN)
- {
- CLog::Log(LOGNOTICE, "%s - device removed from %s/%s: %s (%s:%s)", __FUNCTION__, PeripheralTypeTranslator::TypeToString(peripheral->Type()), peripheral->Location().c_str(), peripheral->DeviceName().c_str(), peripheral->VendorIdAsString(), peripheral->ProductIdAsString());
- peripheral->OnDeviceRemoved();
- }
+ removedPeripherals.push_back(peripheral);
m_peripherals.erase(m_peripherals.begin() + iDevicePtr);
- lock.Leave();
+ }
+ }
+ lock.Leave();
- m_manager->OnDeviceDeleted(*this, *peripheral);
- delete peripheral;
+ for (unsigned int iDevicePtr = 0; iDevicePtr < removedPeripherals.size(); iDevicePtr++)
+ {
+ CPeripheral *peripheral = removedPeripherals.at(iDevicePtr);
+ vector<PeripheralFeature> features;
+ peripheral->GetFeatures(features);
+ bool peripheralHasFeatures = features.size() > 1 || (features.size() == 1 && features.at(0) != FEATURE_UNKNOWN);
+ if (peripheral->Type() != PERIPHERAL_UNKNOWN || peripheralHasFeatures)
+ {
+ CLog::Log(LOGNOTICE, "%s - device removed from %s/%s: %s (%s:%s)", __FUNCTION__, PeripheralTypeTranslator::TypeToString(peripheral->Type()), peripheral->Location().c_str(), peripheral->DeviceName().c_str(), peripheral->VendorIdAsString(), peripheral->ProductIdAsString());
+ peripheral->OnDeviceRemoved();
}
+
+ m_manager->OnDeviceDeleted(*this, *peripheral);
+ delete peripheral;
}
}
5 xbmc/peripherals/bus/PeripheralBus.h
View
@@ -92,9 +92,10 @@ namespace PERIPHERALS
virtual bool HasPeripheral(const CStdString &strLocation) const;
/*!
- * @brief Get the first instance of a peripheral that has the given feature.
+ * @brief Get all peripheral instances that have the given feature.
+ * @param results The list of results.
* @param feature The feature to search for.
- * @return The peripheral or NULL if it wasn't found.
+ * @return The number of devices that have been found.
*/
virtual int GetPeripheralsWithFeature(std::vector<CPeripheral *> &results, const PeripheralFeature feature) const;
1  xbmc/peripherals/devices/Makefile.in
View
@@ -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
92 xbmc/peripherals/devices/PeripheralImon.cpp
View
@@ -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
+ }
+}
+
42 xbmc/peripherals/devices/PeripheralImon.h
View
@@ -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;
+ };
+}
2  xbmc/settings/GUISettings.cpp
View
@@ -546,6 +546,8 @@ void CGUISettings::Initialize()
#endif
#if defined(HAS_SDL_JOYSTICK)
AddBool(in, "input.enablejoystick", 35100, true);
+ AddBool(in, "input.disablejoystickwithimon", 35101, true);
+ GetSetting("input.disablejoystickwithimon")->SetVisible(false);
#endif
CSettingsCategory* net = AddCategory(SETTINGS_SYSTEM, "network", 798);
12 xbmc/settings/GUIWindowSettingsCategory.cpp
View
@@ -84,6 +84,7 @@
#include "network/Zeroconf.h"
#include "peripherals/Peripherals.h"
#include "peripherals/dialogs/GUIDialogPeripheralManager.h"
+#include "peripherals/devices/PeripheralImon.h"
#ifdef _WIN32
#include "WIN32Util.h"
@@ -261,7 +262,11 @@ bool CGUIWindowSettingsCategory::OnMessage(CGUIMessage &message)
break;
case GUI_MSG_UPDATE:
if (HasID(message.GetSenderId()))
- UpdateSettings();
+ {
+ int focusedControl = GetFocusedControlID();
+ CreateSettings();
+ SET_CONTROL_FOCUS(focusedControl, 0);
+ }
break;
case GUI_MSG_NOTIFY_ALL:
{
@@ -1432,10 +1437,11 @@ void CGUIWindowSettingsCategory::OnSettingChanged(CBaseSettingControl *pSettingC
{
g_Mouse.SetEnabled(g_guiSettings.GetBool("input.enablemouse"));
}
- else if (strSetting.Equals("input.enablejoystick"))
+ else if (strSetting.Equals("input.enablejoystick") || strSetting.Equals("input.disablejoystickwithimon"))
{
#if defined(HAS_SDL_JOYSTICK)
- g_Joystick.SetEnabled(g_guiSettings.GetBool("input.enablejoystick"));
+ g_Joystick.SetEnabled(g_guiSettings.GetBool("input.enablejoystick")
+ && (CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0 || !g_guiSettings.GetBool("input.disablejoystickwithimon")) );
#endif
}
else if (strSetting.Equals("videoscreen.screen"))
Something went wrong with that request. Please try again.