[2/3] dinput: Disable linuxinput or linux joysticks based on registry key (try 3)
Lucas Zawacki
lfzawacki at gmail.com
Fri Aug 24 02:55:07 CDT 2012
From: Lucas Zawacki <lfzawacki at gmail.com>
In the form of "controllername"="disabled" key under the 'Joysticks' subkey
This can help the users with bugs #26810 and #30690
---
dlls/dinput/joystick.c | 36 ++++++++++++++++++++++++++++++++++++
dlls/dinput/joystick_linux.c | 2 ++
dlls/dinput/joystick_linuxinput.c | 2 ++
dlls/dinput/joystick_private.h | 2 ++
4 files changed, 42 insertions(+)
diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c
index dfcaeb7..081b0d6 100644
--- a/dlls/dinput/joystick.c
+++ b/dlls/dinput/joystick.c
@@ -49,6 +49,42 @@ static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickGener
return &This->base.IDirectInputDevice8W_iface;
}
+BOOL device_disabled_registry(const char* name)
+{
+ static const char *disabled_str = "disabled";
+ static const char *joystick_key = "Joysticks";
+ char buffer[MAX_PATH];
+ HKEY hkey, appkey, temp;
+ BOOL do_disable = FALSE;
+
+ get_app_key(&hkey, &appkey);
+
+ /* Joystick settings are in the 'joysticks' subkey */
+ if (RegOpenKeyA(appkey, joystick_key, &temp) == ERROR_SUCCESS)
+ {
+ RegCloseKey(appkey);
+ appkey = temp;
+ }
+ else if (RegOpenKeyA(hkey, joystick_key, &temp) == ERROR_SUCCESS)
+ {
+ RegCloseKey(hkey);
+ hkey = temp;
+ }
+
+ /* Look for the "controllername"="disabled" key */
+ if (!get_config_key(hkey, appkey, name, buffer, sizeof(buffer)))
+ if (!strncmp(disabled_str, buffer, sizeof(disabled_str)))
+ {
+ TRACE("Disabling joystick '%s' based on registry key.\n", name);
+ do_disable = TRUE;
+ }
+
+ if (appkey) RegCloseKey(appkey);
+ if (hkey) RegCloseKey(hkey);
+
+ return do_disable;
+}
+
/******************************************************************************
* SetProperty : change input device properties
*/
diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c
index 9a24157..ed2498b 100644
--- a/dlls/dinput/joystick_linux.c
+++ b/dlls/dinput/joystick_linux.c
@@ -158,6 +158,8 @@ static INT find_joystick_devices(void)
/* Append driver name */
strcat(joydev.name, JOYDEVDRIVER);
+ if (device_disabled_registry(joydev.name)) continue;
+
#ifdef JSIOCGAXES
if (ioctl(fd, JSIOCGAXES, &joydev.axis_count) < 0)
{
diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c
index 808ebf4..341e169 100644
--- a/dlls/dinput/joystick_linuxinput.c
+++ b/dlls/dinput/joystick_linuxinput.c
@@ -251,6 +251,8 @@ static void find_joydevs(void)
else
joydev.name = joydev.device;
+ if (device_disabled_registry(joydev.name)) continue;
+
joydev.guid = DInput_Wine_Joystick_Base_GUID;
joydev.guid.Data3 += have_joydevs;
diff --git a/dlls/dinput/joystick_private.h b/dlls/dinput/joystick_private.h
index 71d91f1..483db66 100644
--- a/dlls/dinput/joystick_private.h
+++ b/dlls/dinput/joystick_private.h
@@ -57,6 +57,8 @@ HRESULT setup_dinput_options(JoystickGenericImpl *This, const int *default_axis_
DWORD joystick_map_pov(const POINTL *p) DECLSPEC_HIDDEN;
+BOOL device_disabled_registry(const char* name) DECLSPEC_HIDDEN;
+
HRESULT WINAPI JoystickWGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) DECLSPEC_HIDDEN;
--
1.7.9.5
More information about the wine-patches
mailing list