Commit 6a8ae41c authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

Handle device class in DX8 enumeration (found by Robert Reif).

Fixed remaining DX8 device types. Factorized a bit GetCapabilities for keyboard and mouse.
parent dd30516f
......@@ -159,7 +159,7 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) ||
((dwDevType == DI8DEVTYPE_JOYSTICK) && (version >= 8))) {
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 8))) {
/* check whether we have a joystick */
sprintf(dev, "%s%d", JOYDEV, id);
if ((fd = open(dev,O_RDONLY)) < 0) {
......@@ -209,7 +209,7 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) ||
((dwDevType == DI8DEVTYPE_JOYSTICK) && (version >= 8))) {
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 8))) {
/* check whether we have a joystick */
sprintf(dev, "%s%d", JOYDEV, id);
if ((fd = open(dev,O_RDONLY)) < 0) {
......@@ -556,7 +556,10 @@ static HRESULT alloc_device(REFGUID rguid, LPVOID jvt, IDirectInputImpl *dinput,
newDevice->devcaps.dwSize = sizeof(newDevice->devcaps);
newDevice->devcaps.dwFlags = DIDC_ATTACHED;
newDevice->devcaps.dwDevType = DIDEVTYPE_JOYSTICK;
if (newDevice->dinput->version >= 8)
newDevice->devcaps.dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
newDevice->devcaps.dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
newDevice->devcaps.dwFFSamplePeriod = 0;
newDevice->devcaps.dwFFMinTimeResolution = 0;
newDevice->devcaps.dwFirmwareRevision = 0;
......@@ -1582,10 +1585,7 @@ HRESULT WINAPI JoystickAImpl_GetDeviceInfo(
pdidi->guidInstance = GUID_Joystick;
pdidi->guidProduct = DInput_Wine_Joystick_GUID;
/* we only support traditional joysticks for now */
if (This->dinput->version >= 8)
pdidi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
pdidi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
pdidi->dwDevType = This->devcaps.dwDevType;
strcpy(pdidi->tszInstanceName, "Joystick");
strcpy(pdidi->tszProductName, This->name);
if (pdidi->dwSize > sizeof(DIDEVICEINSTANCE_DX3A)) {
......@@ -1620,10 +1620,7 @@ HRESULT WINAPI JoystickWImpl_GetDeviceInfo(
pdidi->guidInstance = GUID_Joystick;
pdidi->guidProduct = DInput_Wine_Joystick_GUID;
/* we only support traditional joysticks for now */
if (This->dinput->version >= 8)
pdidi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
pdidi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
pdidi->dwDevType = This->devcaps.dwDevType;
MultiByteToWideChar(CP_ACP, 0, "Joystick", -1, pdidi->tszInstanceName, MAX_PATH);
MultiByteToWideChar(CP_ACP, 0, This->name, -1, pdidi->tszProductName, MAX_PATH);
if (pdidi->dwSize > sizeof(DIDEVICEINSTANCE_DX3W)) {
......
......@@ -177,7 +177,7 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
if (!((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) ||
((dwDevType == DI8DEVTYPE_JOYSTICK) && (version >= 8))))
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 8))))
return FALSE;
if (dwFlags & DIEDFL_FORCEFEEDBACK)
......@@ -215,7 +215,7 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
if (!((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) ||
((dwDevType == DI8DEVTYPE_JOYSTICK) && (version >= 8))))
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 8))))
return FALSE;
if (dwFlags & DIEDFL_FORCEFEEDBACK)
......@@ -233,7 +233,10 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
lpddi->guidProduct = DInput_Wine_Joystick_GUID;
lpddi->guidFFDriver = GUID_NULL;
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL<<8);
if (version >= 8)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
MultiByteToWideChar(CP_ACP, 0, "Joystick", -1, lpddi->tszInstanceName, MAX_PATH);
/* ioctl JSIOCGNAME(len) */
......@@ -760,7 +763,10 @@ static HRESULT WINAPI JoystickAImpl_GetCapabilities(
wasacquired = 0;
}
lpDIDevCaps->dwFlags = DIDC_ATTACHED;
lpDIDevCaps->dwDevType = DIDEVTYPE_JOYSTICK;
if (This->dinput->version >= 8)
lpDIDevCaps->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpDIDevCaps->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
axes=0;
for (i=0;i<ABS_MAX;i++) if (test_bit(This->absbits,i)) axes++;
......
......@@ -206,7 +206,7 @@ static BOOL keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEI
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 8)) ||
((dwDevType == DI8DEVTYPE_KEYBOARD) && (version >= 8))) {
(((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 8))) {
TRACE("Enumerating the Keyboard device\n");
fill_keyboard_dideviceinstanceA(lpddi, version);
......@@ -224,7 +224,7 @@ static BOOL keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEI
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 8)) ||
((dwDevType == DI8DEVTYPE_KEYBOARD) && (version >= 8))) {
(((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 8))) {
TRACE("Enumerating the Keyboard device\n");
fill_keyboard_dideviceinstanceW(lpddi, version);
......@@ -569,36 +569,34 @@ static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities(
LPDIRECTINPUTDEVICE8A iface,
LPDIDEVCAPS lpDIDevCaps)
{
SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
DIDEVCAPS devcaps;
TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
if (lpDIDevCaps->dwSize == sizeof(DIDEVCAPS)) {
lpDIDevCaps->dwFlags = DIDC_ATTACHED;
if ((lpDIDevCaps->dwSize != sizeof(DIDEVCAPS)) && (lpDIDevCaps->dwSize != sizeof(DIDEVCAPS_DX3))) {
WARN("invalid parameter\n");
return DIERR_INVALIDPARAM;
}
devcaps.dwSize = lpDIDevCaps->dwSize;
devcaps.dwFlags = DIDC_ATTACHED;
if (This->dinput->version >= 8)
lpDIDevCaps->dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
devcaps.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
else
lpDIDevCaps->dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
lpDIDevCaps->dwAxes = 0;
lpDIDevCaps->dwButtons = 256;
lpDIDevCaps->dwPOVs = 0;
lpDIDevCaps->dwFFSamplePeriod = 0;
lpDIDevCaps->dwFFMinTimeResolution = 0;
lpDIDevCaps->dwFirmwareRevision = 100;
lpDIDevCaps->dwHardwareRevision = 100;
lpDIDevCaps->dwFFDriverVersion = 0;
} else if (lpDIDevCaps->dwSize == sizeof(DIDEVCAPS_DX3)) {
lpDIDevCaps->dwFlags = DIDC_ATTACHED;
lpDIDevCaps->dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
lpDIDevCaps->dwAxes = 0;
lpDIDevCaps->dwButtons = 256;
lpDIDevCaps->dwPOVs = 0;
} else {
WARN("invalid parameter\n");
return DIERR_INVALIDPARAM;
}
return DI_OK;
devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
devcaps.dwAxes = 0;
devcaps.dwButtons = 256;
devcaps.dwPOVs = 0;
devcaps.dwFFSamplePeriod = 0;
devcaps.dwFFMinTimeResolution = 0;
devcaps.dwFirmwareRevision = 100;
devcaps.dwHardwareRevision = 100;
devcaps.dwFFDriverVersion = 0;
memcpy(lpDIDevCaps, &devcaps, lpDIDevCaps->dwSize);
return DI_OK;
}
/******************************************************************************
......
......@@ -210,7 +210,7 @@ static BOOL mousedev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINST
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_MOUSE) && (version < 8)) ||
((dwDevType == DI8DEVTYPE_MOUSE) && (version >= 8))) {
(((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 8))) {
TRACE("Enumerating the mouse device\n");
fill_mouse_dideviceinstanceA(lpddi, version);
......@@ -228,7 +228,7 @@ static BOOL mousedev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINST
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_MOUSE) && (version < 8)) ||
((dwDevType == DI8DEVTYPE_MOUSE) && (version >= 8))) {
(((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 8))) {
TRACE("Enumerating the mouse device\n");
fill_mouse_dideviceinstanceW(lpddi, version);
......@@ -923,33 +923,31 @@ static HRESULT WINAPI SysMouseAImpl_GetCapabilities(
LPDIDEVCAPS lpDIDevCaps)
{
SysMouseImpl *This = (SysMouseImpl *)iface;
DIDEVCAPS devcaps;
TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
if (lpDIDevCaps->dwSize == sizeof(DIDEVCAPS)) {
lpDIDevCaps->dwFlags = DIDC_ATTACHED;
if (This->dinput->version >= 8)
lpDIDevCaps->dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
else
lpDIDevCaps->dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
lpDIDevCaps->dwAxes = 3;
lpDIDevCaps->dwButtons = 3;
lpDIDevCaps->dwPOVs = 0;
lpDIDevCaps->dwFFSamplePeriod = 0;
lpDIDevCaps->dwFFMinTimeResolution = 0;
lpDIDevCaps->dwFirmwareRevision = 100;
lpDIDevCaps->dwHardwareRevision = 100;
lpDIDevCaps->dwFFDriverVersion = 0;
} else if (lpDIDevCaps->dwSize == sizeof(DIDEVCAPS_DX3)) {
lpDIDevCaps->dwFlags = DIDC_ATTACHED;
lpDIDevCaps->dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
lpDIDevCaps->dwAxes = 3;
lpDIDevCaps->dwButtons = 3;
lpDIDevCaps->dwPOVs = 0;
} else {
if ((lpDIDevCaps->dwSize != sizeof(DIDEVCAPS)) && (lpDIDevCaps->dwSize != sizeof(DIDEVCAPS_DX3))) {
WARN("invalid parameter\n");
return DIERR_INVALIDPARAM;
}
devcaps.dwSize = lpDIDevCaps->dwSize;
devcaps.dwFlags = DIDC_ATTACHED;
if (This->dinput->version >= 8)
devcaps.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
else
devcaps.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
devcaps.dwAxes = 3;
devcaps.dwButtons = 3;
devcaps.dwPOVs = 0;
devcaps.dwFFSamplePeriod = 0;
devcaps.dwFFMinTimeResolution = 0;
devcaps.dwFirmwareRevision = 100;
devcaps.dwHardwareRevision = 100;
devcaps.dwFFDriverVersion = 0;
memcpy(lpDIDevCaps, &devcaps, lpDIDevCaps->dwSize);
return DI_OK;
}
......
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