Commit 998b9d86 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dinput: Implement SetProperty DIPROP_APPDATA using enum_objects.

parent 8847de46
...@@ -580,22 +580,6 @@ failed: ...@@ -580,22 +580,6 @@ failed:
return DIERR_OUTOFMEMORY; return DIERR_OUTOFMEMORY;
} }
static int verify_offset(const DataFormat *df, int offset)
{
int i;
if (!df->offsets)
return -1;
for (i = df->wine_df->dwNumObjs - 1; i >= 0; i--)
{
if (df->offsets[i] == offset)
return offset;
}
return -1;
}
static int id_to_object( LPCDIDATAFORMAT df, int id ) static int id_to_object( LPCDIDATAFORMAT df, int id )
{ {
int i; int i;
...@@ -1320,6 +1304,8 @@ static HRESULT WINAPI dinput_device_SetProperty( IDirectInputDevice8W *iface, co ...@@ -1320,6 +1304,8 @@ static HRESULT WINAPI dinput_device_SetProperty( IDirectInputDevice8W *iface, co
{ {
struct set_object_property_params params = {.iface = iface, .header = header, .property = LOWORD( guid )}; struct set_object_property_params params = {.iface = iface, .header = header, .property = LOWORD( guid )};
struct dinput_device *impl = impl_from_IDirectInputDevice8W( iface ); struct dinput_device *impl = impl_from_IDirectInputDevice8W( iface );
DWORD object_mask = DIDFT_AXIS | DIDFT_BUTTON | DIDFT_POV;
DIDEVICEOBJECTINSTANCEW instance;
DIPROPHEADER filter; DIPROPHEADER filter;
HRESULT hr; HRESULT hr;
...@@ -1421,18 +1407,14 @@ static HRESULT WINAPI dinput_device_SetProperty( IDirectInputDevice8W *iface, co ...@@ -1421,18 +1407,14 @@ static HRESULT WINAPI dinput_device_SetProperty( IDirectInputDevice8W *iface, co
case (DWORD_PTR)DIPROP_APPDATA: case (DWORD_PTR)DIPROP_APPDATA:
{ {
const DIPROPPOINTER *value = (const DIPROPPOINTER *)header; const DIPROPPOINTER *value = (const DIPROPPOINTER *)header;
int offset = -1; int user_offset;
if (header->dwSize != sizeof(DIPROPPOINTER)) return DIERR_INVALIDPARAM; if (header->dwSize != sizeof(DIPROPPOINTER)) return DIERR_INVALIDPARAM;
if (header->dwHow == DIPH_DEVICE) return DIERR_UNSUPPORTED;
if (header->dwHow == DIPH_BYID) hr = impl->vtbl->enum_objects( iface, &filter, object_mask, find_object, &instance );
offset = id_to_offset( &impl->data_format, header->dwObj ); if (FAILED(hr)) return hr;
else if (header->dwHow == DIPH_BYOFFSET) if (hr == DIENUM_CONTINUE) return DIERR_OBJECTNOTFOUND;
offset = verify_offset( &impl->data_format, header->dwObj ); if ((user_offset = id_to_offset( &impl->data_format, instance.dwType )) < 0) return DIERR_OBJECTNOTFOUND;
else if (!set_app_data( impl, user_offset, value->uData )) return DIERR_OUTOFMEMORY;
return DIERR_UNSUPPORTED;
if (offset == -1) return DIERR_OBJECTNOTFOUND;
if (!set_app_data( impl, offset, value->uData )) return DIERR_OUTOFMEMORY;
return DI_OK; return DI_OK;
} }
default: default:
......
...@@ -4794,7 +4794,6 @@ static void test_simple_joystick(void) ...@@ -4794,7 +4794,6 @@ static void test_simple_joystick(void)
prop_pointer.diph.dwObj = MAKELONG( HID_USAGE_GENERIC_X, HID_USAGE_PAGE_GENERIC ); prop_pointer.diph.dwObj = MAKELONG( HID_USAGE_GENERIC_X, HID_USAGE_PAGE_GENERIC );
prop_pointer.uData = 0xfeedcafe; prop_pointer.uData = 0xfeedcafe;
hr = IDirectInputDevice8_SetProperty( device, DIPROP_APPDATA, &prop_pointer.diph ); hr = IDirectInputDevice8_SetProperty( device, DIPROP_APPDATA, &prop_pointer.diph );
todo_wine
ok( hr == DI_OK, "SetProperty DIPROP_APPDATA returned %#x\n", hr ); ok( hr == DI_OK, "SetProperty DIPROP_APPDATA returned %#x\n", hr );
prop_dword.dwData = 0xdeadbeef; prop_dword.dwData = 0xdeadbeef;
......
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