Lucas Zawacki : dinput: Disable linuxinput or linux joysticks based on registry key.
Alexandre Julliard
julliard at winehq.org
Fri Aug 24 13:46:43 CDT 2012
Module: wine
Branch: master
Commit: 3da6f1754efa0311e00c63cea1465c2afb62369e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3da6f1754efa0311e00c63cea1465c2afb62369e
Author: Lucas Zawacki <lfzawacki at gmail.com>
Date: Fri Aug 24 04:55:07 2012 -0300
dinput: Disable linuxinput or linux joysticks based on registry key.
---
dlls/dinput/joystick.c | 38 +++++++++++++++++++++++++++++++++++++
dlls/dinput/joystick_linux.c | 2 +
dlls/dinput/joystick_linuxinput.c | 2 +
dlls/dinput/joystick_private.h | 2 +
4 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c
index dfcaeb7..0f7ba19 100644
--- a/dlls/dinput/joystick.c
+++ b/dlls/dinput/joystick.c
@@ -49,6 +49,44 @@ 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 (appkey)
+ {
+ if (RegOpenKeyA(appkey, joystick_key, &temp)) temp = 0;
+ RegCloseKey(appkey);
+ appkey = temp;
+ }
+ if (hkey)
+ {
+ if (RegOpenKeyA(hkey, joystick_key, &temp)) temp = 0;
+ 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;
More information about the wine-cvs
mailing list