Sync to Wine-20050111:
Michael Stefaniuc <mstefani(a)redhat.de>
- Do not check for non NULL pointer before HeapFree'ing it. It's
redundant.
Christian Costa <titan.costa(a)wanadoo.fr>
- Handle device class in DX8 enumeration (found by Robert Reif).
- Fixed remaining DX8 device types.
- Factorized a bit GetCapabilities for keyboard and mouse.
- Fixed enumeration of joysticks in DX8.
- Fixed some traces.
Francois Gouget <fgouget(a)free.fr>
- Assorted spelling fixes.
Neil Olver <olver(a)math.mcgill.ca>
- The flag for a mouse button down in the structure returned by
GetDeviceState should be 0x80 (only the high bit set), not 0xff.
Modified: trunk/reactos/lib/dinput/dinput_main.c
Modified: trunk/reactos/lib/dinput/joystick_linux.c
Modified: trunk/reactos/lib/dinput/joystick_linuxinput.c
Modified: trunk/reactos/lib/dinput/keyboard.c
Modified: trunk/reactos/lib/dinput/mouse.c
_____
Modified: trunk/reactos/lib/dinput/dinput_main.c
--- trunk/reactos/lib/dinput/dinput_main.c 2005-01-11 23:06:20 UTC
(rev 12936)
+++ trunk/reactos/lib/dinput/dinput_main.c 2005-01-11 23:11:18 UTC
(rev 12937)
@@ -744,13 +744,13 @@
HRESULT WINAPI DINPUT_DllGetClassObject(REFCLSID rclsid, REFIID riid,
LPVOID *ppv)
{
- TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid),
ppv);
+ TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid),
ppv);
if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
*ppv = (LPVOID)&DINPUT_CF;
IClassFactory_AddRef((IClassFactory*)*ppv);
return S_OK;
}
- FIXME("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid),
debugstr_guid(riid), ppv);
+ FIXME("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid),
debugstr_guid(riid), ppv);
return CLASS_E_CLASSNOTAVAILABLE;
}
_____
Modified: trunk/reactos/lib/dinput/joystick_linux.c
--- trunk/reactos/lib/dinput/joystick_linux.c 2005-01-11 23:06:20 UTC
(rev 12936)
+++ trunk/reactos/lib/dinput/joystick_linux.c 2005-01-11 23:11:18 UTC
(rev 12937)
@@ -157,7 +157,9 @@
return FALSE;
}
- if ((dwDevType==0) ||
(GET_DIDEVICE_TYPE(dwDevType)==DIDEVTYPE_JOYSTICK)) {
+ if ((dwDevType == 0) ||
+ ((dwDevType == DIDEVTYPE_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) {
@@ -205,7 +207,9 @@
return FALSE;
}
- if ((dwDevType==0) ||
(GET_DIDEVICE_TYPE(dwDevType)==DIDEVTYPE_JOYSTICK)) {
+ if ((dwDevType == 0) ||
+ ((dwDevType == DIDEVTYPE_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) {
@@ -552,7 +556,10 @@
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;
@@ -573,18 +580,12 @@
FAILED:
hr = DIERR_OUTOFMEMORY;
FAILED1:
- if (newDevice->axis_map)
- HeapFree(GetProcessHeap(),0,newDevice->axis_map);
- if (newDevice->name)
- HeapFree(GetProcessHeap(),0,newDevice->name);
- if (newDevice->props)
- HeapFree(GetProcessHeap(),0,newDevice->props);
- if (newDevice->user_df->rgodf)
- HeapFree(GetProcessHeap(),0,newDevice->user_df->rgodf);
- if (newDevice->user_df)
- HeapFree(GetProcessHeap(),0,newDevice->user_df);
- if (newDevice)
- HeapFree(GetProcessHeap(),0,newDevice);
+ HeapFree(GetProcessHeap(),0,newDevice->axis_map);
+ HeapFree(GetProcessHeap(),0,newDevice->name);
+ HeapFree(GetProcessHeap(),0,newDevice->props);
+ HeapFree(GetProcessHeap(),0,newDevice->user_df->rgodf);
+ HeapFree(GetProcessHeap(),0,newDevice->user_df);
+ HeapFree(GetProcessHeap(),0,newDevice);
*pdev = 0;
return hr;
@@ -671,16 +672,13 @@
return ref;
/* Free the device name */
- if (This->name)
- HeapFree(GetProcessHeap(),0,This->name);
+ HeapFree(GetProcessHeap(),0,This->name);
/* Free the axis map */
- if (This->axis_map)
- HeapFree(GetProcessHeap(),0,This->axis_map);
+ HeapFree(GetProcessHeap(),0,This->axis_map);
/* Free the data queue */
- if (This->data_queue != NULL)
- HeapFree(GetProcessHeap(),0,This->data_queue);
+ HeapFree(GetProcessHeap(),0,This->data_queue);
/* Free the DataFormat */
HeapFree(GetProcessHeap(), 0, This->user_df->rgodf);
@@ -764,12 +762,9 @@
FAILED:
WARN("out of memory\n");
- if (new_props)
- HeapFree(GetProcessHeap(),0,new_props);
- if (new_rgodf)
- HeapFree(GetProcessHeap(),0,new_rgodf);
- if (new_df)
- HeapFree(GetProcessHeap(),0,new_df);
+ HeapFree(GetProcessHeap(),0,new_props);
+ HeapFree(GetProcessHeap(),0,new_rgodf);
+ HeapFree(GetProcessHeap(),0,new_df);
return DIERR_OUTOFMEMORY;
}
@@ -1580,10 +1575,7 @@
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)) {
@@ -1618,10 +1610,7 @@
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)) {
_____
Modified: trunk/reactos/lib/dinput/joystick_linuxinput.c
--- trunk/reactos/lib/dinput/joystick_linuxinput.c 2005-01-11
23:06:20 UTC (rev 12936)
+++ trunk/reactos/lib/dinput/joystick_linuxinput.c 2005-01-11
23:11:18 UTC (rev 12937)
@@ -175,8 +175,10 @@
if (id != 0)
return FALSE;
- if ((dwDevType != 0) && (GET_DIDEVICE_TYPE(dwDevType) !=
DIDEVTYPE_JOYSTICK))
- return FALSE;
+ if (!((dwDevType == 0) ||
+ ((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) ||
+ (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType ==
DI8DEVTYPE_JOYSTICK)) && (version >= 8))))
+ return FALSE;
if (dwFlags & DIEDFL_FORCEFEEDBACK)
return FALSE;
@@ -211,8 +213,10 @@
if (id != 0)
return FALSE;
- if ((dwDevType != 0) && (GET_DIDEVICE_TYPE(dwDevType) !=
DIDEVTYPE_JOYSTICK))
- return FALSE;
+ if (!((dwDevType == 0) ||
+ ((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) ||
+ (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType ==
DI8DEVTYPE_JOYSTICK)) && (version >= 8))))
+ return FALSE;
if (dwFlags & DIEDFL_FORCEFEEDBACK)
return FALSE;
@@ -229,7 +233,10 @@
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) */
@@ -339,8 +346,7 @@
return ref;
/* Free the data queue */
- if (This->data_queue != NULL)
- HeapFree(GetProcessHeap(),0,This->data_queue);
+ HeapFree(GetProcessHeap(),0,This->data_queue);
/* Free the DataFormat */
HeapFree(GetProcessHeap(), 0, This->df);
@@ -756,7 +762,10 @@
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++;
_____
Modified: trunk/reactos/lib/dinput/keyboard.c
--- trunk/reactos/lib/dinput/keyboard.c 2005-01-11 23:06:20 UTC (rev
12936)
+++ trunk/reactos/lib/dinput/keyboard.c 2005-01-11 23:11:18 UTC (rev
12937)
@@ -266,7 +266,7 @@
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);
@@ -284,7 +284,7 @@
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);
@@ -387,8 +387,7 @@
#endif
/* Free the data queue */
- if (This->buffer != NULL)
- HeapFree(GetProcessHeap(),0,This->buffer);
+ HeapFree(GetProcessHeap(),0,This->buffer);
DeleteCriticalSection(&(This->crit));
@@ -649,36 +648,34 @@
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;
- }
+ 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;
- return DI_OK;
+ memcpy(lpDIDevCaps, &devcaps, lpDIDevCaps->dwSize);
+
+ return DI_OK;
}
/***********************************************************************
*******
_____
Modified: trunk/reactos/lib/dinput/mouse.c
--- trunk/reactos/lib/dinput/mouse.c 2005-01-11 23:06:20 UTC (rev
12936)
+++ trunk/reactos/lib/dinput/mouse.c 2005-01-11 23:11:18 UTC (rev
12937)
@@ -220,7 +220,7 @@
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);
@@ -238,7 +238,7 @@
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);
@@ -351,8 +351,7 @@
return ref;
/* Free the data queue */
- if (This->data_queue != NULL)
- HeapFree(GetProcessHeap(),0,This->data_queue);
+ HeapFree(GetProcessHeap(),0,This->data_queue);
#ifndef __REACTOS__
if (This->hook) {
@@ -458,7 +457,7 @@
/* Only allow mouse events every 10 ms.
* This is to allow the cursor to start acceleration before
* the warps happen. But if it involves a mouse button event we
- * allow it since we don't want to loose the clicks.
+ * allow it since we don't want to lose the clicks.
*/
if (((GetCurrentTime() - last_event) < 10)
&& wparam == WM_MOUSEMOVE)
@@ -527,9 +526,9 @@
switch(wparam) {
case WM_LBUTTONDOWN:
- GEN_EVENT(This->offset_array[WINE_MOUSE_L_POSITION], 0xFF,
+ GEN_EVENT(This->offset_array[WINE_MOUSE_L_POSITION], 0x80,
hook->time, This->dinput->evsequence++);
- This->m_state.rgbButtons[0] = 0xFF;
+ This->m_state.rgbButtons[0] = 0x80;
break;
case WM_LBUTTONUP:
GEN_EVENT(This->offset_array[WINE_MOUSE_L_POSITION], 0x00,
@@ -537,9 +536,9 @@
This->m_state.rgbButtons[0] = 0x00;
break;
case WM_RBUTTONDOWN:
- GEN_EVENT(This->offset_array[WINE_MOUSE_R_POSITION], 0xFF,
+ GEN_EVENT(This->offset_array[WINE_MOUSE_R_POSITION], 0x80,
hook->time, This->dinput->evsequence++);
- This->m_state.rgbButtons[1] = 0xFF;
+ This->m_state.rgbButtons[1] = 0x80;
break;
case WM_RBUTTONUP:
GEN_EVENT(This->offset_array[WINE_MOUSE_R_POSITION], 0x00,
@@ -547,9 +546,9 @@
This->m_state.rgbButtons[1] = 0x00;
break;
case WM_MBUTTONDOWN:
- GEN_EVENT(This->offset_array[WINE_MOUSE_M_POSITION], 0xFF,
+ GEN_EVENT(This->offset_array[WINE_MOUSE_M_POSITION], 0x80,
hook->time, This->dinput->evsequence++);
- This->m_state.rgbButtons[2] = 0xFF;
+ This->m_state.rgbButtons[2] = 0x80;
break;
case WM_MBUTTONUP:
GEN_EVENT(This->offset_array[WINE_MOUSE_M_POSITION], 0x00,
@@ -1115,33 +1114,31 @@
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;
}