dinput: Support disabled by default option in device_disabled_registry.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-08-25 18:20:26 +02:00 committed by Alexandre Julliard
parent 2726644124
commit 0ba137e36d
4 changed files with 15 additions and 8 deletions

View file

@ -271,13 +271,13 @@ void dump_DIEFFECT(LPCDIEFFECT eff, REFGUID guid, DWORD dwFlags)
}
}
BOOL device_disabled_registry(const char* name)
BOOL device_disabled_registry(const char* name, BOOL disable)
{
static const char disabled_str[] = "disabled";
static const char enabled_str[] = "enabled";
static const char joystick_key[] = "Joysticks";
char buffer[MAX_PATH];
HKEY hkey, appkey, temp;
BOOL do_disable = FALSE;
get_app_key(&hkey, &appkey);
@ -297,16 +297,23 @@ BOOL device_disabled_registry(const char* name)
/* Look for the "controllername"="disabled" key */
if (!get_config_key(hkey, appkey, name, buffer, sizeof(buffer)))
if (!strcmp(disabled_str, buffer))
{
if (!disable && !strcmp(disabled_str, buffer))
{
TRACE("Disabling joystick '%s' based on registry key.\n", name);
do_disable = TRUE;
disable = TRUE;
}
else if (disable && !strcmp(enabled_str, buffer))
{
TRACE("Enabling joystick '%s' based on registry key.\n", name);
disable = FALSE;
}
}
if (appkey) RegCloseKey(appkey);
if (hkey) RegCloseKey(hkey);
return do_disable;
return disable;
}
BOOL is_xinput_device(const DIDEVCAPS *devcaps, WORD vid, WORD pid)

View file

@ -175,7 +175,7 @@ static INT find_joystick_devices(void)
/* Append driver name */
strcat(joydev.name, JOYDEVDRIVER);
if (device_disabled_registry(joydev.name)) {
if (device_disabled_registry(joydev.name, FALSE)) {
close(fd);
continue;
}

View file

@ -264,7 +264,7 @@ static void find_joydevs(void)
else
joydev.name = joydev.device;
if (device_disabled_registry(joydev.name)) {
if (device_disabled_registry(joydev.name, FALSE)) {
close(fd);
HeapFree(GetProcessHeap(), 0, joydev.name);
if (joydev.name != joydev.device)

View file

@ -57,7 +57,7 @@ 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;
BOOL device_disabled_registry(const char* name, BOOL disable) DECLSPEC_HIDDEN;
ULONG WINAPI JoystickWGenericImpl_Release(LPDIRECTINPUTDEVICE8W iface);