Aric Stewart : dinput: Add JoystickID to the Instance Name.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Apr 8 10:40:45 CDT 2015
Module: wine
Branch: master
Commit: 3d30db22484c119d65e1fa476662bd6a4a3eea21
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3d30db22484c119d65e1fa476662bd6a4a3eea21
Author: Aric Stewart <aric at codeweavers.com>
Date: Tue Apr 7 10:00:31 2015 -0500
dinput: Add JoystickID to the Instance Name.
---
dlls/dinput/joystick.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c
index 547ba56..9425c0b 100644
--- a/dlls/dinput/joystick.c
+++ b/dlls/dinput/joystick.c
@@ -26,6 +26,8 @@
* force feedback
*/
+#include <stdio.h>
+
#include "joystick_private.h"
#include "wine/debug.h"
#include "winreg.h"
@@ -608,6 +610,8 @@ HRESULT WINAPI JoystickAGenericImpl_GetDeviceInfo(
LPDIDEVICEINSTANCEA pdidi)
{
JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface);
+ DIPROPDWORD pd;
+ DWORD index = 0;
TRACE("(%p,%p)\n", iface, pdidi);
@@ -622,12 +626,20 @@ HRESULT WINAPI JoystickAGenericImpl_GetDeviceInfo(
return DIERR_INVALIDPARAM;
}
+ /* Try to get joystick index */
+ pd.diph.dwSize = sizeof(pd);
+ pd.diph.dwHeaderSize = sizeof(pd.diph);
+ pd.diph.dwObj = 0;
+ pd.diph.dwHow = DIPH_DEVICE;
+ if (SUCCEEDED(IDirectInputDevice2_GetProperty(iface, DIPROP_JOYSTICKID, &pd.diph)))
+ index = pd.dwData;
+
/* Return joystick */
pdidi->guidInstance = This->guidInstance;
pdidi->guidProduct = This->guidProduct;
/* we only support traditional joysticks for now */
pdidi->dwDevType = This->devcaps.dwDevType;
- strcpy(pdidi->tszInstanceName, "Joystick");
+ snprintf(pdidi->tszInstanceName, MAX_PATH, "Joystick %d", index);
strcpy(pdidi->tszProductName, This->name);
if (pdidi->dwSize > sizeof(DIDEVICEINSTANCE_DX3A)) {
pdidi->guidFFDriver = GUID_NULL;
@@ -646,6 +658,9 @@ HRESULT WINAPI JoystickWGenericImpl_GetDeviceInfo(
LPDIDEVICEINSTANCEW pdidi)
{
JoystickGenericImpl *This = impl_from_IDirectInputDevice8W(iface);
+ CHAR buffer[MAX_PATH];
+ DIPROPDWORD pd;
+ DWORD index = 0;
TRACE("(%p,%p)\n", iface, pdidi);
@@ -655,12 +670,21 @@ HRESULT WINAPI JoystickWGenericImpl_GetDeviceInfo(
return DIERR_INVALIDPARAM;
}
+ /* Try to get joystick index */
+ pd.diph.dwSize = sizeof(pd);
+ pd.diph.dwHeaderSize = sizeof(pd.diph);
+ pd.diph.dwObj = 0;
+ pd.diph.dwHow = DIPH_DEVICE;
+ if (SUCCEEDED(IDirectInputDevice2_GetProperty(iface, DIPROP_JOYSTICKID, &pd.diph)))
+ index = pd.dwData;
+
/* Return joystick */
pdidi->guidInstance = This->guidInstance;
pdidi->guidProduct = This->guidProduct;
/* we only support traditional joysticks for now */
pdidi->dwDevType = This->devcaps.dwDevType;
- MultiByteToWideChar(CP_ACP, 0, "Joystick", -1, pdidi->tszInstanceName, MAX_PATH);
+ snprintf(buffer, sizeof(buffer), "Joystick %d", index);
+ MultiByteToWideChar(CP_ACP, 0, buffer, -1, pdidi->tszInstanceName, MAX_PATH);
MultiByteToWideChar(CP_ACP, 0, This->name, -1, pdidi->tszProductName, MAX_PATH);
if (pdidi->dwSize > sizeof(DIDEVICEINSTANCE_DX3W)) {
pdidi->guidFFDriver = GUID_NULL;
More information about the wine-cvs
mailing list