Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1536 from Karlson2k/Imon_addition_01

Replace system-wide iMON setting with per-device setting
  • Loading branch information...
commit 6671312465caf64feb5240ddd0ec2ccd9bdc780d 2 parents 0630b59 + 4c21c6c
davilla davilla authored
10 language/English/strings.po
View
@@ -11224,12 +11224,14 @@ msgctxt "#35100"
msgid "Enable joystick and gamepad support"
msgstr ""
-#: xbmc/settings/GUISettings.cpp
-msgctxt "#35101"
-msgid "Disable joystick when iMON is present"
+#empty string with id 35101
+
+#: system/peripherals.xml
+msgctxt "#35102"
+msgid "Disable joystick when device is present"
msgstr ""
-#empty strings from id 35102 to 35499
+#empty strings from id 35103 to 35499
msgctxt "#35500"
msgid "Location"
3  system/peripherals.xml
View
@@ -57,6 +57,7 @@
</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"/>
+ <setting key="do_not_use_custom_keymap" type="bool" value="1" label="35009" configurable="0"/>
+ <setting key="disable_winjoystick" type="bool" value="1" label="35102" order="1" />
</peripheral>
</peripherals>
2  xbmc/Application.cpp
View
@@ -1396,7 +1396,7 @@ bool CApplication::Initialize()
#ifdef HAS_SDL_JOYSTICK
g_Joystick.SetEnabled(g_guiSettings.GetBool("input.enablejoystick") &&
- (CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0 || !g_guiSettings.GetBool("input.disablejoystickwithimon")) );
+ CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0 );
#endif
return true;
61 xbmc/peripherals/devices/PeripheralImon.cpp
View
@@ -34,26 +34,21 @@
using namespace PERIPHERALS;
using namespace std;
-volatile long CPeripheralImon::m_CountOfImonsConflictWithDInput = 0;
+volatile long CPeripheralImon::m_lCountOfImonsConflictWithDInput = 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;
+ m_bImonConflictsWithDInput = false;
}
void CPeripheralImon::OnDeviceRemoved()
{
- if (m_ImonConflictsWithDInput)
+ if (m_bImonConflictsWithDInput)
{
- if (AtomicDecrement(&m_CountOfImonsConflictWithDInput) == 0)
+ if (AtomicDecrement(&m_lCountOfImonsConflictWithDInput) == 0)
ActionOnImonConflict(false);
}
}
@@ -62,9 +57,16 @@ bool CPeripheralImon::InitialiseFeature(const PeripheralFeature feature)
{
if (feature == FEATURE_IMON)
{
- if (m_ImonConflictsWithDInput)
+#if defined(TARGET_WINDOWS)
+ if (HasSetting("disable_winjoystick") && GetSettingBool("disable_winjoystick"))
+ m_bImonConflictsWithDInput = true;
+ else
+#endif // TARGET_WINDOWS
+ m_bImonConflictsWithDInput = false;
+
+ if (m_bImonConflictsWithDInput)
{
- AtomicIncrement(&m_CountOfImonsConflictWithDInput);
+ AtomicIncrement(&m_lCountOfImonsConflictWithDInput);
ActionOnImonConflict(true);
}
return CPeripheral::InitialiseFeature(feature);
@@ -73,19 +75,42 @@ bool CPeripheralImon::InitialiseFeature(const PeripheralFeature feature)
return CPeripheralHID::InitialiseFeature(feature);
}
+void CPeripheralImon::AddSetting(const CStdString &strKey, const CSetting *setting)
+{
+#if !defined(TARGET_WINDOWS)
+ if (strKey.compare("disable_winjoystick")!=0)
+#endif // !TARGET_WINDOWS
+ CPeripheralHID::AddSetting(strKey, setting);
+}
+
+void CPeripheralImon::OnSettingChanged(const CStdString &strChangedSetting)
+{
+ if (strChangedSetting.compare("disable_winjoystick") == 0)
+ {
+ if (m_bImonConflictsWithDInput && !GetSettingBool("disable_winjoystick"))
+ {
+ m_bImonConflictsWithDInput = false;
+ if (AtomicDecrement(&m_lCountOfImonsConflictWithDInput) == 0)
+ ActionOnImonConflict(false);
+ }
+ else if(!m_bImonConflictsWithDInput && GetSettingBool("disable_winjoystick"))
+ {
+ m_bImonConflictsWithDInput = true;
+ AtomicIncrement(&m_lCountOfImonsConflictWithDInput);
+ ActionOnImonConflict(true);
+ }
+ }
+}
+
void CPeripheralImon::ActionOnImonConflict(bool deviceInserted /*= true*/)
{
- if (deviceInserted || m_CountOfImonsConflictWithDInput == 0)
+ if (deviceInserted || m_lCountOfImonsConflictWithDInput == 0)
{
-#if defined(TARGET_WINDOWS) && defined (HAS_SDL_JOYSTICK)
- bool enableJoystickNow = (!deviceInserted || !g_guiSettings.GetBool("input.disablejoystickwithimon"))
- && g_guiSettings.GetBool("input.enablejoystick");
+#if defined(TARGET_WINDOWS) && defined(HAS_SDL_JOYSTICK)
+ bool enableJoystickNow = !deviceInserted && 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
}
}
11 xbmc/peripherals/devices/PeripheralImon.h
View
@@ -29,14 +29,17 @@ namespace PERIPHERALS
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 OnSettingChanged(const CStdString &strChangedSetting);
virtual void OnDeviceRemoved();
+ virtual void AddSetting(const CStdString &strKey, const CSetting *setting);
inline bool IsImonConflictsWithDInput()
- { return m_ImonConflictsWithDInput;}
+ { return m_bImonConflictsWithDInput;}
static inline long GetCountOfImonsConflictWithDInput()
- { return m_CountOfImonsConflictWithDInput; }
+ { return m_lCountOfImonsConflictWithDInput; }
static void ActionOnImonConflict(bool deviceInserted = true);
+
private:
- bool m_ImonConflictsWithDInput;
- static volatile long m_CountOfImonsConflictWithDInput;
+ bool m_bImonConflictsWithDInput;
+ static volatile long m_lCountOfImonsConflictWithDInput;
};
}
2  xbmc/settings/GUISettings.cpp
View
@@ -545,8 +545,6 @@ 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
@@ -1016,6 +1016,12 @@ void CGUIWindowSettingsCategory::UpdateSettings()
if (pControl)
pControl->SetEnabled(g_peripherals.GetNumberOfPeripherals() > 0);
}
+ else if (strSetting.Equals("input.enablejoystick"))
+ {
+ CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
+ if (pControl)
+ pControl->SetEnabled(CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0);
+ }
}
g_guiSettings.SetChanged();
@@ -1061,6 +1067,8 @@ void CGUIWindowSettingsCategory::OnClick(CBaseSettingControl *pSettingControl)
CGUIDialogPeripheralManager *dialog = (CGUIDialogPeripheralManager *)g_windowManager.GetWindow(WINDOW_DIALOG_PERIPHERAL_MANAGER);
if (dialog)
dialog->DoModal();
+ // refresh settings
+ UpdateSettings();
return;
}
@@ -1442,11 +1450,11 @@ void CGUIWindowSettingsCategory::OnSettingChanged(CBaseSettingControl *pSettingC
{
g_Mouse.SetEnabled(g_guiSettings.GetBool("input.enablemouse"));
}
- else if (strSetting.Equals("input.enablejoystick") || strSetting.Equals("input.disablejoystickwithimon"))
+ else if (strSetting.Equals("input.enablejoystick"))
{
#if defined(HAS_SDL_JOYSTICK)
g_Joystick.SetEnabled(g_guiSettings.GetBool("input.enablejoystick")
- && (CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0 || !g_guiSettings.GetBool("input.disablejoystickwithimon")) );
+ && CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0);
#endif
}
else if (strSetting.Equals("videoscreen.screen"))
Please sign in to comment.
Something went wrong with that request. Please try again.