Commit cd306046 authored by Vitaliy Margolen's avatar Vitaliy Margolen Committed by Alexandre Julliard

dinput: Pass complete DataFormat structure to find_property.

parent af71538d
......@@ -518,12 +518,12 @@ int id_to_offset(DataFormat *df, int id)
return obj >= 0 && df->offsets ? df->offsets[obj] : -1;
}
int find_property(LPCDIDATAFORMAT df, LPCDIPROPHEADER ph)
int find_property(DataFormat *df, LPCDIPROPHEADER ph)
{
switch (ph->dwHow)
{
case DIPH_BYID: return id_to_object(df, ph->dwObj);
case DIPH_BYOFFSET: return offset_to_object(df, ph->dwObj);
case DIPH_BYID: return id_to_object(df->user_df, ph->dwObj);
case DIPH_BYOFFSET: return offset_to_object(df->user_df, ph->dwObj);
}
FIXME("Unhandled ph->dwHow=='%04X'\n", (unsigned int)ph->dwHow);
......
......@@ -75,7 +75,7 @@ extern void queue_event(LPDIRECTINPUTDEVICE8A iface, int ofs, DWORD data, DWORD
/* Helper functions to work with data format */
extern int offset_to_object(LPCDIDATAFORMAT df, int offset);
extern int id_to_offset(DataFormat *df, int id);
extern int find_property(LPCDIDATAFORMAT df, LPCDIPROPHEADER ph);
extern int find_property(DataFormat *df, LPCDIPROPHEADER ph);
/**
* Callback Data used by specific callback
......
......@@ -909,7 +909,8 @@ static HRESULT WINAPI JoystickAImpl_SetProperty(
This->props[i].lMax = pr->lMax;
}
} else {
int obj = find_property(This->base.data_format.user_df, ph);
int obj = find_property(&This->base.data_format, ph);
TRACE("proprange(%d,%d) obj=%d\n", pr->lMin, pr->lMax, obj);
if (obj >= 0) {
This->props[obj].lMin = pr->lMin;
......@@ -926,7 +927,8 @@ static HRESULT WINAPI JoystickAImpl_SetProperty(
for (i = 0; i < This->base.data_format.user_df->dwNumObjs; i++)
This->props[i].lDeadZone = pd->dwData;
} else {
int obj = find_property(This->base.data_format.user_df, ph);
int obj = find_property(&This->base.data_format, ph);
TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
if (obj >= 0) {
This->props[obj].lDeadZone = pd->dwData;
......@@ -942,7 +944,8 @@ static HRESULT WINAPI JoystickAImpl_SetProperty(
for (i = 0; i < This->base.data_format.user_df->dwNumObjs; i++)
This->props[i].lSaturation = pd->dwData;
} else {
int obj = find_property(This->base.data_format.user_df, ph);
int obj = find_property(&This->base.data_format, ph);
TRACE("saturation(%d) obj=%d\n", pd->dwData, obj);
if (obj >= 0) {
This->props[obj].lSaturation = pd->dwData;
......@@ -1171,8 +1174,9 @@ static HRESULT WINAPI JoystickAImpl_GetProperty(
if (!HIWORD(rguid)) {
switch (LOWORD(rguid)) {
case (DWORD) DIPROP_RANGE: {
LPDIPROPRANGE pr = (LPDIPROPRANGE) pdiph;
int obj = find_property(This->base.data_format.user_df, pdiph);
LPDIPROPRANGE pr = (LPDIPROPRANGE)pdiph;
int obj = find_property(&This->base.data_format, pdiph);
/* The app is querying the current range of the axis
* return the lMin and lMax values */
if (obj >= 0) {
......@@ -1184,8 +1188,9 @@ static HRESULT WINAPI JoystickAImpl_GetProperty(
break;
}
case (DWORD) DIPROP_DEADZONE: {
LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
int obj = find_property(This->base.data_format.user_df, pdiph);
LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
int obj = find_property(&This->base.data_format, pdiph);
if (obj >= 0) {
pd->dwData = This->props[obj].lDeadZone;
TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
......@@ -1194,8 +1199,9 @@ static HRESULT WINAPI JoystickAImpl_GetProperty(
break;
}
case (DWORD) DIPROP_SATURATION: {
LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
int obj = find_property(This->base.data_format.user_df, pdiph);
LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
int obj = find_property(&This->base.data_format, pdiph);
if (obj >= 0) {
pd->dwData = This->props[obj].lSaturation;
TRACE("saturation(%d) obj=%d\n", pd->dwData, obj);
......
......@@ -849,7 +849,8 @@ static HRESULT WINAPI JoystickAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface,
This->wantmax[i] = pr->lMax;
}
} else {
int obj = find_property(This->base.data_format.user_df, ph);
int obj = find_property(&This->base.data_format, ph);
TRACE("proprange(%d,%d) obj=%d\n", pr->lMin, pr->lMax, obj);
if (obj >= 0) {
This->wantmin[obj] = pr->lMin;
......@@ -868,7 +869,8 @@ static HRESULT WINAPI JoystickAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface,
This->deadz[i] = pd->dwData;
}
} else {
int obj = find_property(This->base.data_format.user_df, ph);
int obj = find_property(&This->base.data_format, ph);
TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
if (obj >= 0) {
This->deadz[obj] = pd->dwData;
......@@ -1127,7 +1129,8 @@ static HRESULT WINAPI JoystickAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
switch (LOWORD(rguid)) {
case (DWORD) DIPROP_RANGE: {
LPDIPROPRANGE pr = (LPDIPROPRANGE) pdiph;
int obj = find_property(This->base.data_format.user_df, pdiph);
int obj = find_property(&This->base.data_format, pdiph);
if (obj >= 0) {
pr->lMin = This->joydev->havemin[obj];
pr->lMax = This->joydev->havemax[obj];
......
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