[DINPUT] test fixes
Robert Reif
reif at earthlink.net
Thu May 12 22:01:17 CDT 2005
Fix SetProperty error returned.
Add EnumDevice joystick version check.
Test multiple versions.
I am guessing on the error returned for the DX3 joystick test
because I don't have access to a machine with that version.
I will fix it if necessary based on wintest results.
-------------- next part --------------
Index: dlls/dinput/dinput_main.c
===================================================================
RCS file: /home/wine/wine/dlls/dinput/dinput_main.c,v
retrieving revision 1.53
diff -u -p -r1.53 dinput_main.c
--- dlls/dinput/dinput_main.c 10 May 2005 13:17:03 -0000 1.53
+++ dlls/dinput/dinput_main.c 13 May 2005 02:50:44 -0000
@@ -95,6 +95,7 @@ HRESULT WINAPI DirectInputCreateEx(
This->lpVtbl = &ddi7avt;
This->ref = 1;
This->version = 1;
+ This->dwVersion = dwVersion;
*ppDI = This;
return DI_OK;
@@ -107,6 +108,7 @@ HRESULT WINAPI DirectInputCreateEx(
This->lpVtbl = &ddi7wvt;
This->ref = 1;
This->version = 1;
+ This->dwVersion = dwVersion;
*ppDI = This;
return DI_OK;
@@ -117,6 +119,7 @@ HRESULT WINAPI DirectInputCreateEx(
This->lpVtbl = &ddi8avt;
This->ref = 1;
This->version = 8;
+ This->dwVersion = dwVersion;
*ppDI = This;
return DI_OK;
@@ -127,6 +130,7 @@ HRESULT WINAPI DirectInputCreateEx(
This->lpVtbl = &ddi8wvt;
This->ref = 1;
This->version = 8;
+ This->dwVersion = dwVersion;
*ppDI = This;
return DI_OK;
@@ -145,6 +149,7 @@ HRESULT WINAPI DirectInputCreateA(HINSTA
This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi7avt;
This->ref = 1;
+ This->dwVersion = dwVersion;
if (dwVersion >= 0x0800) {
This->version = 8;
} else {
@@ -166,6 +171,7 @@ HRESULT WINAPI DirectInputCreateW(HINSTA
This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi7wvt;
This->ref = 1;
+ This->dwVersion = dwVersion;
if (dwVersion >= 0x0800) {
This->version = 8;
} else {
@@ -227,7 +233,11 @@ static HRESULT WINAPI IDirectInputAImpl_
This, dwDevType, _dump_DIDEVTYPE_value(dwDevType),
lpCallback, pvRef, dwFlags);
TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
-
+
+ /* joysticks are not supported in version 0x0300 */
+ if ((dwDevType == DIDEVTYPE_JOYSTICK) && (This->dwVersion <= 0x0300))
+ return E_INVALIDARG;
+
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
if (!dinput_devices[i]->enum_deviceA) continue;
for (j = 0, r = -1; r != 0; j++) {
@@ -257,7 +267,11 @@ static HRESULT WINAPI IDirectInputWImpl_
This, dwDevType, _dump_DIDEVTYPE_value(dwDevType),
lpCallback, pvRef, dwFlags);
TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
-
+
+ /* joysticks are not supported in version 0x0300 */
+ if ((dwDevType == DIDEVTYPE_JOYSTICK) && (This->dwVersion <= 0x0300))
+ return E_INVALIDARG;
+
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
if (!dinput_devices[i]->enum_deviceW) continue;
for (j = 0, r = -1; r != 0; j++) {
Index: dlls/dinput/dinput_private.h
===================================================================
RCS file: /home/wine/wine/dlls/dinput/dinput_private.h,v
retrieving revision 1.14
diff -u -p -r1.14 dinput_private.h
--- dlls/dinput/dinput_private.h 15 Mar 2005 19:36:15 -0000 1.14
+++ dlls/dinput/dinput_private.h 13 May 2005 02:50:44 -0000
@@ -36,6 +36,7 @@ struct IDirectInputImpl
DWORD evsequence;
int version;
+ DWORD dwVersion;
};
/* Function called by all devices that Wine supports */
Index: dlls/dinput/joystick_linux.c
===================================================================
RCS file: /home/wine/wine/dlls/dinput/joystick_linux.c,v
retrieving revision 1.24
diff -u -p -r1.24 joystick_linux.c
--- dlls/dinput/joystick_linux.c 10 May 2005 13:17:03 -0000 1.24
+++ dlls/dinput/joystick_linux.c 13 May 2005 02:50:46 -0000
@@ -1125,7 +1125,7 @@ static HRESULT WINAPI JoystickAImpl_SetP
if (ph == NULL) {
WARN("invalid pointer\n");
- return E_POINTER;
+ return E_INVALIDARG;
}
if (TRACE_ON(dinput))
Index: dlls/dinput/tests/joystick.c
===================================================================
RCS file: /home/wine/wine/dlls/dinput/tests/joystick.c,v
retrieving revision 1.1
diff -u -p -r1.1 joystick.c
--- dlls/dinput/tests/joystick.c 11 May 2005 12:05:17 -0000 1.1
+++ dlls/dinput/tests/joystick.c 13 May 2005 02:50:46 -0000
@@ -35,6 +35,11 @@
#define numObjects(x) (sizeof(x) / sizeof(x[0]))
+typedef struct tagUserData {
+ LPDIRECTINPUT pDI;
+ DWORD version;
+} UserData;
+
static const DIOBJECTDATAFORMAT dfDIJoystickTest[] = {
{ &GUID_XAxis,DIJOFS_X,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
{ &GUID_YAxis,DIJOFS_Y,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
@@ -103,8 +108,8 @@ static BOOL CALLBACK EnumAxes(
diprg.lMax = +1000;
hr = IDirectInputDevice_SetProperty(info->pJoystick, DIPROP_RANGE, NULL);
- ok(hr==E_POINTER,"IDirectInputDevice_SetProperty() should have returned "
- "E_POINTER, returned: %s\n", DXGetErrorString8(hr));
+ ok(hr==E_INVALIDARG,"IDirectInputDevice_SetProperty() should have returned "
+ "E_INVALIDARG, returned: %s\n", DXGetErrorString8(hr));
hr = IDirectInputDevice_SetProperty(info->pJoystick, DIPROP_RANGE, &diprg.diph);
ok(hr==DI_OK,"IDirectInputDevice_SetProperty() failed: %s\n", DXGetErrorString8(hr));
@@ -123,7 +128,7 @@ static BOOL CALLBACK EnumJoysticks(
LPVOID pvRef)
{
HRESULT hr;
- LPDIRECTINPUT pDI = (LPDIRECTINPUT)pvRef;
+ UserData * data = (UserData *)pvRef;
LPDIRECTINPUTDEVICE pJoystick;
DIDATAFORMAT format;
DIDEVCAPS caps;
@@ -132,19 +137,20 @@ static BOOL CALLBACK EnumJoysticks(
int i, count;
ULONG ref;
- hr = IDirectInput_CreateDevice(pDI, &lpddi->guidInstance, NULL, NULL);
+ hr = IDirectInput_CreateDevice(data->pDI, &lpddi->guidInstance, NULL, NULL);
ok(hr==E_POINTER,"IDirectInput_CreateDevice() should have returned "
"E_POINTER, returned: %s\n", DXGetErrorString8(hr));
- hr = IDirectInput_CreateDevice(pDI, NULL, &pJoystick, NULL);
+ hr = IDirectInput_CreateDevice(data->pDI, NULL, &pJoystick, NULL);
ok(hr==E_POINTER,"IDirectInput_CreateDevice() should have returned "
"E_POINTER, returned: %s\n", DXGetErrorString8(hr));
- hr = IDirectInput_CreateDevice(pDI, NULL, NULL, NULL);
+ hr = IDirectInput_CreateDevice(data->pDI, NULL, NULL, NULL);
ok(hr==E_POINTER,"IDirectInput_CreateDevice() should have returned "
"E_POINTER, returned: %s\n", DXGetErrorString8(hr));
- hr = IDirectInput_CreateDevice(pDI, &lpddi->guidInstance, &pJoystick, NULL);
+ hr = IDirectInput_CreateDevice(data->pDI, &lpddi->guidInstance,
+ &pJoystick, NULL);
ok(hr==DI_OK,"IDirectInput_CreateDevice() failed: %s\n",
DXGetErrorString8(hr));
if (hr!=DI_OK)
@@ -260,22 +266,34 @@ DONE:
return DIENUM_CONTINUE;
}
-static void joystick_tests()
+static void joystick_tests(DWORD version)
{
HRESULT hr;
LPDIRECTINPUT pDI;
ULONG ref;
- hr = DirectInputCreate(GetModuleHandle(NULL), DIRECTINPUT_VERSION, &pDI, NULL);
- ok(hr==DI_OK, "DirectInputCreate() failed: %s\n", DXGetErrorString8(hr));
- if (hr!=DI_OK)
- return;
-
- hr = IDirectInput_EnumDevices(pDI, DIDEVTYPE_JOYSTICK, EnumJoysticks, pDI, DIEDFL_ALLDEVICES);
- ok(hr==DI_OK,"IDirectInput_EnumDevices() failed: %s\n", DXGetErrorString8(hr));
-
- ref = IDirectInput_Release(pDI);
- ok(ref==0,"IDirectInput_Release() reference count = %ld\n", ref);
+ trace("-- Testing Direct Input Version 0x%04lx --\n", version);
+ hr = DirectInputCreate(GetModuleHandle(NULL), version, &pDI, NULL);
+ ok(hr==DI_OK||hr==DIERR_OLDDIRECTINPUTVERSION,
+ "DirectInputCreate() failed: %s\n", DXGetErrorString8(hr));
+ if (hr==DI_OK && pDI!=0) {
+ UserData data;
+ data.pDI = pDI;
+ data.version = version;
+ hr = IDirectInput_EnumDevices(pDI, DIDEVTYPE_JOYSTICK, EnumJoysticks,
+ &data, DIEDFL_ALLDEVICES);
+ if (version == 0x0300) {
+ trace(" Joysticks Not Supported\n");
+ ok(hr==E_INVALIDARG,"IDirectInput_EnumDevices() should have "
+ "returned E_INVALIDARG, returned: %s\n", DXGetErrorString8(hr));
+ } else {
+ ok(hr==DI_OK,"IDirectInput_EnumDevices() failed: %s\n",
+ DXGetErrorString8(hr));
+ }
+ ref = IDirectInput_Release(pDI);
+ ok(ref==0,"IDirectInput_Release() reference count = %ld\n", ref);
+ } else if (hr==DIERR_OLDDIRECTINPUTVERSION)
+ trace(" Version Not Supported\n");
}
START_TEST(joystick)
@@ -284,7 +302,9 @@ START_TEST(joystick)
trace("DLL Version: %s\n", get_file_version("dinput.dll"));
- joystick_tests();
+ joystick_tests(0x0700);
+ joystick_tests(0x0500);
+ joystick_tests(0x0300);
CoUninitialize();
}
More information about the wine-patches
mailing list