dinput: Change EnumObjects to use GetObjectInfo.
Also small debug trace correction to make it more readable.
This commit is contained in:
parent
d8c67c3415
commit
504798ce9f
|
@ -800,15 +800,12 @@ ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
|
||||||
return InterlockedIncrement(&(This->ref));
|
return InterlockedIncrement(&(This->ref));
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
|
HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(LPDIRECTINPUTDEVICE8A iface,
|
||||||
LPDIRECTINPUTDEVICE8A iface,
|
LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID lpvRef, DWORD dwFlags)
|
||||||
LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
|
|
||||||
LPVOID lpvRef,
|
|
||||||
DWORD dwFlags)
|
|
||||||
{
|
{
|
||||||
IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
|
IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
|
||||||
DIDEVICEOBJECTINSTANCEA ddoi;
|
DIDEVICEOBJECTINSTANCEA ddoi;
|
||||||
int i, axis = 0, button = 0;
|
int i;
|
||||||
|
|
||||||
TRACE("(%p) %p,%p flags:%08x)\n", iface, lpCallback, lpvRef, dwFlags);
|
TRACE("(%p) %p,%p flags:%08x)\n", iface, lpCallback, lpvRef, dwFlags);
|
||||||
TRACE(" - flags = ");
|
TRACE(" - flags = ");
|
||||||
|
@ -821,56 +818,46 @@ HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
|
||||||
|
|
||||||
for (i = 0; i < This->data_format.wine_df->dwNumObjs; i++)
|
for (i = 0; i < This->data_format.wine_df->dwNumObjs; i++)
|
||||||
{
|
{
|
||||||
LPDIOBJECTDATAFORMAT odf;
|
LPDIOBJECTDATAFORMAT odf = dataformat_to_odf(This->data_format.wine_df, i);
|
||||||
DWORD type;
|
|
||||||
|
|
||||||
odf = (LPDIOBJECTDATAFORMAT)((LPBYTE)This->data_format.wine_df->rgodf +
|
if (dwFlags != DIDFT_ALL && !(dwFlags & DIEFT_GETTYPE(odf->dwType))) continue;
|
||||||
i * This->data_format.wine_df->dwObjSize);
|
if (IDirectInputDevice_GetObjectInfo(iface, &ddoi, odf->dwType, DIPH_BYID) != DI_OK)
|
||||||
type = DIEFT_GETTYPE(odf->dwType);
|
continue;
|
||||||
|
|
||||||
if (type & DIDFT_AXIS) axis++;
|
|
||||||
else if (type & DIDFT_BUTTON) button++;
|
|
||||||
|
|
||||||
if (dwFlags != DIDFT_ALL && !(dwFlags & type)) continue;
|
|
||||||
|
|
||||||
ddoi.guidType = *odf->pguid;
|
|
||||||
ddoi.dwType = odf->dwType;
|
|
||||||
ddoi.dwFlags = odf->dwFlags;
|
|
||||||
ddoi.dwOfs = !This->data_format.offsets ? odf->dwOfs : This->data_format.offsets[i];
|
|
||||||
|
|
||||||
if (IsEqualGUID(&ddoi.guidType, &GUID_XAxis)) strcpy(ddoi.tszName, "X-Axis");
|
|
||||||
else if (IsEqualGUID(&ddoi.guidType, &GUID_YAxis)) strcpy(ddoi.tszName, "Y-Axis");
|
|
||||||
else if (IsEqualGUID(&ddoi.guidType, &GUID_ZAxis)) strcpy(ddoi.tszName, "Z-Axis");
|
|
||||||
else if (IsEqualGUID(&ddoi.guidType, &GUID_Key ))
|
|
||||||
GetKeyNameTextA((DIDFT_GETINSTANCE(odf->dwType) & 0x80) << 17 |
|
|
||||||
(DIDFT_GETINSTANCE(odf->dwType) & 0x7f) << 16,
|
|
||||||
ddoi.tszName, sizeof(ddoi.tszName));
|
|
||||||
else if (type & DIDFT_AXIS) wsprintfA(ddoi.tszName, "%d-Axis", axis - 1);
|
|
||||||
else if (type & DIDFT_BUTTON) wsprintfA(ddoi.tszName, "Button %d", button - 1);
|
|
||||||
else FIXME("no name\n");
|
|
||||||
|
|
||||||
_dump_OBJECTINSTANCEA(&ddoi);
|
|
||||||
if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) break;
|
if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(
|
HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface,
|
||||||
LPDIRECTINPUTDEVICE8W iface,
|
LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID lpvRef, DWORD dwFlags)
|
||||||
LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
|
|
||||||
LPVOID lpvRef,
|
|
||||||
DWORD dwFlags)
|
|
||||||
{
|
{
|
||||||
device_enumobjects_AtoWcb_data data;
|
IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
|
||||||
|
DIDEVICEOBJECTINSTANCEW ddoi;
|
||||||
|
int i;
|
||||||
|
|
||||||
data.lpCallBack = lpCallback;
|
TRACE("(%p) %p,%p flags:%08x)\n", iface, lpCallback, lpvRef, dwFlags);
|
||||||
data.lpvRef = lpvRef;
|
TRACE(" - flags = ");
|
||||||
|
_dump_EnumObjects_flags(dwFlags);
|
||||||
|
TRACE("\n");
|
||||||
|
|
||||||
return IDirectInputDevice2AImpl_EnumObjects(
|
/* Only the fields till dwFFMaxForce are relevant */
|
||||||
(LPDIRECTINPUTDEVICE8A) iface,
|
memset(&ddoi, 0, sizeof(ddoi));
|
||||||
(LPDIENUMDEVICEOBJECTSCALLBACKA) DIEnumDevicesCallbackAtoW,
|
ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, dwFFMaxForce);
|
||||||
(LPVOID) &data, dwFlags);
|
|
||||||
|
for (i = 0; i < This->data_format.wine_df->dwNumObjs; i++)
|
||||||
|
{
|
||||||
|
LPDIOBJECTDATAFORMAT odf = dataformat_to_odf(This->data_format.wine_df, i);
|
||||||
|
|
||||||
|
if (dwFlags != DIDFT_ALL && !(dwFlags & DIEFT_GETTYPE(odf->dwType))) continue;
|
||||||
|
if (IDirectInputDevice_GetObjectInfo(iface, &ddoi, odf->dwType, DIPH_BYID) != DI_OK)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
|
|
@ -59,8 +59,8 @@ static const DIDATAFORMAT data_format = {
|
||||||
static BOOL CALLBACK enum_callback(LPCDIDEVICEOBJECTINSTANCE oi, LPVOID info)
|
static BOOL CALLBACK enum_callback(LPCDIDEVICEOBJECTINSTANCE oi, LPVOID info)
|
||||||
{
|
{
|
||||||
if (winetest_debug > 1)
|
if (winetest_debug > 1)
|
||||||
trace(" Type:%4x Ofs:%2x Name:%s Flags:%08x\n",
|
trace(" Type:%4x Ofs:%3d Flags:%08x Name:%s\n",
|
||||||
oi->dwType, oi->dwOfs, oi->tszName, oi->dwFlags);
|
oi->dwType, oi->dwOfs, oi->dwFlags, oi->tszName);
|
||||||
(*(int*)info)++;
|
(*(int*)info)++;
|
||||||
return DIENUM_CONTINUE;
|
return DIENUM_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue