Commit 6dd763e0 authored by Robert Reif's avatar Robert Reif Committed by Alexandre Julliard

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

Change cooperative level to pass on windows.
parent 5d90f2bc
......@@ -94,7 +94,6 @@ HRESULT WINAPI DirectInputCreateEx(
This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi7avt;
This->ref = 1;
This->version = 1;
This->dwVersion = dwVersion;
*ppDI = This;
......@@ -107,7 +106,6 @@ HRESULT WINAPI DirectInputCreateEx(
This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi7wvt;
This->ref = 1;
This->version = 1;
This->dwVersion = dwVersion;
*ppDI = This;
......@@ -118,7 +116,6 @@ HRESULT WINAPI DirectInputCreateEx(
This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi8avt;
This->ref = 1;
This->version = 8;
This->dwVersion = dwVersion;
*ppDI = This;
......@@ -129,7 +126,6 @@ HRESULT WINAPI DirectInputCreateEx(
This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi8wvt;
This->ref = 1;
This->version = 8;
This->dwVersion = dwVersion;
*ppDI = This;
......@@ -150,12 +146,6 @@ HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPU
This->lpVtbl = &ddi7avt;
This->ref = 1;
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;
return 0;
......@@ -172,12 +162,6 @@ HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPU
This->lpVtbl = &ddi7wvt;
This->ref = 1;
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;
return 0;
}
......@@ -234,16 +218,12 @@ static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
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++) {
devInstance.dwSize = sizeof(devInstance);
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)
return 0;
}
......@@ -268,16 +248,12 @@ static HRESULT WINAPI IDirectInputWImpl_EnumDevices(
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++) {
devInstance.dwSize = sizeof(devInstance);
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)
return 0;
}
......
......@@ -35,15 +35,14 @@ struct IDirectInputImpl
/* Used to have an unique sequence number for all the events */
DWORD evsequence;
int version;
DWORD dwVersion;
};
/* Function called by all devices that Wine supports */
struct dinput_device {
const char *name;
BOOL (*enum_deviceA)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id);
BOOL (*enum_deviceW)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW 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, DWORD version, int id);
HRESULT (*create_deviceA)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev);
HRESULT (*create_deviceW)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev);
};
......
......@@ -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;
char dev[32];
......@@ -159,8 +159,8 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
}
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 8))) {
((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) {
/* check whether we have a joystick */
sprintf(dev, "%s%d", JOYDEV, id);
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->guidProduct = DInput_Wine_Joystick_GUID;
/* we only support traditional joysticks for now */
if (version >= 8)
if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
......@@ -196,7 +196,7 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
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;
char name[MAX_PATH];
......@@ -209,8 +209,8 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
}
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 8))) {
((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) {
/* check whether we have a joystick */
sprintf(dev, "%s%d", JOYDEV, id);
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->guidProduct = DInput_Wine_Joystick_GUID;
/* we only support traditional joysticks for now */
if (version >= 8)
if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
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.dwFlags = DIDC_ATTACHED;
if (newDevice->dinput->version >= 8)
if (newDevice->dinput->dwVersion >= 0x0800)
newDevice->devcaps.dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
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);
if (ph == NULL) {
WARN("invalid pointer\n");
return E_INVALIDARG;
WARN("invalid parameter: ph == NULL\n");
return DIERR_INVALIDPARAM;
}
if (TRACE_ON(dinput))
......@@ -1228,7 +1228,7 @@ static HRESULT WINAPI JoystickAImpl_GetCapabilities(
TRACE("%p->(%p)\n",iface,lpDIDevCaps);
if (lpDIDevCaps == NULL) {
WARN("invalid parameter: lpDIDevCaps = NULL\n");
WARN("invalid pointer\n");
return E_POINTER;
}
......@@ -1576,6 +1576,11 @@ HRESULT WINAPI JoystickAImpl_GetDeviceInfo(
TRACE("(%p,%p)\n", iface, pdidi);
if (pdidi == NULL) {
WARN("invalid pointer\n");
return E_POINTER;
}
if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3A)) &&
(pdidi->dwSize != sizeof(DIDEVICEINSTANCEA))) {
WARN("invalid parameter: pdidi->dwSize = %ld != %d or %d\n",
......
......@@ -164,7 +164,7 @@ static int joydev_have(void)
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;
......@@ -172,8 +172,8 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
return FALSE;
if (!((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 8))))
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))))
return FALSE;
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->guidFFDriver = GUID_NULL;
if (version >= 8)
if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
......@@ -202,7 +202,7 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
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;
......@@ -210,8 +210,8 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
return FALSE;
if (!((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 8))))
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))))
return FALSE;
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->guidFFDriver = GUID_NULL;
if (version >= 8)
if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
......@@ -755,7 +755,7 @@ static HRESULT WINAPI JoystickAImpl_GetCapabilities(
wasacquired = 0;
}
lpDIDevCaps->dwFlags = DIDC_ATTACHED;
if (This->dinput->version >= 8)
if (This->dinput->dwVersion >= 0x0800)
lpDIDevCaps->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpDIDevCaps->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
......
......@@ -154,7 +154,7 @@ static GUID DInput_Wine_Keyboard_GUID = { /* 0ab8648a-7735-11d2-8c73-71df54a9644
{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;
DIDEVICEINSTANCEA ddi;
......@@ -168,7 +168,7 @@ static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int versi
ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
if (version >= 8)
if (version >= 0x0800)
ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
else
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)));
}
static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version) {
static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version) {
DWORD dwSize;
DIDEVICEINSTANCEW ddi;
......@@ -192,7 +192,7 @@ static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int versi
ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
if (version >= 8)
if (version >= 0x0800)
ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
else
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)));
}
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)
return FALSE;
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 8)) ||
(((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 8))) {
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
TRACE("Enumerating the Keyboard device\n");
fill_keyboard_dideviceinstanceA(lpddi, version);
......@@ -220,14 +220,14 @@ static BOOL keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEI
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)
return FALSE;
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 8)) ||
(((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 8))) {
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
TRACE("Enumerating the Keyboard device\n");
fill_keyboard_dideviceinstanceW(lpddi, version);
......@@ -622,7 +622,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities(
devcaps.dwSize = lpDIDevCaps->dwSize;
devcaps.dwFlags = DIDC_ATTACHED;
if (This->dinput->version >= 8)
if (This->dinput->dwVersion >= 0x0800)
devcaps.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
else
devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
......@@ -727,7 +727,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceInfo(
return DI_OK;
}
fill_keyboard_dideviceinstanceA(pdidi, This->dinput->version);
fill_keyboard_dideviceinstanceA(pdidi, This->dinput->dwVersion);
return DI_OK;
}
......@@ -742,7 +742,7 @@ static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface
return DI_OK;
}
fill_keyboard_dideviceinstanceW(pdidi, This->dinput->version);
fill_keyboard_dideviceinstanceW(pdidi, This->dinput->dwVersion);
return DI_OK;
}
......
......@@ -155,7 +155,7 @@ static GUID DInput_Wine_Mouse_GUID = { /* 9e573ed8-7734-11d2-8d4a-23903fb6bdf7 *
{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;
DIDEVICEINSTANCEA ddi;
......@@ -169,7 +169,7 @@ static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int version)
ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Mouse_GUID; /* Vendor's GUID */
if (version >= 8)
if (version >= 0x0800)
ddi.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
else
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)));
}
static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version) {
static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version) {
DWORD dwSize;
DIDEVICEINSTANCEW ddi;
......@@ -193,7 +193,7 @@ static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version)
ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Mouse_GUID; /* Vendor's GUID */
if (version >= 8)
if (version >= 0x0800)
ddi.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
else
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)));
}
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)
return FALSE;
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_MOUSE) && (version < 8)) ||
(((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 8))) {
((dwDevType == DIDEVTYPE_MOUSE) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 0x0800))) {
TRACE("Enumerating the mouse device\n");
fill_mouse_dideviceinstanceA(lpddi, version);
......@@ -221,14 +221,14 @@ static BOOL mousedev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINST
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)
return FALSE;
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_MOUSE) && (version < 8)) ||
(((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 8))) {
((dwDevType == DIDEVTYPE_MOUSE) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 0x0800))) {
TRACE("Enumerating the mouse device\n");
fill_mouse_dideviceinstanceW(lpddi, version);
......@@ -945,7 +945,7 @@ static HRESULT WINAPI SysMouseAImpl_GetCapabilities(
devcaps.dwSize = lpDIDevCaps->dwSize;
devcaps.dwFlags = DIDC_ATTACHED;
if (This->dinput->version >= 8)
if (This->dinput->dwVersion >= 0x0800)
devcaps.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
else
devcaps.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
......@@ -1071,7 +1071,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceInfo(
return DI_OK;
}
fill_mouse_dideviceinstanceA(pdidi, This->dinput->version);
fill_mouse_dideviceinstanceA(pdidi, This->dinput->dwVersion);
return DI_OK;
}
......@@ -1086,7 +1086,7 @@ static HRESULT WINAPI SysMouseWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, L
return DI_OK;
}
fill_mouse_dideviceinstanceW(pdidi, This->dinput->version);
fill_mouse_dideviceinstanceW(pdidi, This->dinput->dwVersion);
return DI_OK;
}
......
......@@ -80,9 +80,9 @@ HWND get_hwnd()
typedef struct tagJoystickInfo
{
LPDIRECTINPUTDEVICE pJoystick;
int axis;
int pov;
int button;
DWORD axis;
DWORD pov;
DWORD button;
} JoystickInfo;
static BOOL CALLBACK EnumAxes(
......@@ -136,7 +136,12 @@ static BOOL CALLBACK EnumJoysticks(
JoystickInfo info;
int i, count;
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);
ok(hr==E_POINTER,"IDirectInput_CreateDevice() should have returned "
"E_POINTER, returned: %s\n", DXGetErrorString8(hr));
......@@ -187,8 +192,8 @@ static BOOL CALLBACK EnumJoysticks(
if (hr != DI_OK)
goto RELEASE;
hr = IDirectInputDevice_SetCooperativeLevel(pJoystick, get_hwnd(),
DISCL_EXCLUSIVE | DISCL_FOREGROUND);
hr = IDirectInputDevice_SetCooperativeLevel(pJoystick, hWnd,
DISCL_NONEXCLUSIVE | DISCL_BACKGROUND);
ok(hr==DI_OK,"IDirectInputDevice_SetCooperativeLevel() failed: %s\n",
DXGetErrorString8(hr));
......@@ -213,13 +218,36 @@ static BOOL CALLBACK EnumJoysticks(
info.pJoystick = pJoystick;
/* enumerate objects */
hr = IDirectInputDevice_EnumObjects(pJoystick, EnumAxes, (VOID*)&info, DIDFT_ALL);
hr = IDirectInputDevice_EnumObjects(pJoystick, EnumAxes, (VOID*)&info, DIDFT_ALL);
ok(hr==DI_OK,"IDirectInputDevice_EnumObjects() failed: %s\n",
DXGetErrorString8(hr));
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.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);
ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %s\n",
......@@ -271,9 +299,10 @@ static void joystick_tests(DWORD version)
HRESULT hr;
LPDIRECTINPUT pDI;
ULONG ref;
HINSTANCE hInstance = GetModuleHandle(NULL);
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,
"DirectInputCreate() failed: %s\n", DXGetErrorString8(hr));
if (hr==DI_OK && pDI!=0) {
......@@ -282,14 +311,8 @@ static void joystick_tests(DWORD version)
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));
}
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment