dinput: Implement HID joystick IDirectInputDevice8_SetProperty.
For DIPROP_RANGE property on POVs and Axes, and initialize it on creation. This uses the value caps physical range, as it's exactly the purpose and we don't use it for anything else otherwise. We'll scale values from their logical range directly anyway to save a conversion. Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
81c15d2d81
commit
2681caa3f8
|
@ -427,6 +427,16 @@ static HRESULT WINAPI hid_joystick_GetCapabilities( IDirectInputDevice8W *iface,
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL get_property_prop_range( struct hid_joystick *impl, struct hid_caps *caps,
|
||||||
|
DIDEVICEOBJECTINSTANCEW *instance, void *data )
|
||||||
|
{
|
||||||
|
HIDP_VALUE_CAPS *value_caps = caps->value;
|
||||||
|
DIPROPRANGE *value = data;
|
||||||
|
value->lMin = value_caps->PhysicalMin;
|
||||||
|
value->lMax = value_caps->PhysicalMax;
|
||||||
|
return DIENUM_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI hid_joystick_GetProperty( IDirectInputDevice8W *iface, const GUID *guid,
|
static HRESULT WINAPI hid_joystick_GetProperty( IDirectInputDevice8W *iface, const GUID *guid,
|
||||||
DIPROPHEADER *header )
|
DIPROPHEADER *header )
|
||||||
{
|
{
|
||||||
|
@ -439,6 +449,9 @@ static HRESULT WINAPI hid_joystick_GetProperty( IDirectInputDevice8W *iface, con
|
||||||
|
|
||||||
switch (LOWORD( guid ))
|
switch (LOWORD( guid ))
|
||||||
{
|
{
|
||||||
|
case (DWORD_PTR)DIPROP_RANGE:
|
||||||
|
enum_value_objects( impl, header, DIDFT_AXIS, get_property_prop_range, header );
|
||||||
|
return DI_OK;
|
||||||
case (DWORD_PTR)DIPROP_PRODUCTNAME:
|
case (DWORD_PTR)DIPROP_PRODUCTNAME:
|
||||||
{
|
{
|
||||||
DIPROPSTRING *value = (DIPROPSTRING *)header;
|
DIPROPSTRING *value = (DIPROPSTRING *)header;
|
||||||
|
@ -477,6 +490,41 @@ static HRESULT WINAPI hid_joystick_GetProperty( IDirectInputDevice8W *iface, con
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL set_property_prop_range( struct hid_joystick *impl, struct hid_caps *caps,
|
||||||
|
DIDEVICEOBJECTINSTANCEW *instance, void *data )
|
||||||
|
{
|
||||||
|
HIDP_VALUE_CAPS *value_caps = caps->value;
|
||||||
|
DIPROPRANGE *value = data;
|
||||||
|
LONG range = value_caps->LogicalMax - value_caps->LogicalMin;
|
||||||
|
value_caps->PhysicalMin = value->lMin;
|
||||||
|
value_caps->PhysicalMax = value->lMax;
|
||||||
|
if (instance->dwType & DIDFT_POV && range > 0)
|
||||||
|
value_caps->PhysicalMax -= value->lMax / (range + 1);
|
||||||
|
return DIENUM_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI hid_joystick_SetProperty( IDirectInputDevice8W *iface, const GUID *guid,
|
||||||
|
const DIPROPHEADER *header )
|
||||||
|
{
|
||||||
|
struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface );
|
||||||
|
|
||||||
|
TRACE( "iface %p, guid %s, header %p\n", iface, debugstr_guid( guid ), header );
|
||||||
|
|
||||||
|
if (!header) return DIERR_INVALIDPARAM;
|
||||||
|
if (!IS_DIPROP( guid )) return DI_OK;
|
||||||
|
|
||||||
|
switch (LOWORD( guid ))
|
||||||
|
{
|
||||||
|
case (DWORD_PTR)DIPROP_RANGE:
|
||||||
|
enum_value_objects( impl, header, DIDFT_AXIS, set_property_prop_range, (void *)header );
|
||||||
|
return DI_OK;
|
||||||
|
default:
|
||||||
|
return IDirectInputDevice2WImpl_SetProperty( iface, guid, header );
|
||||||
|
}
|
||||||
|
|
||||||
|
return DI_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI hid_joystick_GetDeviceState( IDirectInputDevice8W *iface, DWORD len, void *ptr )
|
static HRESULT WINAPI hid_joystick_GetDeviceState( IDirectInputDevice8W *iface, DWORD len, void *ptr )
|
||||||
{
|
{
|
||||||
struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface );
|
struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface );
|
||||||
|
@ -536,7 +584,7 @@ static const IDirectInputDevice8WVtbl hid_joystick_vtbl =
|
||||||
hid_joystick_GetCapabilities,
|
hid_joystick_GetCapabilities,
|
||||||
IDirectInputDevice2WImpl_EnumObjects,
|
IDirectInputDevice2WImpl_EnumObjects,
|
||||||
hid_joystick_GetProperty,
|
hid_joystick_GetProperty,
|
||||||
IDirectInputDevice2WImpl_SetProperty,
|
hid_joystick_SetProperty,
|
||||||
IDirectInputDevice2WImpl_Acquire,
|
IDirectInputDevice2WImpl_Acquire,
|
||||||
IDirectInputDevice2WImpl_Unacquire,
|
IDirectInputDevice2WImpl_Unacquire,
|
||||||
hid_joystick_GetDeviceState,
|
hid_joystick_GetDeviceState,
|
||||||
|
@ -747,6 +795,15 @@ static HRESULT hid_joystick_create_device( IDirectInputImpl *dinput, const GUID
|
||||||
.guidProduct = *guid,
|
.guidProduct = *guid,
|
||||||
.guidInstance = *guid
|
.guidInstance = *guid
|
||||||
};
|
};
|
||||||
|
DIPROPRANGE range =
|
||||||
|
{
|
||||||
|
.diph =
|
||||||
|
{
|
||||||
|
.dwSize = sizeof(range),
|
||||||
|
.dwHeaderSize = sizeof(DIPROPHEADER),
|
||||||
|
.dwHow = DIPH_DEVICE,
|
||||||
|
},
|
||||||
|
};
|
||||||
HIDD_ATTRIBUTES attrs = {.Size = sizeof(attrs)};
|
HIDD_ATTRIBUTES attrs = {.Size = sizeof(attrs)};
|
||||||
HIDP_LINK_COLLECTION_NODE *nodes;
|
HIDP_LINK_COLLECTION_NODE *nodes;
|
||||||
struct hid_joystick *impl = NULL;
|
struct hid_joystick *impl = NULL;
|
||||||
|
@ -826,6 +883,11 @@ static HRESULT hid_joystick_create_device( IDirectInputImpl *dinput, const GUID
|
||||||
|
|
||||||
_dump_DIDATAFORMAT( impl->base.data_format.wine_df );
|
_dump_DIDATAFORMAT( impl->base.data_format.wine_df );
|
||||||
|
|
||||||
|
range.lMax = 65535;
|
||||||
|
enum_value_objects( impl, &range.diph, DIDFT_AXIS, set_property_prop_range, &range );
|
||||||
|
range.lMax = 36000;
|
||||||
|
enum_value_objects( impl, &range.diph, DIDFT_POV, set_property_prop_range, &range );
|
||||||
|
|
||||||
*out = &impl->base.IDirectInputDevice8W_iface;
|
*out = &impl->base.IDirectInputDevice8W_iface;
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue