Rémi Bernon : dinput: Look for the PID set constant force output report.
Alexandre Julliard
julliard at winehq.org
Fri Oct 8 14:12:26 CDT 2021
Module: wine
Branch: master
Commit: 25a86e46682ef0ae42e2f477e070e577605bc418
URL: https://source.winehq.org/git/wine.git/?a=commit;h=25a86e46682ef0ae42e2f477e070e577605bc418
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Fri Oct 8 09:50:27 2021 +0200
dinput: Look for the PID set constant force output report.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dinput/joystick_hid.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index d2fed77ef62..9369f3d8873 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -136,6 +136,13 @@ struct pid_set_condition
struct hid_value_caps *dead_band_caps;
};
+struct pid_set_constant_force
+{
+ BYTE id;
+ ULONG collection;
+ struct hid_value_caps *magnitude_caps;
+};
+
#define DEVICE_STATE_MAX_SIZE 1024
struct hid_joystick
@@ -171,6 +178,7 @@ struct hid_joystick
struct pid_set_periodic pid_set_periodic;
struct pid_set_envelope pid_set_envelope;
struct pid_set_condition pid_set_condition;
+ struct pid_set_constant_force pid_set_constant_force;
};
static inline struct hid_joystick *impl_from_IDirectInputDevice8W( IDirectInputDevice8W *iface )
@@ -191,6 +199,7 @@ struct hid_joystick_effect
DWORD axes[6];
LONG directions[6];
+ DICONSTANTFORCE constant_force;
DICONDITION condition[2];
DIENVELOPE envelope;
DIPERIODIC periodic;
@@ -1910,6 +1919,7 @@ static BOOL init_data_format( struct hid_joystick *impl, struct hid_value_caps *
static BOOL init_pid_reports( struct hid_joystick *impl, struct hid_value_caps *caps,
DIDEVICEOBJECTINSTANCEW *instance, void *data )
{
+ struct pid_set_constant_force *set_constant_force = &impl->pid_set_constant_force;
struct pid_control_report *device_control = &impl->pid_device_control;
struct pid_control_report *effect_control = &impl->pid_effect_control;
struct pid_effect_update *effect_update = &impl->pid_effect_update;
@@ -1944,6 +1954,7 @@ static BOOL init_pid_reports( struct hid_joystick *impl, struct hid_value_caps *
case PID_USAGE_SET_PERIODIC_REPORT: SET_COLLECTION( set_periodic ); break;
case PID_USAGE_SET_ENVELOPE_REPORT: SET_COLLECTION( set_envelope ); break;
case PID_USAGE_SET_CONDITION_REPORT: SET_COLLECTION( set_condition ); break;
+ case PID_USAGE_SET_CONSTANT_FORCE_REPORT: SET_COLLECTION( set_constant_force ); break;
case PID_USAGE_DEVICE_CONTROL: SET_SUB_COLLECTION( device_control, control_coll ); break;
case PID_USAGE_EFFECT_OPERATION: SET_SUB_COLLECTION( effect_control, control_coll ); break;
@@ -1965,6 +1976,7 @@ static BOOL init_pid_reports( struct hid_joystick *impl, struct hid_value_caps *
static BOOL init_pid_caps( struct hid_joystick *impl, struct hid_value_caps *caps,
DIDEVICEOBJECTINSTANCEW *instance, void *data )
{
+ struct pid_set_constant_force *set_constant_force = &impl->pid_set_constant_force;
struct pid_control_report *device_control = &impl->pid_device_control;
struct pid_control_report *effect_control = &impl->pid_effect_control;
struct pid_effect_update *effect_update = &impl->pid_effect_update;
@@ -2111,6 +2123,16 @@ static BOOL init_pid_caps( struct hid_joystick *impl, struct hid_value_caps *cap
set_condition->dead_band_caps = caps;
}
}
+ if (instance->wCollectionNumber == set_constant_force->collection)
+ {
+ SET_REPORT_ID( set_constant_force );
+ if (instance->wUsage == PID_USAGE_MAGNITUDE)
+ {
+ caps->physical_min = -10000;
+ caps->physical_max = 10000;
+ set_constant_force->magnitude_caps = caps;
+ }
+ }
#undef SET_REPORT_ID
@@ -2220,6 +2242,8 @@ static HRESULT hid_joystick_create_device( IDirectInputImpl *dinput, const GUID
TRACE( "set periodic id %u, coll %u\n", impl->pid_set_periodic.id, impl->pid_set_periodic.collection );
TRACE( "set envelope id %u, coll %u\n", impl->pid_set_envelope.id, impl->pid_set_envelope.collection );
TRACE( "set condition id %u, coll %u\n", impl->pid_set_condition.id, impl->pid_set_condition.collection );
+ TRACE( "set constant force id %u, coll %u\n", impl->pid_set_constant_force.id,
+ impl->pid_set_constant_force.collection );
if (impl->pid_device_control.id)
{
@@ -2377,6 +2401,13 @@ static HRESULT WINAPI hid_joystick_effect_Initialize( IDirectInputEffect *iface,
if (status != HIDP_STATUS_SUCCESS) return DIERR_DEVICENOTREG;
break;
case PID_USAGE_ET_CONSTANT_FORCE:
+ status = HidP_InitializeReportForID( HidP_Output, joystick->pid_set_constant_force.id, joystick->preparsed,
+ impl->type_specific_buf[0], report_len );
+ if (status != HIDP_STATUS_SUCCESS) return DIERR_DEVICENOTREG;
+ status = HidP_InitializeReportForID( HidP_Output, joystick->pid_set_envelope.id, joystick->preparsed,
+ impl->type_specific_buf[1], report_len );
+ if (status != HIDP_STATUS_SUCCESS) return DIERR_DEVICENOTREG;
+ break;
case PID_USAGE_ET_RAMP:
case PID_USAGE_ET_CUSTOM_FORCE_DATA:
FIXME( "effect type %#x not implemented!\n", type );
@@ -2526,6 +2557,10 @@ static HRESULT WINAPI hid_joystick_effect_GetParameters( IDirectInputEffect *ifa
memcpy( params->lpvTypeSpecificParams, impl->condition, params->cbTypeSpecificParams );
break;
case PID_USAGE_ET_CONSTANT_FORCE:
+ if (!params->lpvTypeSpecificParams) return E_POINTER;
+ if (params->cbTypeSpecificParams != sizeof(DICONSTANTFORCE)) return DIERR_INVALIDPARAM;
+ memcpy( params->lpvTypeSpecificParams, &impl->constant_force, sizeof(DICONSTANTFORCE) );
+ break;
case PID_USAGE_ET_RAMP:
case PID_USAGE_ET_CUSTOM_FORCE_DATA:
FIXME( "DIEP_TYPESPECIFICPARAMS not implemented!\n" );
@@ -2684,6 +2719,13 @@ static HRESULT WINAPI hid_joystick_effect_SetParameters( IDirectInputEffect *ifa
}
break;
case PID_USAGE_ET_CONSTANT_FORCE:
+ if (!params->lpvTypeSpecificParams) return E_POINTER;
+ if (params->cbTypeSpecificParams != sizeof(DICONSTANTFORCE)) return DIERR_INVALIDPARAM;
+ if (memcmp( &impl->constant_force, params->lpvTypeSpecificParams, sizeof(DICONSTANTFORCE) ))
+ impl->modified = TRUE;
+ memcpy( &impl->constant_force, params->lpvTypeSpecificParams, sizeof(DICONSTANTFORCE) );
+ impl->params.cbTypeSpecificParams = sizeof(DICONSTANTFORCE);
+ break;
case PID_USAGE_ET_RAMP:
case PID_USAGE_ET_CUSTOM_FORCE_DATA:
FIXME( "DIEP_TYPESPECIFICPARAMS not implemented!\n" );
@@ -2890,6 +2932,7 @@ static HRESULT WINAPI hid_joystick_effect_Download( IDirectInputEffect *iface )
{
static const DWORD complete_mask = DIEP_AXES | DIEP_DIRECTION | DIEP_TYPESPECIFICPARAMS;
struct hid_joystick_effect *impl = impl_from_IDirectInputEffect( iface );
+ struct pid_set_constant_force *set_constant_force = &impl->joystick->pid_set_constant_force;
struct pid_effect_update *effect_update = &impl->joystick->pid_effect_update;
struct pid_set_condition *set_condition = &impl->joystick->pid_set_condition;
struct pid_set_periodic *set_periodic = &impl->joystick->pid_set_periodic;
@@ -2981,6 +3024,25 @@ static HRESULT WINAPI hid_joystick_effect_Download( IDirectInputEffect *iface )
else hr = DIERR_INPUTLOST;
}
break;
+ case PID_USAGE_ET_CONSTANT_FORCE:
+ set_parameter_value( impl, impl->type_specific_buf[0], set_constant_force->magnitude_caps,
+ impl->constant_force.lMagnitude );
+
+ if (WriteFile( device, impl->type_specific_buf[0], report_len, NULL, NULL )) hr = DI_OK;
+ else hr = DIERR_INPUTLOST;
+
+ set_parameter_value( impl, impl->type_specific_buf[1], set_envelope->attack_level_caps,
+ impl->envelope.dwAttackLevel );
+ set_parameter_value_us( impl, impl->type_specific_buf[1], set_envelope->attack_time_caps,
+ impl->envelope.dwAttackTime );
+ set_parameter_value( impl, impl->type_specific_buf[1], set_envelope->fade_level_caps,
+ impl->envelope.dwFadeLevel );
+ set_parameter_value_us( impl, impl->type_specific_buf[1], set_envelope->fade_time_caps,
+ impl->envelope.dwFadeTime );
+
+ if (WriteFile( device, impl->type_specific_buf[1], report_len, NULL, NULL )) hr = DI_OK;
+ else hr = DIERR_INPUTLOST;
+ break;
}
set_parameter_value_us( impl, impl->effect_update_buf, effect_update->duration_caps,
More information about the wine-cvs
mailing list