From 3da6f1754efa0311e00c63cea1465c2afb62369e Mon Sep 17 00:00:00 2001 From: Lucas Zawacki Date: Fri, 24 Aug 2012 04:55:07 -0300 Subject: [PATCH] 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(+) diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c index dfcaeb7fc37..0f7ba196baa 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 9a24157b48a..ed2498b61fa 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 808ebf4d4b9..341e169e330 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 71d91f14f5b..483db66e1e0 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;