dinput: No need to copy default constant format. Use already defined static instead.
This commit is contained in:
parent
a051487d3b
commit
c17e06d5c0
@ -136,7 +136,6 @@ struct JoystickImpl
|
|||||||
|
|
||||||
int joyfd;
|
int joyfd;
|
||||||
|
|
||||||
LPDIDATAFORMAT internal_df;
|
|
||||||
LPDIDATAFORMAT df;
|
LPDIDATAFORMAT df;
|
||||||
DataFormat *transform; /* wine to user format converter */
|
DataFormat *transform; /* wine to user format converter */
|
||||||
int *offsets; /* object offsets */
|
int *offsets; /* object offsets */
|
||||||
@ -408,27 +407,13 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm
|
|||||||
goto FAILED;
|
goto FAILED;
|
||||||
CopyMemory(newDevice->df->rgodf,c_dfDIJoystick2.rgodf,c_dfDIJoystick2.dwNumObjs*c_dfDIJoystick2.dwObjSize);
|
CopyMemory(newDevice->df->rgodf,c_dfDIJoystick2.rgodf,c_dfDIJoystick2.dwNumObjs*c_dfDIJoystick2.dwObjSize);
|
||||||
|
|
||||||
/* no do the same for the internal df */
|
|
||||||
newDevice->internal_df = HeapAlloc(GetProcessHeap(),0,c_dfDIJoystick2.dwSize);
|
|
||||||
if (newDevice->internal_df == 0)
|
|
||||||
goto FAILED;
|
|
||||||
CopyMemory(newDevice->internal_df, &c_dfDIJoystick2, c_dfDIJoystick2.dwSize);
|
|
||||||
|
|
||||||
/* copy default objects */
|
|
||||||
newDevice->internal_df->rgodf = HeapAlloc(GetProcessHeap(),0,c_dfDIJoystick2.dwNumObjs*c_dfDIJoystick2.dwObjSize);
|
|
||||||
if (newDevice->internal_df->rgodf == 0)
|
|
||||||
goto FAILED;
|
|
||||||
CopyMemory(newDevice->internal_df->rgodf,c_dfDIJoystick2.rgodf,c_dfDIJoystick2.dwNumObjs*c_dfDIJoystick2.dwObjSize);
|
|
||||||
|
|
||||||
/* create an offsets array */
|
/* create an offsets array */
|
||||||
newDevice->offsets = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,c_dfDIJoystick2.dwNumObjs*sizeof(int));
|
newDevice->offsets = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,c_dfDIJoystick2.dwNumObjs*sizeof(int));
|
||||||
if (newDevice->offsets == 0)
|
if (newDevice->offsets == 0)
|
||||||
goto FAILED;
|
goto FAILED;
|
||||||
|
|
||||||
calculate_ids(newDevice->internal_df);
|
|
||||||
|
|
||||||
/* create the default transform filter */
|
/* create the default transform filter */
|
||||||
newDevice->transform = create_DataFormat(newDevice->internal_df, newDevice->df, newDevice->offsets);
|
newDevice->transform = create_DataFormat(&c_dfDIJoystick2, newDevice->df, newDevice->offsets);
|
||||||
calculate_ids(newDevice->df);
|
calculate_ids(newDevice->df);
|
||||||
|
|
||||||
return newDevice;
|
return newDevice;
|
||||||
@ -436,8 +421,6 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm
|
|||||||
FAILED:
|
FAILED:
|
||||||
HeapFree(GetProcessHeap(),0,newDevice->df->rgodf);
|
HeapFree(GetProcessHeap(),0,newDevice->df->rgodf);
|
||||||
HeapFree(GetProcessHeap(),0,newDevice->df);
|
HeapFree(GetProcessHeap(),0,newDevice->df);
|
||||||
HeapFree(GetProcessHeap(),0,newDevice->internal_df->rgodf);
|
|
||||||
HeapFree(GetProcessHeap(),0,newDevice->internal_df);
|
|
||||||
HeapFree(GetProcessHeap(),0,newDevice);
|
HeapFree(GetProcessHeap(),0,newDevice);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -593,7 +576,7 @@ static HRESULT WINAPI JoystickAImpl_SetDataFormat(
|
|||||||
}
|
}
|
||||||
memcpy(This->df->rgodf,df->rgodf,df->dwNumObjs*df->dwObjSize);
|
memcpy(This->df->rgodf,df->rgodf,df->dwNumObjs*df->dwObjSize);
|
||||||
|
|
||||||
This->transform = create_DataFormat(This->internal_df, This->df, This->offsets);
|
This->transform = create_DataFormat(&c_dfDIJoystick2, This->df, This->offsets);
|
||||||
calculate_ids(This->df);
|
calculate_ids(This->df);
|
||||||
|
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user