Commit 46d35211 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dinput: Move device_instance_is_disabled to device.c.

parent 7d4d3944
......@@ -314,6 +314,54 @@ DWORD get_config_key( HKEY defkey, HKEY appkey, const WCHAR *name, WCHAR *buffer
return ERROR_FILE_NOT_FOUND;
}
BOOL device_instance_is_disabled( DIDEVICEINSTANCEW *instance, BOOL *override )
{
static const WCHAR disabled_str[] = {'d', 'i', 's', 'a', 'b', 'l', 'e', 'd', 0};
static const WCHAR override_str[] = {'o', 'v', 'e', 'r', 'r', 'i', 'd', 'e', 0};
static const WCHAR joystick_key[] = {'J', 'o', 'y', 's', 't', 'i', 'c', 'k', 's', 0};
WCHAR buffer[MAX_PATH];
HKEY hkey, appkey, temp;
BOOL disable = FALSE;
get_app_key( &hkey, &appkey );
if (override) *override = FALSE;
/* Joystick settings are in the 'joysticks' subkey */
if (appkey)
{
if (RegOpenKeyW( appkey, joystick_key, &temp )) temp = 0;
RegCloseKey( appkey );
appkey = temp;
}
if (hkey)
{
if (RegOpenKeyW( hkey, joystick_key, &temp )) temp = 0;
RegCloseKey( hkey );
hkey = temp;
}
/* Look for the "controllername"="disabled" key */
if (!get_config_key( hkey, appkey, instance->tszInstanceName, buffer, sizeof(buffer) ))
{
if (!strcmpW( disabled_str, buffer ))
{
TRACE( "Disabling joystick '%s' based on registry key.\n", debugstr_w(instance->tszInstanceName) );
disable = TRUE;
}
else if (override && !strcmpW( override_str, buffer ))
{
TRACE( "Force enabling joystick '%s' based on registry key.\n", debugstr_w(instance->tszInstanceName) );
*override = TRUE;
}
}
if (appkey) RegCloseKey( appkey );
if (hkey) RegCloseKey( hkey );
return disable;
}
/* Conversion between internal data buffer and external data buffer */
void fill_DataFormat(void *out, DWORD size, const void *in, const DataFormat *df)
{
......
......@@ -98,6 +98,7 @@ extern const IDirectInputDevice8AVtbl dinput_device_a_vtbl DECLSPEC_HIDDEN;
extern BOOL get_app_key(HKEY*, HKEY*) DECLSPEC_HIDDEN;
extern DWORD get_config_key( HKEY, HKEY, const WCHAR *, WCHAR *, DWORD ) DECLSPEC_HIDDEN;
extern BOOL device_instance_is_disabled( DIDEVICEINSTANCEW *instance, BOOL *override ) DECLSPEC_HIDDEN;
/* Routines to do DataFormat / WineFormat conversions */
extern void fill_DataFormat(void *out, DWORD size, const void *in, const DataFormat *df) DECLSPEC_HIDDEN;
......
......@@ -279,54 +279,6 @@ BOOL device_disabled_registry(const char* name)
return device_instance_is_disabled( &instance, NULL );
}
BOOL device_instance_is_disabled( DIDEVICEINSTANCEW *instance, BOOL *override )
{
static const WCHAR disabled_str[] = {'d', 'i', 's', 'a', 'b', 'l', 'e', 'd', 0};
static const WCHAR override_str[] = {'o', 'v', 'e', 'r', 'r', 'i', 'd', 'e', 0};
static const WCHAR joystick_key[] = {'J', 'o', 'y', 's', 't', 'i', 'c', 'k', 's', 0};
WCHAR buffer[MAX_PATH];
HKEY hkey, appkey, temp;
BOOL disable = FALSE;
get_app_key(&hkey, &appkey);
if (override) *override = FALSE;
/* Joystick settings are in the 'joysticks' subkey */
if (appkey)
{
if (RegOpenKeyW( appkey, joystick_key, &temp )) temp = 0;
RegCloseKey(appkey);
appkey = temp;
}
if (hkey)
{
if (RegOpenKeyW( hkey, joystick_key, &temp )) temp = 0;
RegCloseKey(hkey);
hkey = temp;
}
/* Look for the "controllername"="disabled" key */
if (!get_config_key( hkey, appkey, instance->tszInstanceName, buffer, sizeof(buffer) ))
{
if (!strcmpW( disabled_str, buffer ))
{
TRACE( "Disabling joystick '%s' based on registry key.\n", debugstr_w(instance->tszInstanceName) );
disable = TRUE;
}
else if (override && !strcmpW( override_str, buffer ))
{
TRACE( "Force enabling joystick '%s' based on registry key.\n", debugstr_w(instance->tszInstanceName) );
*override = TRUE;
}
}
if (appkey) RegCloseKey(appkey);
if (hkey) RegCloseKey(hkey);
return disable;
}
BOOL is_xinput_device(const DIDEVCAPS *devcaps, WORD vid, WORD pid)
{
int i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment