Pass around real version and do correct thing based on it.

Change cooperative level to pass on windows.
This commit is contained in:
Robert Reif 2005-05-16 08:44:14 +00:00 committed by Alexandre Julliard
parent 5d90f2bcf9
commit 6dd763e03b
7 changed files with 95 additions and 92 deletions

View File

@ -94,7 +94,6 @@ HRESULT WINAPI DirectInputCreateEx(
This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl)); This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi7avt; This->lpVtbl = &ddi7avt;
This->ref = 1; This->ref = 1;
This->version = 1;
This->dwVersion = dwVersion; This->dwVersion = dwVersion;
*ppDI = This; *ppDI = This;
@ -107,7 +106,6 @@ HRESULT WINAPI DirectInputCreateEx(
This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl)); This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi7wvt; This->lpVtbl = &ddi7wvt;
This->ref = 1; This->ref = 1;
This->version = 1;
This->dwVersion = dwVersion; This->dwVersion = dwVersion;
*ppDI = This; *ppDI = This;
@ -118,7 +116,6 @@ HRESULT WINAPI DirectInputCreateEx(
This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl)); This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi8avt; This->lpVtbl = &ddi8avt;
This->ref = 1; This->ref = 1;
This->version = 8;
This->dwVersion = dwVersion; This->dwVersion = dwVersion;
*ppDI = This; *ppDI = This;
@ -129,7 +126,6 @@ HRESULT WINAPI DirectInputCreateEx(
This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl)); This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi8wvt; This->lpVtbl = &ddi8wvt;
This->ref = 1; This->ref = 1;
This->version = 8;
This->dwVersion = dwVersion; This->dwVersion = dwVersion;
*ppDI = This; *ppDI = This;
@ -150,12 +146,6 @@ HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPU
This->lpVtbl = &ddi7avt; This->lpVtbl = &ddi7avt;
This->ref = 1; This->ref = 1;
This->dwVersion = dwVersion; This->dwVersion = dwVersion;
if (dwVersion >= 0x0800) {
This->version = 8;
} else {
/* We do not differientiate between version 1, 2 and 7 */
This->version = 1;
}
*ppDI = (IDirectInputA*)This; *ppDI = (IDirectInputA*)This;
return 0; return 0;
@ -172,12 +162,6 @@ HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPU
This->lpVtbl = &ddi7wvt; This->lpVtbl = &ddi7wvt;
This->ref = 1; This->ref = 1;
This->dwVersion = dwVersion; This->dwVersion = dwVersion;
if (dwVersion >= 0x0800) {
This->version = 8;
} else {
/* We do not differientiate between version 1, 2 and 7 */
This->version = 1;
}
*ppDI = (IDirectInputW*)This; *ppDI = (IDirectInputW*)This;
return 0; return 0;
} }
@ -234,16 +218,12 @@ static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
lpCallback, pvRef, dwFlags); lpCallback, pvRef, dwFlags);
TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n"); 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++) { for (i = 0; i < NB_DINPUT_DEVICES; i++) {
if (!dinput_devices[i]->enum_deviceA) continue; if (!dinput_devices[i]->enum_deviceA) continue;
for (j = 0, r = -1; r != 0; j++) { for (j = 0, r = -1; r != 0; j++) {
devInstance.dwSize = sizeof(devInstance); devInstance.dwSize = sizeof(devInstance);
TRACE(" - checking device %d ('%s')\n", i, dinput_devices[i]->name); TRACE(" - checking device %d ('%s')\n", i, dinput_devices[i]->name);
if ((r = dinput_devices[i]->enum_deviceA(dwDevType, dwFlags, &devInstance, This->version, j))) { if ((r = dinput_devices[i]->enum_deviceA(dwDevType, dwFlags, &devInstance, This->dwVersion, j))) {
if (lpCallback(&devInstance,pvRef) == DIENUM_STOP) if (lpCallback(&devInstance,pvRef) == DIENUM_STOP)
return 0; return 0;
} }
@ -268,16 +248,12 @@ static HRESULT WINAPI IDirectInputWImpl_EnumDevices(
lpCallback, pvRef, dwFlags); lpCallback, pvRef, dwFlags);
TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n"); 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++) { for (i = 0; i < NB_DINPUT_DEVICES; i++) {
if (!dinput_devices[i]->enum_deviceW) continue; if (!dinput_devices[i]->enum_deviceW) continue;
for (j = 0, r = -1; r != 0; j++) { for (j = 0, r = -1; r != 0; j++) {
devInstance.dwSize = sizeof(devInstance); devInstance.dwSize = sizeof(devInstance);
TRACE(" - checking device %d ('%s')\n", i, dinput_devices[i]->name); TRACE(" - checking device %d ('%s')\n", i, dinput_devices[i]->name);
if ((r = dinput_devices[i]->enum_deviceW(dwDevType, dwFlags, &devInstance, This->version, j))) { if ((r = dinput_devices[i]->enum_deviceW(dwDevType, dwFlags, &devInstance, This->dwVersion, j))) {
if (lpCallback(&devInstance,pvRef) == DIENUM_STOP) if (lpCallback(&devInstance,pvRef) == DIENUM_STOP)
return 0; return 0;
} }

View File

@ -35,15 +35,14 @@ struct IDirectInputImpl
/* Used to have an unique sequence number for all the events */ /* Used to have an unique sequence number for all the events */
DWORD evsequence; DWORD evsequence;
int version;
DWORD dwVersion; DWORD dwVersion;
}; };
/* Function called by all devices that Wine supports */ /* Function called by all devices that Wine supports */
struct dinput_device { struct dinput_device {
const char *name; const char *name;
BOOL (*enum_deviceA)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id); BOOL (*enum_deviceA)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id);
BOOL (*enum_deviceW)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version, int id); BOOL (*enum_deviceW)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id);
HRESULT (*create_deviceA)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev); HRESULT (*create_deviceA)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev);
HRESULT (*create_deviceW)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev); HRESULT (*create_deviceW)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev);
}; };

View File

@ -148,7 +148,7 @@ static void _dump_DIDEVCAPS(LPDIDEVCAPS lpDIDevCaps)
} }
} }
static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id) static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
{ {
int fd = -1; int fd = -1;
char dev[32]; char dev[32];
@ -159,8 +159,8 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
} }
if ((dwDevType == 0) || if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) || ((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 8))) { (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) {
/* check whether we have a joystick */ /* check whether we have a joystick */
sprintf(dev, "%s%d", JOYDEV, id); sprintf(dev, "%s%d", JOYDEV, id);
if ((fd = open(dev,O_RDONLY)) < 0) { if ((fd = open(dev,O_RDONLY)) < 0) {
@ -173,7 +173,7 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
lpddi->guidInstance.Data3 = id; lpddi->guidInstance.Data3 = id;
lpddi->guidProduct = DInput_Wine_Joystick_GUID; lpddi->guidProduct = DInput_Wine_Joystick_GUID;
/* we only support traditional joysticks for now */ /* we only support traditional joysticks for now */
if (version >= 8) if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8); lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8); lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
@ -196,7 +196,7 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
return FALSE; return FALSE;
} }
static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version, int id) static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
{ {
int fd = -1; int fd = -1;
char name[MAX_PATH]; char name[MAX_PATH];
@ -209,8 +209,8 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
} }
if ((dwDevType == 0) || if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) || ((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 8))) { (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) {
/* check whether we have a joystick */ /* check whether we have a joystick */
sprintf(dev, "%s%d", JOYDEV, id); sprintf(dev, "%s%d", JOYDEV, id);
if ((fd = open(dev,O_RDONLY)) < 0) { if ((fd = open(dev,O_RDONLY)) < 0) {
@ -223,7 +223,7 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
lpddi->guidInstance.Data3 = id; lpddi->guidInstance.Data3 = id;
lpddi->guidProduct = DInput_Wine_Joystick_GUID; lpddi->guidProduct = DInput_Wine_Joystick_GUID;
/* we only support traditional joysticks for now */ /* we only support traditional joysticks for now */
if (version >= 8) if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8); lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8); lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
@ -557,7 +557,7 @@ static HRESULT alloc_device(REFGUID rguid, LPVOID jvt, IDirectInputImpl *dinput,
newDevice->devcaps.dwSize = sizeof(newDevice->devcaps); newDevice->devcaps.dwSize = sizeof(newDevice->devcaps);
newDevice->devcaps.dwFlags = DIDC_ATTACHED; newDevice->devcaps.dwFlags = DIDC_ATTACHED;
if (newDevice->dinput->version >= 8) if (newDevice->dinput->dwVersion >= 0x0800)
newDevice->devcaps.dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8); newDevice->devcaps.dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else else
newDevice->devcaps.dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8); newDevice->devcaps.dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
@ -1124,8 +1124,8 @@ static HRESULT WINAPI JoystickAImpl_SetProperty(
TRACE("(%p,%s,%p)\n",This,debugstr_guid(rguid),ph); TRACE("(%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
if (ph == NULL) { if (ph == NULL) {
WARN("invalid pointer\n"); WARN("invalid parameter: ph == NULL\n");
return E_INVALIDARG; return DIERR_INVALIDPARAM;
} }
if (TRACE_ON(dinput)) if (TRACE_ON(dinput))
@ -1228,7 +1228,7 @@ static HRESULT WINAPI JoystickAImpl_GetCapabilities(
TRACE("%p->(%p)\n",iface,lpDIDevCaps); TRACE("%p->(%p)\n",iface,lpDIDevCaps);
if (lpDIDevCaps == NULL) { if (lpDIDevCaps == NULL) {
WARN("invalid parameter: lpDIDevCaps = NULL\n"); WARN("invalid pointer\n");
return E_POINTER; return E_POINTER;
} }
@ -1576,6 +1576,11 @@ HRESULT WINAPI JoystickAImpl_GetDeviceInfo(
TRACE("(%p,%p)\n", iface, pdidi); TRACE("(%p,%p)\n", iface, pdidi);
if (pdidi == NULL) {
WARN("invalid pointer\n");
return E_POINTER;
}
if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3A)) && if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3A)) &&
(pdidi->dwSize != sizeof(DIDEVICEINSTANCEA))) { (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA))) {
WARN("invalid parameter: pdidi->dwSize = %ld != %d or %d\n", WARN("invalid parameter: pdidi->dwSize = %ld != %d or %d\n",

View File

@ -164,7 +164,7 @@ static int joydev_have(void)
return havejoy; return havejoy;
} }
static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id) static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
{ {
int havejoy = 0; int havejoy = 0;
@ -172,8 +172,8 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
return FALSE; return FALSE;
if (!((dwDevType == 0) || if (!((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) || ((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 8)))) (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))))
return FALSE; return FALSE;
if (dwFlags & DIEDFL_FORCEFEEDBACK) if (dwFlags & DIEDFL_FORCEFEEDBACK)
@ -191,7 +191,7 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
lpddi->guidProduct = DInput_Wine_Joystick_GUID; lpddi->guidProduct = DInput_Wine_Joystick_GUID;
lpddi->guidFFDriver = GUID_NULL; lpddi->guidFFDriver = GUID_NULL;
if (version >= 8) if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8); lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8); lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
@ -202,7 +202,7 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
return TRUE; return TRUE;
} }
static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version, int id) static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
{ {
int havejoy = 0; int havejoy = 0;
@ -210,8 +210,8 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
return FALSE; return FALSE;
if (!((dwDevType == 0) || if (!((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) || ((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 8)))) (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))))
return FALSE; return FALSE;
if (dwFlags & DIEDFL_FORCEFEEDBACK) if (dwFlags & DIEDFL_FORCEFEEDBACK)
@ -229,7 +229,7 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
lpddi->guidProduct = DInput_Wine_Joystick_GUID; lpddi->guidProduct = DInput_Wine_Joystick_GUID;
lpddi->guidFFDriver = GUID_NULL; lpddi->guidFFDriver = GUID_NULL;
if (version >= 8) if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8); lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8); lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
@ -755,7 +755,7 @@ static HRESULT WINAPI JoystickAImpl_GetCapabilities(
wasacquired = 0; wasacquired = 0;
} }
lpDIDevCaps->dwFlags = DIDC_ATTACHED; lpDIDevCaps->dwFlags = DIDC_ATTACHED;
if (This->dinput->version >= 8) if (This->dinput->dwVersion >= 0x0800)
lpDIDevCaps->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8); lpDIDevCaps->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else else
lpDIDevCaps->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8); lpDIDevCaps->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);

View File

@ -154,7 +154,7 @@ static GUID DInput_Wine_Keyboard_GUID = { /* 0ab8648a-7735-11d2-8c73-71df54a9644
{0x8c, 0x73, 0x71, 0xdf, 0x54, 0xa9, 0x64, 0x41} {0x8c, 0x73, 0x71, 0xdf, 0x54, 0xa9, 0x64, 0x41}
}; };
static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int version) { static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version) {
DWORD dwSize; DWORD dwSize;
DIDEVICEINSTANCEA ddi; DIDEVICEINSTANCEA ddi;
@ -168,7 +168,7 @@ static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int versi
ddi.dwSize = dwSize; ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */ ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */ ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
if (version >= 8) if (version >= 0x0800)
ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8); ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
else else
ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8); ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
@ -178,7 +178,7 @@ static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int versi
memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi))); memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
} }
static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version) { static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version) {
DWORD dwSize; DWORD dwSize;
DIDEVICEINSTANCEW ddi; DIDEVICEINSTANCEW ddi;
@ -192,7 +192,7 @@ static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int versi
ddi.dwSize = dwSize; ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */ ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */ ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
if (version >= 8) if (version >= 0x0800)
ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8); ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
else else
ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8); ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
@ -202,14 +202,14 @@ static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int versi
memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi))); memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
} }
static BOOL keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id) static BOOL keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
{ {
if (id != 0) if (id != 0)
return FALSE; return FALSE;
if ((dwDevType == 0) || if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 8)) || ((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 8))) { (((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
TRACE("Enumerating the Keyboard device\n"); TRACE("Enumerating the Keyboard device\n");
fill_keyboard_dideviceinstanceA(lpddi, version); fill_keyboard_dideviceinstanceA(lpddi, version);
@ -220,14 +220,14 @@ static BOOL keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEI
return FALSE; return FALSE;
} }
static BOOL keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version, int id) static BOOL keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
{ {
if (id != 0) if (id != 0)
return FALSE; return FALSE;
if ((dwDevType == 0) || if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 8)) || ((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 8))) { (((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
TRACE("Enumerating the Keyboard device\n"); TRACE("Enumerating the Keyboard device\n");
fill_keyboard_dideviceinstanceW(lpddi, version); fill_keyboard_dideviceinstanceW(lpddi, version);
@ -622,7 +622,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities(
devcaps.dwSize = lpDIDevCaps->dwSize; devcaps.dwSize = lpDIDevCaps->dwSize;
devcaps.dwFlags = DIDC_ATTACHED; devcaps.dwFlags = DIDC_ATTACHED;
if (This->dinput->version >= 8) if (This->dinput->dwVersion >= 0x0800)
devcaps.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8); devcaps.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
else else
devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8); devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
@ -727,7 +727,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceInfo(
return DI_OK; return DI_OK;
} }
fill_keyboard_dideviceinstanceA(pdidi, This->dinput->version); fill_keyboard_dideviceinstanceA(pdidi, This->dinput->dwVersion);
return DI_OK; return DI_OK;
} }
@ -742,7 +742,7 @@ static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface
return DI_OK; return DI_OK;
} }
fill_keyboard_dideviceinstanceW(pdidi, This->dinput->version); fill_keyboard_dideviceinstanceW(pdidi, This->dinput->dwVersion);
return DI_OK; return DI_OK;
} }

View File

@ -155,7 +155,7 @@ static GUID DInput_Wine_Mouse_GUID = { /* 9e573ed8-7734-11d2-8d4a-23903fb6bdf7 *
{0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7} {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
}; };
static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int version) { static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version) {
DWORD dwSize; DWORD dwSize;
DIDEVICEINSTANCEA ddi; DIDEVICEINSTANCEA ddi;
@ -169,7 +169,7 @@ static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int version)
ddi.dwSize = dwSize; ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */ ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Mouse_GUID; /* Vendor's GUID */ ddi.guidProduct = DInput_Wine_Mouse_GUID; /* Vendor's GUID */
if (version >= 8) if (version >= 0x0800)
ddi.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8); ddi.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
else else
ddi.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8); ddi.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
@ -179,7 +179,7 @@ static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int version)
memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi))); memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
} }
static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version) { static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version) {
DWORD dwSize; DWORD dwSize;
DIDEVICEINSTANCEW ddi; DIDEVICEINSTANCEW ddi;
@ -193,7 +193,7 @@ static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version)
ddi.dwSize = dwSize; ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */ ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Mouse_GUID; /* Vendor's GUID */ ddi.guidProduct = DInput_Wine_Mouse_GUID; /* Vendor's GUID */
if (version >= 8) if (version >= 0x0800)
ddi.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8); ddi.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
else else
ddi.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8); ddi.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
@ -203,14 +203,14 @@ static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version)
memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi))); memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
} }
static BOOL mousedev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id) static BOOL mousedev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
{ {
if (id != 0) if (id != 0)
return FALSE; return FALSE;
if ((dwDevType == 0) || if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_MOUSE) && (version < 8)) || ((dwDevType == DIDEVTYPE_MOUSE) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 8))) { (((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 0x0800))) {
TRACE("Enumerating the mouse device\n"); TRACE("Enumerating the mouse device\n");
fill_mouse_dideviceinstanceA(lpddi, version); fill_mouse_dideviceinstanceA(lpddi, version);
@ -221,14 +221,14 @@ static BOOL mousedev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINST
return FALSE; return FALSE;
} }
static BOOL mousedev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version, int id) static BOOL mousedev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
{ {
if (id != 0) if (id != 0)
return FALSE; return FALSE;
if ((dwDevType == 0) || if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_MOUSE) && (version < 8)) || ((dwDevType == DIDEVTYPE_MOUSE) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 8))) { (((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 0x0800))) {
TRACE("Enumerating the mouse device\n"); TRACE("Enumerating the mouse device\n");
fill_mouse_dideviceinstanceW(lpddi, version); fill_mouse_dideviceinstanceW(lpddi, version);
@ -945,7 +945,7 @@ static HRESULT WINAPI SysMouseAImpl_GetCapabilities(
devcaps.dwSize = lpDIDevCaps->dwSize; devcaps.dwSize = lpDIDevCaps->dwSize;
devcaps.dwFlags = DIDC_ATTACHED; devcaps.dwFlags = DIDC_ATTACHED;
if (This->dinput->version >= 8) if (This->dinput->dwVersion >= 0x0800)
devcaps.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8); devcaps.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
else else
devcaps.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8); devcaps.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
@ -1071,7 +1071,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceInfo(
return DI_OK; return DI_OK;
} }
fill_mouse_dideviceinstanceA(pdidi, This->dinput->version); fill_mouse_dideviceinstanceA(pdidi, This->dinput->dwVersion);
return DI_OK; return DI_OK;
} }
@ -1086,7 +1086,7 @@ static HRESULT WINAPI SysMouseWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, L
return DI_OK; return DI_OK;
} }
fill_mouse_dideviceinstanceW(pdidi, This->dinput->version); fill_mouse_dideviceinstanceW(pdidi, This->dinput->dwVersion);
return DI_OK; return DI_OK;
} }

View File

@ -80,9 +80,9 @@ HWND get_hwnd()
typedef struct tagJoystickInfo typedef struct tagJoystickInfo
{ {
LPDIRECTINPUTDEVICE pJoystick; LPDIRECTINPUTDEVICE pJoystick;
int axis; DWORD axis;
int pov; DWORD pov;
int button; DWORD button;
} JoystickInfo; } JoystickInfo;
static BOOL CALLBACK EnumAxes( static BOOL CALLBACK EnumAxes(
@ -136,6 +136,11 @@ static BOOL CALLBACK EnumJoysticks(
JoystickInfo info; JoystickInfo info;
int i, count; int i, count;
ULONG ref; ULONG ref;
DIDEVICEINSTANCE inst;
DIDEVICEINSTANCE_DX3 inst3;
HWND hWnd = get_hwnd();
ok(data->version > 0x0300, "Joysticks not supported in version 0x%04lx\n", data->version);
hr = IDirectInput_CreateDevice(data->pDI, &lpddi->guidInstance, NULL, NULL); hr = IDirectInput_CreateDevice(data->pDI, &lpddi->guidInstance, NULL, NULL);
ok(hr==E_POINTER,"IDirectInput_CreateDevice() should have returned " ok(hr==E_POINTER,"IDirectInput_CreateDevice() should have returned "
@ -187,8 +192,8 @@ static BOOL CALLBACK EnumJoysticks(
if (hr != DI_OK) if (hr != DI_OK)
goto RELEASE; goto RELEASE;
hr = IDirectInputDevice_SetCooperativeLevel(pJoystick, get_hwnd(), hr = IDirectInputDevice_SetCooperativeLevel(pJoystick, hWnd,
DISCL_EXCLUSIVE | DISCL_FOREGROUND); DISCL_NONEXCLUSIVE | DISCL_BACKGROUND);
ok(hr==DI_OK,"IDirectInputDevice_SetCooperativeLevel() failed: %s\n", ok(hr==DI_OK,"IDirectInputDevice_SetCooperativeLevel() failed: %s\n",
DXGetErrorString8(hr)); DXGetErrorString8(hr));
@ -219,7 +224,30 @@ static BOOL CALLBACK EnumJoysticks(
ok(caps.dwAxes == info.axis, "Number of enumerated axes doesn't match capabilities\n"); ok(caps.dwAxes == info.axis, "Number of enumerated axes doesn't match capabilities\n");
ok(caps.dwButtons == info.button, "Number of enumerated buttons doesn't match capabilities\n"); ok(caps.dwButtons == info.button, "Number of enumerated buttons doesn't match capabilities\n");
ok(caps.dwPOVs == info.pov, "Number of enumerated buttons doesn't match capabilities\n"); ok(caps.dwPOVs == info.pov, "Number of enumerated POVs doesn't match capabilities\n");
hr = IDirectInputDevice_GetDeviceInfo(pJoystick, 0);
ok(hr==E_POINTER, "IDirectInputDevice_GetDeviceInfo() "
"should have returned E_POINTER, returned: %s\n",
DXGetErrorString8(hr));
ZeroMemory(&inst, sizeof(inst));
ZeroMemory(&inst3, sizeof(inst3));
hr = IDirectInputDevice_GetDeviceInfo(pJoystick, &inst);
ok(hr==DIERR_INVALIDPARAM, "IDirectInputDevice_GetDeviceInfo() "
"should have returned DIERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(hr));
inst.dwSize = sizeof(inst);
hr = IDirectInputDevice_GetDeviceInfo(pJoystick, &inst);
ok(hr==DI_OK,"IDirectInputDevice_GetDeviceInfo() failed: %s\n",
DXGetErrorString8(hr));
inst3.dwSize = sizeof(inst3);
hr = IDirectInputDevice_GetDeviceInfo(pJoystick, (LPDIDEVICEINSTANCE)&inst3);
ok(hr==DI_OK,"IDirectInputDevice_GetDeviceInfo() failed: %s\n",
DXGetErrorString8(hr));
hr = IDirectInputDevice_Acquire(pJoystick); hr = IDirectInputDevice_Acquire(pJoystick);
ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %s\n", ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %s\n",
@ -271,9 +299,10 @@ static void joystick_tests(DWORD version)
HRESULT hr; HRESULT hr;
LPDIRECTINPUT pDI; LPDIRECTINPUT pDI;
ULONG ref; ULONG ref;
HINSTANCE hInstance = GetModuleHandle(NULL);
trace("-- Testing Direct Input Version 0x%04lx --\n", version); trace("-- Testing Direct Input Version 0x%04lx --\n", version);
hr = DirectInputCreate(GetModuleHandle(NULL), version, &pDI, NULL); hr = DirectInputCreate(hInstance, version, &pDI, NULL);
ok(hr==DI_OK||hr==DIERR_OLDDIRECTINPUTVERSION, ok(hr==DI_OK||hr==DIERR_OLDDIRECTINPUTVERSION,
"DirectInputCreate() failed: %s\n", DXGetErrorString8(hr)); "DirectInputCreate() failed: %s\n", DXGetErrorString8(hr));
if (hr==DI_OK && pDI!=0) { if (hr==DI_OK && pDI!=0) {
@ -282,14 +311,8 @@ static void joystick_tests(DWORD version)
data.version = version; data.version = version;
hr = IDirectInput_EnumDevices(pDI, DIDEVTYPE_JOYSTICK, EnumJoysticks, hr = IDirectInput_EnumDevices(pDI, DIDEVTYPE_JOYSTICK, EnumJoysticks,
&data, DIEDFL_ALLDEVICES); &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", ok(hr==DI_OK,"IDirectInput_EnumDevices() failed: %s\n",
DXGetErrorString8(hr)); DXGetErrorString8(hr));
}
ref = IDirectInput_Release(pDI); ref = IDirectInput_Release(pDI);
ok(ref==0,"IDirectInput_Release() reference count = %ld\n", ref); ok(ref==0,"IDirectInput_Release() reference count = %ld\n", ref);
} else if (hr==DIERR_OLDDIRECTINPUTVERSION) } else if (hr==DIERR_OLDDIRECTINPUTVERSION)