dinput: Add a helper function to open configuration registry keys.
This commit is contained in:
parent
319097f563
commit
8ff85c08b6
|
@ -217,6 +217,41 @@ void _dump_DIDATAFORMAT(const DIDATAFORMAT *df) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Get the default and the app-specific config keys.
|
||||||
|
*/
|
||||||
|
BOOL get_app_key(HKEY *defkey, HKEY *appkey)
|
||||||
|
{
|
||||||
|
char buffer[MAX_PATH+16];
|
||||||
|
DWORD len;
|
||||||
|
|
||||||
|
*appkey = 0;
|
||||||
|
|
||||||
|
/* @@ Wine registry key: HKCU\Software\Wine\DirectInput */
|
||||||
|
if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\DirectInput", defkey))
|
||||||
|
*defkey = 0;
|
||||||
|
|
||||||
|
len = GetModuleFileNameA(0, buffer, MAX_PATH);
|
||||||
|
if (len && len < MAX_PATH)
|
||||||
|
{
|
||||||
|
HKEY tmpkey;
|
||||||
|
|
||||||
|
/* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectInput */
|
||||||
|
if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey))
|
||||||
|
{
|
||||||
|
char *p, *appname = buffer;
|
||||||
|
if ((p = strrchr(appname, '/'))) appname = p + 1;
|
||||||
|
if ((p = strrchr(appname, '\\'))) appname = p + 1;
|
||||||
|
strcat(appname, "\\DirectInput");
|
||||||
|
|
||||||
|
if (RegOpenKeyA(tmpkey, appname, appkey)) appkey = 0;
|
||||||
|
RegCloseKey(tmpkey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *defkey || *appkey;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Get a config key from either the app-specific or the default config
|
* Get a config key from either the app-specific or the default config
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -72,6 +72,7 @@ struct IDirectInputDevice2AImpl
|
||||||
DataFormat data_format; /* user data format and wine to user format converter */
|
DataFormat data_format; /* user data format and wine to user format converter */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern BOOL get_app_key(HKEY*, HKEY*);
|
||||||
extern DWORD get_config_key(HKEY, HKEY, const char*, char*, DWORD);
|
extern DWORD get_config_key(HKEY, HKEY, const char*, char*, DWORD);
|
||||||
|
|
||||||
/* Routines to do DataFormat / WineFormat conversions */
|
/* Routines to do DataFormat / WineFormat conversions */
|
||||||
|
|
|
@ -269,28 +269,11 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
|
||||||
static HRESULT setup_dinput_options(JoystickImpl * device)
|
static HRESULT setup_dinput_options(JoystickImpl * device)
|
||||||
{
|
{
|
||||||
char buffer[MAX_PATH+16];
|
char buffer[MAX_PATH+16];
|
||||||
HKEY hkey, appkey = 0;
|
HKEY hkey, appkey;
|
||||||
DWORD len;
|
|
||||||
|
|
||||||
buffer[MAX_PATH]='\0';
|
buffer[MAX_PATH]='\0';
|
||||||
|
|
||||||
/* @@ Wine registry key: HKCU\Software\Wine\DirectInput */
|
get_app_key(&hkey, &appkey);
|
||||||
if (RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\DirectInput", &hkey)) hkey = 0;
|
|
||||||
|
|
||||||
len = GetModuleFileNameA( 0, buffer, MAX_PATH );
|
|
||||||
if (len && len < MAX_PATH) {
|
|
||||||
HKEY tmpkey;
|
|
||||||
/* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectInput */
|
|
||||||
if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey ))
|
|
||||||
{
|
|
||||||
char *p, *appname = buffer;
|
|
||||||
if ((p = strrchr( appname, '/' ))) appname = p + 1;
|
|
||||||
if ((p = strrchr( appname, '\\' ))) appname = p + 1;
|
|
||||||
strcat( appname, "\\DirectInput" );
|
|
||||||
if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0;
|
|
||||||
RegCloseKey( tmpkey );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get options */
|
/* get options */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue