It is only relevant for FFB devices, and is already being called by hid_joystick_unacquire().
From: Ivo Ivanov logos128@gmail.com Signed-off-by: Ivo Ivanov logos128@gmail.com Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 85392c6b30b..e0d15893bd4 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -741,8 +741,6 @@ void dinput_device_destroy( IDirectInputDevice8W *iface ) TRACE( "iface %p.\n", iface );
IDirectInputDevice_Unacquire(iface); - /* Reset the FF state, free all effects, etc */ - IDirectInputDevice8_SendForceFeedbackCommand(iface, DISFFC_RESET);
free( This->data_queue );
Avoid crashing in dinput_device_destroy, calling Unacquire while device resources may be already freed up.
From: Ivo Ivanov logos128@gmail.com Signed-off-by: Ivo Ivanov logos128@gmail.com Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index e0d15893bd4..3297e857afa 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -740,8 +740,6 @@ void dinput_device_destroy( IDirectInputDevice8W *iface )
TRACE( "iface %p.\n", iface );
- IDirectInputDevice_Unacquire(iface); - free( This->data_queue );
/* Free data format */ @@ -768,6 +766,7 @@ static ULONG WINAPI dinput_device_Release( IDirectInputDevice8W *iface )
if (!ref) { + IDirectInputDevice_Unacquire( iface ); if (impl->vtbl->release) impl->vtbl->release( iface ); else dinput_device_destroy( iface ); }
From: Ivo Ivanov logos128@gmail.com
Signed-off-by: Ivo Ivanov logos128@gmail.com Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 2 +- dlls/dinput/joystick_hid.c | 34 ++-------------------------------- 2 files changed, 3 insertions(+), 33 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 3297e857afa..114c7538eb2 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1480,7 +1480,7 @@ static HRESULT WINAPI dinput_device_SendForceFeedbackCommand( IDirectInputDevice struct dinput_device *impl = impl_from_IDirectInputDevice8W( iface ); HRESULT hr;
- TRACE( "iface %p, flags %x.\n", iface, command ); + TRACE( "iface %p, command %#x.\n", iface, command );
switch (command) { diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 5a3c46e2d9a..cb920adab06 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -52,25 +52,6 @@ DEFINE_GUID( GUID_DEVINTERFACE_WINEXINPUT,0x6c53d5fd,0x6480,0x440f,0xb6,0x18,0x4 DEFINE_GUID( hid_joystick_guid, 0x9e573edb, 0x7734, 0x11d2, 0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7 ); DEFINE_DEVPROPKEY( DEVPROPKEY_HID_HANDLE, 0xbc62e415, 0xf4fe, 0x405c, 0x8e, 0xda, 0x63, 0x6f, 0xb5, 0x9f, 0x08, 0x98, 2 );
-static inline const char *debugstr_hid_value_caps( struct hid_value_caps *caps ) -{ - if (!caps) return "(null)"; - return wine_dbg_sprintf( "RId %d, Usg %02x:%02x-%02x Dat %02x-%02x, Str %d-%d, Des %d-%d, " - "Bits %02x Flags %#x, LCol %d LUsg %02x:%02x, BitSz %d, RCnt %d, Unit %x E%+d, Log %+d-%+d, Phy %+d-%+d", - caps->report_id, caps->usage_page, caps->usage_min, caps->usage_max, caps->data_index_min, caps->data_index_max, - caps->string_min, caps->string_max, caps->designator_min, caps->designator_max, caps->bit_field, caps->flags, - caps->link_collection, caps->link_usage_page, caps->link_usage, caps->bit_size, caps->report_count, - caps->units, caps->units_exp, caps->logical_min, caps->logical_max, caps->physical_min, caps->physical_max ); -} - -static inline const char *debugstr_hid_collection_node( struct hid_collection_node *node ) -{ - if (!node) return "(null)"; - return wine_dbg_sprintf( "Usg %02x:%02x, Parent %u, Next %u, NbChild %u, Child %u, Type %02x", - node->usage_page, node->usage, node->parent, node->next_sibling, - node->number_of_children, node->first_child, node->collection_type ); -} - struct extra_caps { LONG bit_size; @@ -418,15 +399,11 @@ static BOOL enum_objects( struct hid_joystick *impl, const DIPROPHEADER *filter,
if (caps->usage_page == HID_USAGE_PAGE_PID) { - TRACE( "Ignoring input caps %s, PID specific.\n", debugstr_hid_value_caps( caps ) ); value_ofs += (caps->usage_max - caps->usage_min + 1) * sizeof(LONG); object += caps->usage_max - caps->usage_min + 1; } else if (caps->usage_page >= HID_USAGE_PAGE_VENDOR_DEFINED_BEGIN) - { - TRACE( "Ignoring input value %s, vendor specific.\n", debugstr_hid_value_caps( caps ) ); value_ofs += (caps->usage_max - caps->usage_min + 1) * sizeof(LONG); - } else for (j = caps->usage_min; j <= caps->usage_max; ++j) { instance.dwOfs = value_ofs; @@ -498,15 +475,11 @@ static BOOL enum_objects( struct hid_joystick *impl, const DIPROPHEADER *filter,
if (caps->usage_page == HID_USAGE_PAGE_PID) { - TRACE( "Ignoring input caps %s, PID specific.\n", debugstr_hid_value_caps( caps ) ); button_ofs += caps->usage_max - caps->usage_min + 1; object += caps->usage_max - caps->usage_min + 1; } else if (caps->usage_page >= HID_USAGE_PAGE_VENDOR_DEFINED_BEGIN) - { - TRACE( "Ignoring input button %s, vendor specific.\n", debugstr_hid_value_caps( caps ) ); button_ofs += caps->usage_max - caps->usage_min + 1; - } else for (j = caps->usage_min; j <= caps->usage_max; ++j) { instance.dwOfs = button_ofs; @@ -538,7 +511,6 @@ static BOOL enum_objects( struct hid_joystick *impl, const DIPROPHEADER *filter,
if (caps->usage_page >= HID_USAGE_PAGE_VENDOR_DEFINED_BEGIN) { - TRACE( "Ignoring output caps %s, vendor specific.\n", debugstr_hid_value_caps( caps ) ); if (caps->flags & HID_VALUE_CAPS_IS_BUTTON) button_ofs += caps->usage_max - caps->usage_min + 1; else value_ofs += (caps->usage_max - caps->usage_min + 1) * sizeof(LONG); } @@ -593,9 +565,7 @@ static BOOL enum_objects( struct hid_joystick *impl, const DIPROPHEADER *filter, node != node_end; ++node) { if (!node->usage_page) continue; - if (node->usage_page >= HID_USAGE_PAGE_VENDOR_DEFINED_BEGIN) - TRACE( "Ignoring collection %s, vendor specific.\n", debugstr_hid_collection_node( node ) ); - else + if (node->usage_page < HID_USAGE_PAGE_VENDOR_DEFINED_BEGIN) { instance.dwOfs = 0; instance.dwType = DIDFT_COLLECTION | DIDFT_MAKEINSTANCE( collection++ ) | DIDFT_NODATA; @@ -877,7 +847,7 @@ static HRESULT hid_joystick_get_effect_info( IDirectInputDevice8W *iface, DIEFFE usage, &button, &count, preparsed ); if (status != HIDP_STATUS_SUCCESS) { - WARN( "HidP_GetSpecificValueCaps %#x returned %#x\n", usage, status ); + WARN( "HidP_GetSpecificButtonCaps %#x returned %#x\n", usage, status ); return DIERR_DEVICENOTREG; } else if (!count)
From: Ivo Ivanov logos128@gmail.com Signed-off-by: Ivo Ivanov logos128@gmail.com Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index cb920adab06..fa3c01ec673 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -278,31 +278,19 @@ static inline const GUID *effect_usage_to_guid( USAGE usage )
static const WCHAR *effect_guid_to_string( const GUID *guid ) { - static const WCHAR guid_customforce_w[] = {'G','U','I','D','_','C','u','s','t','o','m','F','o','r','c','e',0}; - static const WCHAR guid_constantforce_w[] = {'G','U','I','D','_','C','o','n','s','t','a','n','t','F','o','r','c','e',0}; - static const WCHAR guid_rampforce_w[] = {'G','U','I','D','_','R','a','m','p','F','o','r','c','e',0}; - static const WCHAR guid_square_w[] = {'G','U','I','D','_','S','q','u','a','r','e',0}; - static const WCHAR guid_sine_w[] = {'G','U','I','D','_','S','i','n','e',0}; - static const WCHAR guid_triangle_w[] = {'G','U','I','D','_','T','r','i','a','n','g','l','e',0}; - static const WCHAR guid_sawtoothup_w[] = {'G','U','I','D','_','S','a','w','t','o','o','t','h','U','p',0}; - static const WCHAR guid_sawtoothdown_w[] = {'G','U','I','D','_','S','a','w','t','o','o','t','h','D','o','w','n',0}; - static const WCHAR guid_spring_w[] = {'G','U','I','D','_','S','p','r','i','n','g',0}; - static const WCHAR guid_damper_w[] = {'G','U','I','D','_','D','a','m','p','e','r',0}; - static const WCHAR guid_inertia_w[] = {'G','U','I','D','_','I','n','e','r','t','i','a',0}; - static const WCHAR guid_friction_w[] = {'G','U','I','D','_','F','r','i','c','t','i','o','n',0}; - if (IsEqualGUID( guid, &GUID_CustomForce )) return guid_customforce_w; - if (IsEqualGUID( guid, &GUID_ConstantForce )) return guid_constantforce_w; - if (IsEqualGUID( guid, &GUID_RampForce )) return guid_rampforce_w; - if (IsEqualGUID( guid, &GUID_Square )) return guid_square_w; - if (IsEqualGUID( guid, &GUID_Sine )) return guid_sine_w; - if (IsEqualGUID( guid, &GUID_Triangle )) return guid_triangle_w; - if (IsEqualGUID( guid, &GUID_SawtoothUp )) return guid_sawtoothup_w; - if (IsEqualGUID( guid, &GUID_SawtoothDown )) return guid_sawtoothdown_w; - if (IsEqualGUID( guid, &GUID_Spring )) return guid_spring_w; - if (IsEqualGUID( guid, &GUID_Damper )) return guid_damper_w; - if (IsEqualGUID( guid, &GUID_Inertia )) return guid_inertia_w; - if (IsEqualGUID( guid, &GUID_Friction )) return guid_friction_w; - return NULL; + if (IsEqualGUID( guid, &GUID_CustomForce )) return L"GUID_CustomForce"; + if (IsEqualGUID( guid, &GUID_ConstantForce )) return L"GUID_ConstantForce"; + if (IsEqualGUID( guid, &GUID_RampForce )) return L"GUID_RampForce"; + if (IsEqualGUID( guid, &GUID_Square )) return L"GUID_Square"; + if (IsEqualGUID( guid, &GUID_Sine )) return L"GUID_Sine"; + if (IsEqualGUID( guid, &GUID_Triangle )) return L"GUID_Triangle"; + if (IsEqualGUID( guid, &GUID_SawtoothUp )) return L"GUID_SawtoothUp"; + if (IsEqualGUID( guid, &GUID_SawtoothDown )) return L"GUID_SawtoothDown"; + if (IsEqualGUID( guid, &GUID_Spring )) return L"GUID_Spring"; + if (IsEqualGUID( guid, &GUID_Damper )) return L"GUID_Damper"; + if (IsEqualGUID( guid, &GUID_Inertia )) return L"GUID_Inertia"; + if (IsEqualGUID( guid, &GUID_Friction )) return L"GUID_Friction"; + return L"GUID_Unknown"; }
static HRESULT find_next_effect_id( struct hid_joystick *impl, ULONG *index )
From: Ivo Ivanov logos128@gmail.com
Signed-off-by: Ivo Ivanov logos128@gmail.com Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index fa3c01ec673..b5b3c73d3de 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -1679,7 +1679,7 @@ static BOOL init_pid_caps( struct hid_joystick *impl, struct hid_value_caps *cap { caps->physical_min = -10000; caps->physical_max = 10000; - set_ramp_force->start_caps = caps; + set_ramp_force->end_caps = caps; } }
From: Ivo Ivanov logos128@gmail.com
It is implied from the complete_mask check above.
Signed-off-by: Ivo Ivanov logos128@gmail.com Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index b5b3c73d3de..4fdf961a04d 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -2698,24 +2698,21 @@ static HRESULT WINAPI hid_joystick_effect_Download( IDirectInputEffect *iface ) set_parameter_value_us( impl, impl->effect_update_buf, effect_update->trigger_repeat_interval_caps, impl->params.dwTriggerRepeatInterval );
- if (impl->flags & DIEP_DIRECTION) + count = 1; + usage = PID_USAGE_DIRECTION_ENABLE; + status = HidP_SetUsages( HidP_Output, HID_USAGE_PAGE_PID, 0, &usage, &count, + impl->joystick->preparsed, impl->effect_update_buf, report_len ); + if (status != HIDP_STATUS_SUCCESS) WARN( "HidP_SetUsages returned %#x\n", status ); + + spherical.rglDirection = directions; + convert_directions_to_spherical( &impl->params, &spherical ); + + if (!effect_update->direction_count) WARN( "no PID effect direction caps found\n" ); + else for (i = 0; i < spherical.cAxes - 1; ++i) { - count = 1; - usage = PID_USAGE_DIRECTION_ENABLE; - status = HidP_SetUsages( HidP_Output, HID_USAGE_PAGE_PID, 0, &usage, &count, - impl->joystick->preparsed, impl->effect_update_buf, report_len ); - if (status != HIDP_STATUS_SUCCESS) WARN( "HidP_SetUsages returned %#x\n", status ); - - spherical.rglDirection = directions; - convert_directions_to_spherical( &impl->params, &spherical ); - - if (!effect_update->direction_count) WARN( "no PID effect direction caps found\n" ); - else for (i = 0; i < spherical.cAxes - 1; ++i) - { - tmp = directions[i] + (i == 0 ? 9000 : 0); - caps = effect_update->direction_caps[effect_update->direction_count - i - 1]; - set_parameter_value( impl, impl->effect_update_buf, caps, tmp % 36000 ); - } + tmp = directions[i] + (i == 0 ? 9000 : 0); + caps = effect_update->direction_caps[effect_update->direction_count - i - 1]; + set_parameter_value( impl, impl->effect_update_buf, caps, tmp % 36000 ); }
status = HidP_SetUsageValue( HidP_Output, HID_USAGE_PAGE_PID, 0, PID_USAGE_TRIGGER_BUTTON,
As we support up to 6 force feedback axes and directions, the number of condition should match.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 4fdf961a04d..c49e840f845 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -188,7 +188,7 @@ struct hid_joystick_effect LONG directions[6]; DICONSTANTFORCE constant_force; DIRAMPFORCE ramp_force; - DICONDITION condition[2]; + DICONDITION condition[6]; DIENVELOPE envelope; DIPERIODIC periodic; DIEFFECT params; @@ -1878,6 +1878,9 @@ static HRESULT WINAPI hid_joystick_effect_Initialize( IDirectInputEffect *iface, joystick->preparsed, impl->effect_update_buf, report_len ); if (status != HIDP_STATUS_SUCCESS) return DIERR_DEVICENOTREG;
+ impl->type_specific_buf[0][0] = 0; + impl->type_specific_buf[1][0] = 0; + switch (type) { case PID_USAGE_ET_SQUARE: @@ -1899,9 +1902,6 @@ static HRESULT WINAPI hid_joystick_effect_Initialize( IDirectInputEffect *iface, status = HidP_InitializeReportForID( HidP_Output, joystick->pid_set_condition.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_condition.id, joystick->preparsed, - impl->type_specific_buf[1], report_len ); - 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, @@ -1921,8 +1921,6 @@ static HRESULT WINAPI hid_joystick_effect_Initialize( IDirectInputEffect *iface, break; case PID_USAGE_ET_CUSTOM_FORCE_DATA: FIXME( "effect type %#x not implemented!\n", type ); - impl->type_specific_buf[0][0] = 0; - impl->type_specific_buf[1][0] = 0; break; }
@@ -2626,22 +2624,22 @@ static HRESULT WINAPI hid_joystick_effect_Download( IDirectInputEffect *iface ) case PID_USAGE_ET_DAMPER: case PID_USAGE_ET_INERTIA: case PID_USAGE_ET_FRICTION: - for (i = 0; i < min( 2, impl->params.cbTypeSpecificParams / sizeof(DICONDITION) ); ++i) + for (i = 0; i < impl->params.cbTypeSpecificParams / sizeof(DICONDITION); ++i) { - set_parameter_value( impl, impl->type_specific_buf[i], set_condition->center_point_offset_caps, + set_parameter_value( impl, impl->type_specific_buf[0], set_condition->center_point_offset_caps, impl->condition[i].lOffset ); - set_parameter_value( impl, impl->type_specific_buf[i], set_condition->positive_coefficient_caps, + set_parameter_value( impl, impl->type_specific_buf[0], set_condition->positive_coefficient_caps, impl->condition[i].lPositiveCoefficient ); - set_parameter_value( impl, impl->type_specific_buf[i], set_condition->negative_coefficient_caps, + set_parameter_value( impl, impl->type_specific_buf[0], set_condition->negative_coefficient_caps, impl->condition[i].lNegativeCoefficient ); - set_parameter_value( impl, impl->type_specific_buf[i], set_condition->positive_saturation_caps, + set_parameter_value( impl, impl->type_specific_buf[0], set_condition->positive_saturation_caps, impl->condition[i].dwPositiveSaturation ); - set_parameter_value( impl, impl->type_specific_buf[i], set_condition->negative_saturation_caps, + set_parameter_value( impl, impl->type_specific_buf[0], set_condition->negative_saturation_caps, impl->condition[i].dwNegativeSaturation ); - set_parameter_value( impl, impl->type_specific_buf[i], set_condition->dead_band_caps, + set_parameter_value( impl, impl->type_specific_buf[0], set_condition->dead_band_caps, impl->condition[i].lDeadBand );
- if (WriteFile( device, impl->type_specific_buf[i], report_len, NULL, NULL )) hr = DI_OK; + if (WriteFile( device, impl->type_specific_buf[0], report_len, NULL, NULL )) hr = DI_OK; else hr = DIERR_INPUTLOST; } break;
From: Ivo Ivanov logos128@gmail.com
Signed-off-by: Ivo Ivanov logos128@gmail.com Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index c49e840f845..500ae05d481 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -2581,6 +2581,11 @@ static HRESULT WINAPI hid_joystick_effect_Download( IDirectInputEffect *iface ) impl->index, impl->joystick->preparsed, impl->type_specific_buf[0], report_len ); if (status != HIDP_STATUS_SUCCESS) WARN( "HidP_SetUsageValue returned %#x\n", status );
+ if (!impl->type_specific_buf[1][0]) status = HIDP_STATUS_SUCCESS; + else status = HidP_SetUsageValue( HidP_Output, HID_USAGE_PAGE_PID, 0, PID_USAGE_EFFECT_BLOCK_INDEX, + impl->index, impl->joystick->preparsed, impl->type_specific_buf[1], report_len ); + if (status != HIDP_STATUS_SUCCESS) WARN( "HidP_SetUsageValue returned %#x\n", status ); + status = HidP_SetUsageValue( HidP_Output, HID_USAGE_PAGE_PID, 0, PID_USAGE_EFFECT_BLOCK_INDEX, impl->index, impl->joystick->preparsed, impl->effect_update_buf, report_len ); if (status != HIDP_STATUS_SUCCESS) hr = status;
Instead of a generic type_specific_buf[1], and factor code for all effects that use an envelope.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 134 ++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 70 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 500ae05d481..efb90b4e2e9 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -197,7 +197,8 @@ struct hid_joystick_effect
char *effect_control_buf; char *effect_update_buf; - char *type_specific_buf[2]; + char *type_specific_buf; + char *set_envelope_buf; };
static inline struct hid_joystick_effect *impl_from_IDirectInputEffect( IDirectInputEffect *iface ) @@ -1850,8 +1851,8 @@ static ULONG WINAPI hid_joystick_effect_Release( IDirectInputEffect *iface ) list_remove( &impl->entry ); LeaveCriticalSection( &impl->joystick->base.crit ); hid_joystick_release( &impl->joystick->base.IDirectInputDevice8W_iface ); - free( impl->type_specific_buf[1] ); - free( impl->type_specific_buf[0] ); + free( impl->set_envelope_buf ); + free( impl->type_specific_buf ); free( impl->effect_update_buf ); free( impl->effect_control_buf ); free( impl ); @@ -1878,8 +1879,8 @@ static HRESULT WINAPI hid_joystick_effect_Initialize( IDirectInputEffect *iface, joystick->preparsed, impl->effect_update_buf, report_len ); if (status != HIDP_STATUS_SUCCESS) return DIERR_DEVICENOTREG;
- impl->type_specific_buf[0][0] = 0; - impl->type_specific_buf[1][0] = 0; + impl->type_specific_buf[0] = 0; + impl->set_envelope_buf[0] = 0;
switch (type) { @@ -1889,10 +1890,7 @@ static HRESULT WINAPI hid_joystick_effect_Initialize( IDirectInputEffect *iface, case PID_USAGE_ET_SAWTOOTH_UP: case PID_USAGE_ET_SAWTOOTH_DOWN: status = HidP_InitializeReportForID( HidP_Output, joystick->pid_set_periodic.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 ); + joystick->preparsed, impl->type_specific_buf, report_len ); if (status != HIDP_STATUS_SUCCESS) return DIERR_DEVICENOTREG; break; case PID_USAGE_ET_SPRING: @@ -1900,23 +1898,17 @@ static HRESULT WINAPI hid_joystick_effect_Initialize( IDirectInputEffect *iface, case PID_USAGE_ET_INERTIA: case PID_USAGE_ET_FRICTION: status = HidP_InitializeReportForID( HidP_Output, joystick->pid_set_condition.id, joystick->preparsed, - impl->type_specific_buf[0], report_len ); + impl->type_specific_buf, report_len ); 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 ); + impl->type_specific_buf, report_len ); if (status != HIDP_STATUS_SUCCESS) return DIERR_DEVICENOTREG; break; case PID_USAGE_ET_RAMP: status = HidP_InitializeReportForID( HidP_Output, joystick->pid_set_ramp_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 ); + impl->type_specific_buf, report_len ); if (status != HIDP_STATUS_SUCCESS) return DIERR_DEVICENOTREG; break; case PID_USAGE_ET_CUSTOM_FORCE_DATA: @@ -1924,6 +1916,21 @@ static HRESULT WINAPI hid_joystick_effect_Initialize( IDirectInputEffect *iface, break; }
+ switch (type) + { + case PID_USAGE_ET_SQUARE: + case PID_USAGE_ET_SINE: + case PID_USAGE_ET_TRIANGLE: + case PID_USAGE_ET_SAWTOOTH_UP: + case PID_USAGE_ET_SAWTOOTH_DOWN: + case PID_USAGE_ET_CONSTANT_FORCE: + case PID_USAGE_ET_RAMP: + status = HidP_InitializeReportForID( HidP_Output, joystick->pid_set_envelope.id, joystick->preparsed, + impl->set_envelope_buf, report_len ); + if (status != HIDP_STATUS_SUCCESS) return DIERR_DEVICENOTREG; + break; + } + count = 1; status = HidP_SetUsages( HidP_Output, HID_USAGE_PAGE_PID, joystick->pid_effect_update.type_coll, &type, &count, joystick->preparsed, impl->effect_update_buf, report_len ); @@ -2576,14 +2583,14 @@ static HRESULT WINAPI hid_joystick_effect_Download( IDirectInputEffect *iface ) hr = DIERR_INCOMPLETEEFFECT; else if (!impl->index && SUCCEEDED(hr = find_next_effect_id( impl->joystick, &impl->index ))) { - if (!impl->type_specific_buf[0][0]) status = HIDP_STATUS_SUCCESS; + if (!impl->type_specific_buf[0]) status = HIDP_STATUS_SUCCESS; else status = HidP_SetUsageValue( HidP_Output, HID_USAGE_PAGE_PID, 0, PID_USAGE_EFFECT_BLOCK_INDEX, - impl->index, impl->joystick->preparsed, impl->type_specific_buf[0], report_len ); + impl->index, impl->joystick->preparsed, impl->type_specific_buf, report_len ); if (status != HIDP_STATUS_SUCCESS) WARN( "HidP_SetUsageValue returned %#x\n", status );
- if (!impl->type_specific_buf[1][0]) status = HIDP_STATUS_SUCCESS; + if (!impl->set_envelope_buf[0]) status = HIDP_STATUS_SUCCESS; else status = HidP_SetUsageValue( HidP_Output, HID_USAGE_PAGE_PID, 0, PID_USAGE_EFFECT_BLOCK_INDEX, - impl->index, impl->joystick->preparsed, impl->type_specific_buf[1], report_len ); + impl->index, impl->joystick->preparsed, impl->set_envelope_buf, report_len ); if (status != HIDP_STATUS_SUCCESS) WARN( "HidP_SetUsageValue returned %#x\n", status );
status = HidP_SetUsageValue( HidP_Output, HID_USAGE_PAGE_PID, 0, PID_USAGE_EFFECT_BLOCK_INDEX, @@ -2601,28 +2608,16 @@ static HRESULT WINAPI hid_joystick_effect_Download( IDirectInputEffect *iface ) case PID_USAGE_ET_TRIANGLE: case PID_USAGE_ET_SAWTOOTH_UP: case PID_USAGE_ET_SAWTOOTH_DOWN: - set_parameter_value( impl, impl->type_specific_buf[0], set_periodic->magnitude_caps, + set_parameter_value( impl, impl->type_specific_buf, set_periodic->magnitude_caps, impl->periodic.dwMagnitude ); - set_parameter_value_us( impl, impl->type_specific_buf[0], set_periodic->period_caps, + set_parameter_value_us( impl, impl->type_specific_buf, set_periodic->period_caps, impl->periodic.dwPeriod ); - set_parameter_value( impl, impl->type_specific_buf[0], set_periodic->phase_caps, + set_parameter_value( impl, impl->type_specific_buf, set_periodic->phase_caps, impl->periodic.dwPhase ); - set_parameter_value( impl, impl->type_specific_buf[0], set_periodic->offset_caps, + set_parameter_value( impl, impl->type_specific_buf, set_periodic->offset_caps, impl->periodic.lOffset );
- 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; + if (WriteFile( device, impl->type_specific_buf, report_len, NULL, NULL )) hr = DI_OK; else hr = DIERR_INPUTLOST; break; case PID_USAGE_ET_SPRING: @@ -2631,61 +2626,60 @@ static HRESULT WINAPI hid_joystick_effect_Download( IDirectInputEffect *iface ) case PID_USAGE_ET_FRICTION: for (i = 0; i < impl->params.cbTypeSpecificParams / sizeof(DICONDITION); ++i) { - set_parameter_value( impl, impl->type_specific_buf[0], set_condition->center_point_offset_caps, + set_parameter_value( impl, impl->type_specific_buf, set_condition->center_point_offset_caps, impl->condition[i].lOffset ); - set_parameter_value( impl, impl->type_specific_buf[0], set_condition->positive_coefficient_caps, + set_parameter_value( impl, impl->type_specific_buf, set_condition->positive_coefficient_caps, impl->condition[i].lPositiveCoefficient ); - set_parameter_value( impl, impl->type_specific_buf[0], set_condition->negative_coefficient_caps, + set_parameter_value( impl, impl->type_specific_buf, set_condition->negative_coefficient_caps, impl->condition[i].lNegativeCoefficient ); - set_parameter_value( impl, impl->type_specific_buf[0], set_condition->positive_saturation_caps, + set_parameter_value( impl, impl->type_specific_buf, set_condition->positive_saturation_caps, impl->condition[i].dwPositiveSaturation ); - set_parameter_value( impl, impl->type_specific_buf[0], set_condition->negative_saturation_caps, + set_parameter_value( impl, impl->type_specific_buf, set_condition->negative_saturation_caps, impl->condition[i].dwNegativeSaturation ); - set_parameter_value( impl, impl->type_specific_buf[0], set_condition->dead_band_caps, + set_parameter_value( impl, impl->type_specific_buf, set_condition->dead_band_caps, impl->condition[i].lDeadBand );
- if (WriteFile( device, impl->type_specific_buf[0], report_len, NULL, NULL )) hr = DI_OK; + if (WriteFile( device, impl->type_specific_buf, report_len, NULL, NULL )) hr = DI_OK; 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, + set_parameter_value( impl, impl->type_specific_buf, 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; + if (WriteFile( device, impl->type_specific_buf, report_len, NULL, NULL )) hr = DI_OK; else hr = DIERR_INPUTLOST; break; case PID_USAGE_ET_RAMP: - set_parameter_value( impl, impl->type_specific_buf[0], set_ramp_force->start_caps, + set_parameter_value( impl, impl->type_specific_buf, set_ramp_force->start_caps, impl->ramp_force.lStart ); - set_parameter_value( impl, impl->type_specific_buf[0], set_ramp_force->end_caps, + set_parameter_value( impl, impl->type_specific_buf, set_ramp_force->end_caps, impl->ramp_force.lEnd );
- if (WriteFile( device, impl->type_specific_buf[0], report_len, NULL, NULL )) hr = DI_OK; + if (WriteFile( device, impl->type_specific_buf, report_len, NULL, NULL )) hr = DI_OK; else hr = DIERR_INPUTLOST; + break; + }
- set_parameter_value( impl, impl->type_specific_buf[1], set_envelope->attack_level_caps, + switch (impl->type) + { + case PID_USAGE_ET_SQUARE: + case PID_USAGE_ET_SINE: + case PID_USAGE_ET_TRIANGLE: + case PID_USAGE_ET_SAWTOOTH_UP: + case PID_USAGE_ET_SAWTOOTH_DOWN: + case PID_USAGE_ET_CONSTANT_FORCE: + case PID_USAGE_ET_RAMP: + set_parameter_value( impl, impl->set_envelope_buf, set_envelope->attack_level_caps, impl->envelope.dwAttackLevel ); - set_parameter_value_us( impl, impl->type_specific_buf[1], set_envelope->attack_time_caps, + set_parameter_value_us( impl, impl->set_envelope_buf, set_envelope->attack_time_caps, impl->envelope.dwAttackTime ); - set_parameter_value( impl, impl->type_specific_buf[1], set_envelope->fade_level_caps, + set_parameter_value( impl, impl->set_envelope_buf, set_envelope->fade_level_caps, impl->envelope.dwFadeLevel ); - set_parameter_value_us( impl, impl->type_specific_buf[1], set_envelope->fade_time_caps, + set_parameter_value_us( impl, impl->set_envelope_buf, set_envelope->fade_time_caps, impl->envelope.dwFadeTime );
- if (WriteFile( device, impl->type_specific_buf[1], report_len, NULL, NULL )) hr = DI_OK; + if (WriteFile( device, impl->set_envelope_buf, report_len, NULL, NULL )) hr = DI_OK; else hr = DIERR_INPUTLOST; break; } @@ -2798,8 +2792,8 @@ static HRESULT hid_joystick_create_effect( IDirectInputDevice8W *iface, IDirectI report_len = joystick->caps.OutputReportByteLength; if (!(impl->effect_control_buf = malloc( report_len ))) goto failed; if (!(impl->effect_update_buf = malloc( report_len ))) goto failed; - if (!(impl->type_specific_buf[0] = malloc( report_len ))) goto failed; - if (!(impl->type_specific_buf[1] = malloc( report_len ))) goto failed; + if (!(impl->type_specific_buf = malloc( report_len ))) goto failed; + if (!(impl->set_envelope_buf = malloc( report_len ))) goto failed;
impl->envelope.dwSize = sizeof(DIENVELOPE); impl->params.dwSize = sizeof(DIEFFECT);
From: Ivo Ivanov logos128@gmail.com
Instead of then number of WCHAR.
Signed-off-by: Ivo Ivanov logos128@gmail.com Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index efb90b4e2e9..a5fbfb81332 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -1239,8 +1239,8 @@ static BOOL hid_joystick_device_try_open( UINT32 handle, const WCHAR *path, HAND if (caps->UsagePage != HID_USAGE_PAGE_GENERIC) goto failed; if (caps->Usage != HID_USAGE_GENERIC_GAMEPAD && caps->Usage != HID_USAGE_GENERIC_JOYSTICK) goto failed;
- if (!HidD_GetProductString( device_file, instance->tszInstanceName, MAX_PATH )) goto failed; - if (!HidD_GetProductString( device_file, instance->tszProductName, MAX_PATH )) goto failed; + if (!HidD_GetProductString( device_file, instance->tszInstanceName, MAX_PATH * sizeof(WCHAR) )) goto failed; + if (!HidD_GetProductString( device_file, instance->tszProductName, MAX_PATH * sizeof(WCHAR) )) goto failed;
instance->guidInstance = hid_joystick_guid; instance->guidInstance.Data1 ^= handle;
From: Ivo Ivanov logos128@gmail.com
Fixes the device names appearing with the first words in joy.cpl and probably in games, when the UDEV bus is used in HIDRAW mode.
Signed-off-by: Ivo Ivanov logos128@gmail.com Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus_udev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index dad5344a54c..5ff1719848d 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -1121,13 +1121,13 @@ static void get_device_subsystem_info(struct udev_device *dev, char const *subsy if (!strncmp(ptr, "HID_UNIQ=", 9)) { if (desc->serialnumber[0]) continue; - if (sscanf(ptr, "HID_UNIQ=%256s\n", buffer) == 1) + if (sscanf(ptr, "HID_UNIQ=%256[^\n]", buffer) == 1) ntdll_umbstowcs(buffer, strlen(buffer) + 1, desc->serialnumber, ARRAY_SIZE(desc->serialnumber)); } if (!strncmp(ptr, "HID_NAME=", 9)) { if (desc->product[0]) continue; - if (sscanf(ptr, "HID_NAME=%256s\n", buffer) == 1) + if (sscanf(ptr, "HID_NAME=%256[^\n]", buffer) == 1) ntdll_umbstowcs(buffer, strlen(buffer) + 1, desc->product, ARRAY_SIZE(desc->product)); } if (!strncmp(ptr, "HID_PHYS=", 9) || !strncmp(ptr, "PHYS="", 6))