dinput: Remove redundant parameter.

This commit is contained in:
Vitaliy Margolen 2006-12-12 08:58:40 -07:00 committed by Alexandre Julliard
parent d5b57f3904
commit 6246fa62f9
6 changed files with 25 additions and 23 deletions

View File

@ -336,7 +336,7 @@ static void calculate_ids(LPDIDATAFORMAT df)
} }
} }
HRESULT create_DataFormat(LPCDIDATAFORMAT wine_format, LPCDIDATAFORMAT asked_format, DataFormat *format) HRESULT create_DataFormat(LPCDIDATAFORMAT asked_format, DataFormat *format)
{ {
DataTransform *dt; DataTransform *dt;
unsigned int i, j; unsigned int i, j;
@ -344,12 +344,13 @@ HRESULT create_DataFormat(LPCDIDATAFORMAT wine_format, LPCDIDATAFORMAT asked_for
int *done; int *done;
int index = 0; int index = 0;
DWORD next = 0; DWORD next = 0;
if (!format->wine_df) return DIERR_INVALIDPARAM;
done = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, asked_format->dwNumObjs * sizeof(int)); done = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, asked_format->dwNumObjs * sizeof(int));
dt = HeapAlloc(GetProcessHeap(), 0, asked_format->dwNumObjs * sizeof(DataTransform)); dt = HeapAlloc(GetProcessHeap(), 0, asked_format->dwNumObjs * sizeof(DataTransform));
if (!dt || !done) goto failed; if (!dt || !done) goto failed;
if (!(format->offsets = HeapAlloc(GetProcessHeap(), 0, wine_format->dwNumObjs * sizeof(int)))) if (!(format->offsets = HeapAlloc(GetProcessHeap(), 0, format->wine_df->dwNumObjs * sizeof(int))))
goto failed; goto failed;
if (!(format->user_df = HeapAlloc(GetProcessHeap(), 0, asked_format->dwSize))) if (!(format->user_df = HeapAlloc(GetProcessHeap(), 0, asked_format->dwSize)))
@ -362,7 +363,8 @@ HRESULT create_DataFormat(LPCDIDATAFORMAT wine_format, LPCDIDATAFORMAT asked_for
TRACE("Creating DataTransform :\n"); TRACE("Creating DataTransform :\n");
for (i = 0; i < wine_format->dwNumObjs; i++) { for (i = 0; i < format->wine_df->dwNumObjs; i++)
{
format->offsets[i] = -1; format->offsets[i] = -1;
for (j = 0; j < asked_format->dwNumObjs; j++) { for (j = 0; j < asked_format->dwNumObjs; j++) {
@ -373,18 +375,18 @@ HRESULT create_DataFormat(LPCDIDATAFORMAT wine_format, LPCDIDATAFORMAT asked_for
* the GUID of the Wine object. * the GUID of the Wine object.
*/ */
((asked_format->rgodf[j].pguid == NULL) || ((asked_format->rgodf[j].pguid == NULL) ||
(wine_format->rgodf[i].pguid == NULL) || (format->wine_df->rgodf[i].pguid == NULL) ||
(IsEqualGUID(wine_format->rgodf[i].pguid, asked_format->rgodf[j].pguid))) (IsEqualGUID(format->wine_df->rgodf[i].pguid, asked_format->rgodf[j].pguid)))
&& &&
(/* Then check if it accepts any instance id, and if not, if it matches Wine's (/* Then check if it accepts any instance id, and if not, if it matches Wine's
* instance id. * instance id.
*/ */
(DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == 0xFFFF) || (DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == 0xFFFF) ||
(DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == 0x00FF) || /* This is mentionned in no DX docs, but it works fine - tested on WinXP */ (DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == 0x00FF) || /* This is mentionned in no DX docs, but it works fine - tested on WinXP */
(DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == DIDFT_GETINSTANCE(wine_format->rgodf[i].dwType))) (DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == DIDFT_GETINSTANCE(format->wine_df->rgodf[i].dwType)))
&& &&
( /* Then if the asked type matches the one Wine provides */ ( /* Then if the asked type matches the one Wine provides */
DIDFT_GETTYPE(asked_format->rgodf[j].dwType) & wine_format->rgodf[i].dwType)) DIDFT_GETTYPE(asked_format->rgodf[j].dwType) & format->wine_df->rgodf[i].dwType))
{ {
done[j] = 1; done[j] = 1;
@ -399,23 +401,23 @@ HRESULT create_DataFormat(LPCDIDATAFORMAT wine_format, LPCDIDATAFORMAT asked_for
TRACE(" - Wine (%d) :\n", i); TRACE(" - Wine (%d) :\n", i);
TRACE(" * GUID: %s ('%s')\n", TRACE(" * GUID: %s ('%s')\n",
debugstr_guid(wine_format->rgodf[i].pguid), debugstr_guid(format->wine_df->rgodf[i].pguid),
_dump_dinput_GUID(wine_format->rgodf[i].pguid)); _dump_dinput_GUID(format->wine_df->rgodf[i].pguid));
TRACE(" * Offset: %3d\n", wine_format->rgodf[i].dwOfs); TRACE(" * Offset: %3d\n", format->wine_df->rgodf[i].dwOfs);
TRACE(" * dwType: %08x\n", wine_format->rgodf[i].dwType); TRACE(" * dwType: %08x\n", format->wine_df->rgodf[i].dwType);
TRACE(" "); _dump_EnumObjects_flags(wine_format->rgodf[i].dwType); TRACE("\n"); TRACE(" "); _dump_EnumObjects_flags(format->wine_df->rgodf[i].dwType); TRACE("\n");
if (wine_format->rgodf[i].dwType & DIDFT_BUTTON) if (format->wine_df->rgodf[i].dwType & DIDFT_BUTTON)
dt[index].size = sizeof(BYTE); dt[index].size = sizeof(BYTE);
else else
dt[index].size = sizeof(DWORD); dt[index].size = sizeof(DWORD);
dt[index].offset_in = wine_format->rgodf[i].dwOfs; dt[index].offset_in = format->wine_df->rgodf[i].dwOfs;
dt[index].offset_out = asked_format->rgodf[j].dwOfs; dt[index].offset_out = asked_format->rgodf[j].dwOfs;
format->offsets[i] = asked_format->rgodf[j].dwOfs; format->offsets[i] = asked_format->rgodf[j].dwOfs;
dt[index].value = 0; dt[index].value = 0;
next = next + dt[index].size; next = next + dt[index].size;
if (wine_format->rgodf[i].dwOfs != dt[index].offset_out) if (format->wine_df->rgodf[i].dwOfs != dt[index].offset_out)
same = 0; same = 0;
index++; index++;
@ -451,7 +453,7 @@ HRESULT create_DataFormat(LPCDIDATAFORMAT wine_format, LPCDIDATAFORMAT asked_for
} }
} }
format->internal_format_size = wine_format->dwDataSize; format->internal_format_size = format->wine_df->dwDataSize;
format->size = index; format->size = index;
if (same) { if (same) {
HeapFree(GetProcessHeap(), 0, dt); HeapFree(GetProcessHeap(), 0, dt);
@ -635,7 +637,7 @@ HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(
EnterCriticalSection(&This->crit); EnterCriticalSection(&This->crit);
release_DataFormat(&This->data_format); release_DataFormat(&This->data_format);
res = create_DataFormat(This->data_format.wine_df, df, &This->data_format); res = create_DataFormat(df, &This->data_format);
LeaveCriticalSection(&This->crit); LeaveCriticalSection(&This->crit);
return res; return res;

View File

@ -69,7 +69,7 @@ struct IDirectInputDevice2AImpl
/* Routines to do DataFormat / WineFormat conversions */ /* Routines to do DataFormat / WineFormat conversions */
extern void fill_DataFormat(void *out, const void *in, DataFormat *df) ; extern void fill_DataFormat(void *out, const void *in, DataFormat *df) ;
extern HRESULT create_DataFormat(LPCDIDATAFORMAT wine_format, LPCDIDATAFORMAT asked_format, DataFormat *format); extern HRESULT create_DataFormat(LPCDIDATAFORMAT asked_format, DataFormat *format);
extern void release_DataFormat(DataFormat *df) ; extern void release_DataFormat(DataFormat *df) ;
extern void queue_event(LPDIRECTINPUTDEVICE8A iface, int ofs, DWORD data, DWORD time, DWORD seq); extern void queue_event(LPDIRECTINPUTDEVICE8A iface, int ofs, DWORD data, DWORD time, DWORD seq);
/* Helper functions to work with data format */ /* Helper functions to work with data format */

View File

@ -481,7 +481,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
newDevice->base.data_format.wine_df = &c_dfDIJoystick2; newDevice->base.data_format.wine_df = &c_dfDIJoystick2;
/* create the default transform filter */ /* create the default transform filter */
hr = create_DataFormat(&c_dfDIJoystick2, &c_dfDIJoystick2, &newDevice->base.data_format); hr = create_DataFormat(&c_dfDIJoystick2, &newDevice->base.data_format);
if (hr != DI_OK) goto FAILED; if (hr != DI_OK) goto FAILED;
IDirectInputDevice_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->dinput); IDirectInputDevice_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->dinput);

View File

@ -392,7 +392,7 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm
newDevice->base.data_format.wine_df = &c_dfDIJoystick2; newDevice->base.data_format.wine_df = &c_dfDIJoystick2;
/* create the default transform filter */ /* create the default transform filter */
if (create_DataFormat(&c_dfDIJoystick2, &c_dfDIJoystick2, &newDevice->base.data_format) == DI_OK) if (create_DataFormat(&c_dfDIJoystick2, &newDevice->base.data_format) == DI_OK)
return newDevice; return newDevice;
HeapFree(GetProcessHeap(),0,newDevice); HeapFree(GetProcessHeap(),0,newDevice);

View File

@ -197,7 +197,7 @@ static SysKeyboardImpl *alloc_device(REFGUID rguid, const void *kvt, IDirectInpu
InitializeCriticalSection(&newDevice->base.crit); InitializeCriticalSection(&newDevice->base.crit);
newDevice->base.data_format.wine_df = &c_dfDIKeyboard; newDevice->base.data_format.wine_df = &c_dfDIKeyboard;
if (create_DataFormat(&c_dfDIKeyboard, &c_dfDIKeyboard, &newDevice->base.data_format) == DI_OK) if (create_DataFormat(&c_dfDIKeyboard, &newDevice->base.data_format) == DI_OK)
return newDevice; return newDevice;
return NULL; return NULL;
} }

View File

@ -237,7 +237,7 @@ static SysMouseImpl *alloc_device(REFGUID rguid, const void *mvt, IDirectInputIm
newDevice->dinput = dinput; newDevice->dinput = dinput;
newDevice->base.data_format.wine_df = &Wine_InternalMouseFormat; newDevice->base.data_format.wine_df = &Wine_InternalMouseFormat;
if (create_DataFormat(&Wine_InternalMouseFormat, &Wine_InternalMouseFormat, &newDevice->base.data_format) == DI_OK) if (create_DataFormat(&Wine_InternalMouseFormat, &newDevice->base.data_format) == DI_OK)
return newDevice; return newDevice;
return NULL; return NULL;