Vitaliy Margolen : dinput: Add a helper function to open configuration registry keys.
Alexandre Julliard
julliard at winehq.org
Tue Sep 25 07:50:52 CDT 2007
Module: wine
Branch: master
Commit: 8ff85c08b6bbf45b58fbbc1d374f5e1c051eda2f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8ff85c08b6bbf45b58fbbc1d374f5e1c051eda2f
Author: Vitaliy Margolen <wine-patches at kievinfo.com>
Date: Mon Sep 24 19:34:32 2007 -0600
dinput: Add a helper function to open configuration registry keys.
---
dlls/dinput/device.c | 35 +++++++++++++++++++++++++++++++++++
dlls/dinput/device_private.h | 1 +
dlls/dinput/joystick_linux.c | 21 ++-------------------
3 files changed, 38 insertions(+), 19 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index d1c94fc..170d8fd 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -218,6 +218,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
*/
DWORD get_config_key( HKEY defkey, HKEY appkey, const char *name,
diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h
index b855c1b..edd1f4b 100644
--- a/dlls/dinput/device_private.h
+++ b/dlls/dinput/device_private.h
@@ -72,6 +72,7 @@ struct IDirectInputDevice2AImpl
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);
/* Routines to do DataFormat / WineFormat conversions */
diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c
index 0f821de..000837d 100644
--- a/dlls/dinput/joystick_linux.c
+++ b/dlls/dinput/joystick_linux.c
@@ -269,28 +269,11 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
static HRESULT setup_dinput_options(JoystickImpl * device)
{
char buffer[MAX_PATH+16];
- HKEY hkey, appkey = 0;
- DWORD len;
+ HKEY hkey, appkey;
buffer[MAX_PATH]='\0';
- /* @@ Wine registry key: HKCU\Software\Wine\DirectInput */
- 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_app_key(&hkey, &appkey);
/* get options */
More information about the wine-cvs
mailing list