dinput: [joystick_linux] Reuse the same properties array.

This commit is contained in:
Vitaliy Margolen 2007-01-09 13:43:59 -07:00 committed by Alexandre Julliard
parent 3989e0feb8
commit 60948ab1f0
1 changed files with 8 additions and 14 deletions

View File

@ -654,7 +654,6 @@ static HRESULT WINAPI JoystickAImpl_SetDataFormat(
{ {
JoystickImpl *This = (JoystickImpl *)iface; JoystickImpl *This = (JoystickImpl *)iface;
unsigned int i; unsigned int i;
ObjProps * new_props = 0;
HRESULT hr; HRESULT hr;
TRACE("(%p,%p)\n",This,df); TRACE("(%p,%p)\n",This,df);
@ -662,13 +661,8 @@ static HRESULT WINAPI JoystickAImpl_SetDataFormat(
hr = IDirectInputDevice2AImpl_SetDataFormat(iface, df); hr = IDirectInputDevice2AImpl_SetDataFormat(iface, df);
if (FAILED(hr)) return hr; if (FAILED(hr)) return hr;
new_props = HeapAlloc(GetProcessHeap(),0,df->dwNumObjs*sizeof(ObjProps)); for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
if (!new_props) return DIERR_OUTOFMEMORY; {
HeapFree(GetProcessHeap(),0,This->props);
This->props = new_props;
for (i = 0; i < df->dwNumObjs; i++) {
This->props[i].lMin = 0; This->props[i].lMin = 0;
This->props[i].lMax = 0xffff; This->props[i].lMax = 0xffff;
This->props[i].lDeadZone = 1000; This->props[i].lDeadZone = 1000;
@ -925,10 +919,10 @@ static HRESULT WINAPI JoystickAImpl_SetProperty(
if (!HIWORD(rguid)) { if (!HIWORD(rguid)) {
switch (LOWORD(rguid)) { switch (LOWORD(rguid)) {
case (DWORD)DIPROP_RANGE: { case (DWORD)DIPROP_RANGE: {
LPCDIPROPRANGE pr = (LPCDIPROPRANGE)ph; LPCDIPROPRANGE pr = (LPCDIPROPRANGE)ph;
if (ph->dwHow == DIPH_DEVICE) { if (ph->dwHow == DIPH_DEVICE) {
TRACE("proprange(%d,%d) all\n", pr->lMin, pr->lMax); TRACE("proprange(%d,%d) all\n", pr->lMin, pr->lMax);
for (i = 0; i < This->base.data_format.user_df->dwNumObjs; i++) { for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++) {
This->props[i].lMin = pr->lMin; This->props[i].lMin = pr->lMin;
This->props[i].lMax = pr->lMax; This->props[i].lMax = pr->lMax;
} }
@ -945,10 +939,10 @@ static HRESULT WINAPI JoystickAImpl_SetProperty(
break; break;
} }
case (DWORD)DIPROP_DEADZONE: { case (DWORD)DIPROP_DEADZONE: {
LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph; LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
if (ph->dwHow == DIPH_DEVICE) { if (ph->dwHow == DIPH_DEVICE) {
TRACE("deadzone(%d) all\n", pd->dwData); TRACE("deadzone(%d) all\n", pd->dwData);
for (i = 0; i < This->base.data_format.user_df->dwNumObjs; i++) for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
This->props[i].lDeadZone = pd->dwData; This->props[i].lDeadZone = pd->dwData;
} else { } else {
int obj = find_property(&This->base.data_format, ph); int obj = find_property(&This->base.data_format, ph);
@ -962,10 +956,10 @@ static HRESULT WINAPI JoystickAImpl_SetProperty(
break; break;
} }
case (DWORD)DIPROP_SATURATION: { case (DWORD)DIPROP_SATURATION: {
LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph; LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
if (ph->dwHow == DIPH_DEVICE) { if (ph->dwHow == DIPH_DEVICE) {
TRACE("saturation(%d) all\n", pd->dwData); TRACE("saturation(%d) all\n", pd->dwData);
for (i = 0; i < This->base.data_format.user_df->dwNumObjs; i++) for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
This->props[i].lSaturation = pd->dwData; This->props[i].lSaturation = pd->dwData;
} else { } else {
int obj = find_property(&This->base.data_format, ph); int obj = find_property(&This->base.data_format, ph);