Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/xinput1_3/main.c | 96 ++++++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 42 deletions(-)
diff --git a/dlls/xinput1_3/main.c b/dlls/xinput1_3/main.c index 0e5bd7283c4..c8ce6622dcb 100644 --- a/dlls/xinput1_3/main.c +++ b/dlls/xinput1_3/main.c @@ -286,11 +286,14 @@ static DWORD HID_set_state(struct xinput_controller *controller, XINPUT_VIBRATIO PHIDP_PREPARSED_DATA preparsed = controller->hid.preparsed; char *report_buf = controller->hid.output_report_buf; BYTE report_id = controller->hid.haptics_report; + BOOL update_rumble, update_buzz; NTSTATUS status;
if (!(controller->caps.Flags & XINPUT_CAPS_FFB_SUPPORTED)) return ERROR_SUCCESS;
+ update_rumble = (controller->vibration.wLeftMotorSpeed != state->wLeftMotorSpeed); controller->vibration.wLeftMotorSpeed = state->wLeftMotorSpeed; + update_buzz = (controller->vibration.wRightMotorSpeed != state->wRightMotorSpeed); controller->vibration.wRightMotorSpeed = state->wRightMotorSpeed;
if (!controller->enabled) return ERROR_SUCCESS; @@ -311,55 +314,64 @@ static DWORD HID_set_state(struct xinput_controller *controller, XINPUT_VIBRATIO return 0; }
- /* send haptics rumble report (left motor) */ - status = HidP_InitializeReportForID(HidP_Output, report_id, preparsed, report_buf, report_len); - if (status != HIDP_STATUS_SUCCESS) WARN("HidP_InitializeReportForID returned %#lx\n", status); - status = HidP_SetUsageValue(HidP_Output, HID_USAGE_PAGE_HAPTICS, 0, HID_USAGE_HAPTICS_INTENSITY, - state->wLeftMotorSpeed, preparsed, report_buf, report_len); - if (status != HIDP_STATUS_SUCCESS) WARN("HidP_SetUsageValue INTENSITY returned %#lx\n", status); - status = HidP_SetUsageValue(HidP_Output, HID_USAGE_PAGE_HAPTICS, 0, HID_USAGE_HAPTICS_MANUAL_TRIGGER, - controller->hid.haptics_rumble_ordinal, preparsed, report_buf, report_len); - if (status != HIDP_STATUS_SUCCESS) WARN("HidP_SetUsageValue MANUAL_TRIGGER returned %#lx\n", status); - status = HidP_SetUsageValue(HidP_Output, HID_USAGE_PAGE_HAPTICS, 0, HID_USAGE_HAPTICS_REPEAT_COUNT, - 0, preparsed, report_buf, report_len); - if (status != HIDP_STATUS_SUCCESS) WARN("HidP_SetUsageValue REPEAT_COUNT returned %#lx\n", status); - if (!HidD_SetOutputReport(controller->device, report_buf, report_len)) + if (update_rumble) { - WARN("HidD_SetOutputReport failed with error %lu\n", GetLastError()); - return GetLastError(); + /* send haptics rumble report (left motor) */ + status = HidP_InitializeReportForID(HidP_Output, report_id, preparsed, report_buf, report_len); + if (status != HIDP_STATUS_SUCCESS) WARN("HidP_InitializeReportForID returned %#lx\n", status); + status = HidP_SetUsageValue(HidP_Output, HID_USAGE_PAGE_HAPTICS, 0, HID_USAGE_HAPTICS_INTENSITY, + state->wLeftMotorSpeed, preparsed, report_buf, report_len); + if (status != HIDP_STATUS_SUCCESS) WARN("HidP_SetUsageValue INTENSITY returned %#lx\n", status); + status = HidP_SetUsageValue(HidP_Output, HID_USAGE_PAGE_HAPTICS, 0, HID_USAGE_HAPTICS_MANUAL_TRIGGER, + controller->hid.haptics_rumble_ordinal, preparsed, report_buf, report_len); + if (status != HIDP_STATUS_SUCCESS) WARN("HidP_SetUsageValue MANUAL_TRIGGER returned %#lx\n", status); + status = HidP_SetUsageValue(HidP_Output, HID_USAGE_PAGE_HAPTICS, 0, HID_USAGE_HAPTICS_REPEAT_COUNT, + 0, preparsed, report_buf, report_len); + if (status != HIDP_STATUS_SUCCESS) WARN("HidP_SetUsageValue REPEAT_COUNT returned %#lx\n", status); + if (!HidD_SetOutputReport(controller->device, report_buf, report_len)) + { + WARN("HidD_SetOutputReport failed with error %lu\n", GetLastError()); + return GetLastError(); + } }
- /* send haptics buzz report (right motor) */ - status = HidP_InitializeReportForID(HidP_Output, report_id, preparsed, report_buf, report_len); - if (status != HIDP_STATUS_SUCCESS) WARN("HidP_InitializeReportForID returned %#lx\n", status); - status = HidP_SetUsageValue(HidP_Output, HID_USAGE_PAGE_HAPTICS, 0, HID_USAGE_HAPTICS_INTENSITY, - state->wRightMotorSpeed, preparsed, report_buf, report_len); - if (status != HIDP_STATUS_SUCCESS) WARN("HidP_SetUsageValue INTENSITY returned %#lx\n", status); - status = HidP_SetUsageValue(HidP_Output, HID_USAGE_PAGE_HAPTICS, 0, HID_USAGE_HAPTICS_MANUAL_TRIGGER, - controller->hid.haptics_buzz_ordinal, preparsed, report_buf, report_len); - if (status != HIDP_STATUS_SUCCESS) WARN("HidP_SetUsageValue MANUAL_TRIGGER returned %#lx\n", status); - status = HidP_SetUsageValue(HidP_Output, HID_USAGE_PAGE_HAPTICS, 0, HID_USAGE_HAPTICS_REPEAT_COUNT, - 0, preparsed, report_buf, report_len); - if (status != HIDP_STATUS_SUCCESS) WARN("HidP_SetUsageValue REPEAT_COUNT returned %#lx\n", status); - if (!HidD_SetOutputReport(controller->device, report_buf, report_len)) + if (update_buzz) { - WARN("HidD_SetOutputReport failed with error %lu\n", GetLastError()); - return GetLastError(); + /* send haptics buzz report (right motor) */ + status = HidP_InitializeReportForID(HidP_Output, report_id, preparsed, report_buf, report_len); + if (status != HIDP_STATUS_SUCCESS) WARN("HidP_InitializeReportForID returned %#lx\n", status); + status = HidP_SetUsageValue(HidP_Output, HID_USAGE_PAGE_HAPTICS, 0, HID_USAGE_HAPTICS_INTENSITY, + state->wRightMotorSpeed, preparsed, report_buf, report_len); + if (status != HIDP_STATUS_SUCCESS) WARN("HidP_SetUsageValue INTENSITY returned %#lx\n", status); + status = HidP_SetUsageValue(HidP_Output, HID_USAGE_PAGE_HAPTICS, 0, HID_USAGE_HAPTICS_MANUAL_TRIGGER, + controller->hid.haptics_buzz_ordinal, preparsed, report_buf, report_len); + if (status != HIDP_STATUS_SUCCESS) WARN("HidP_SetUsageValue MANUAL_TRIGGER returned %#lx\n", status); + status = HidP_SetUsageValue(HidP_Output, HID_USAGE_PAGE_HAPTICS, 0, HID_USAGE_HAPTICS_REPEAT_COUNT, + 0, preparsed, report_buf, report_len); + if (status != HIDP_STATUS_SUCCESS) WARN("HidP_SetUsageValue REPEAT_COUNT returned %#lx\n", status); + if (!HidD_SetOutputReport(controller->device, report_buf, report_len)) + { + WARN("HidD_SetOutputReport failed with error %lu\n", GetLastError()); + return GetLastError(); + } }
- /* trigger haptics waveforms */ - status = HidP_InitializeReportForID(HidP_Output, report_id, preparsed, report_buf, report_len); - if (status != HIDP_STATUS_SUCCESS) WARN("HidP_InitializeReportForID returned %#lx\n", status); - status = HidP_SetUsageValue(HidP_Output, HID_USAGE_PAGE_HAPTICS, 0, HID_USAGE_HAPTICS_MANUAL_TRIGGER, - controller->hid.haptics_none_ordinal, preparsed, report_buf, report_len); - if (status != HIDP_STATUS_SUCCESS) WARN("HidP_SetUsageValue MANUAL_TRIGGER returned %#lx\n", status); - status = HidP_SetUsageValue(HidP_Output, HID_USAGE_PAGE_HAPTICS, 0, HID_USAGE_HAPTICS_REPEAT_COUNT, - 1, preparsed, report_buf, report_len); - if (status != HIDP_STATUS_SUCCESS) WARN("HidP_SetUsageValue REPEAT_COUNT returned %#lx\n", status); - if (!HidD_SetOutputReport(controller->device, report_buf, report_len)) + if (update_rumble || update_buzz) { - WARN("HidD_SetOutputReport failed with error %lu\n", GetLastError()); - return GetLastError(); + /* trigger haptics waveforms */ + status = HidP_InitializeReportForID(HidP_Output, report_id, preparsed, report_buf, report_len); + if (status != HIDP_STATUS_SUCCESS) WARN("HidP_InitializeReportForID returned %#lx\n", status); + status = HidP_SetUsageValue(HidP_Output, HID_USAGE_PAGE_HAPTICS, 0, HID_USAGE_HAPTICS_MANUAL_TRIGGER, + controller->hid.haptics_none_ordinal, preparsed, report_buf, report_len); + if (status != HIDP_STATUS_SUCCESS) WARN("HidP_SetUsageValue MANUAL_TRIGGER returned %#lx\n", status); + status = HidP_SetUsageValue(HidP_Output, HID_USAGE_PAGE_HAPTICS, 0, HID_USAGE_HAPTICS_REPEAT_COUNT, + 1, preparsed, report_buf, report_len); + if (status != HIDP_STATUS_SUCCESS) WARN("HidP_SetUsageValue REPEAT_COUNT returned %#lx\n", status); + if (!HidD_SetOutputReport(controller->device, report_buf, report_len)) + { + WARN("HidD_SetOutputReport failed with error %lu\n", GetLastError()); + return GetLastError(); + } }
return ERROR_SUCCESS;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus_sdl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index 93ba58ec9d6..c80b7ce324a 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -400,8 +400,8 @@ static void sdl_device_stop(struct unix_device *iface) pthread_mutex_unlock(&sdl_cs); }
-NTSTATUS sdl_device_haptics_start(struct unix_device *iface, UINT duration_ms, - USHORT rumble_intensity, USHORT buzz_intensity) +static NTSTATUS sdl_device_haptics_start(struct unix_device *iface, UINT duration_ms, + USHORT rumble_intensity, USHORT buzz_intensity) { struct sdl_device *impl = impl_from_unix_device(iface); SDL_HapticEffect effect; @@ -439,7 +439,7 @@ NTSTATUS sdl_device_haptics_start(struct unix_device *iface, UINT duration_ms, return STATUS_SUCCESS; }
-NTSTATUS sdl_device_haptics_stop(struct unix_device *iface) +static NTSTATUS sdl_device_haptics_stop(struct unix_device *iface) { struct sdl_device *impl = impl_from_unix_device(iface);
So that an open failure will not decrement it to -1.
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 b9542d37f9b..47670ebd732 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -2013,12 +2013,12 @@ HRESULT hid_joystick_create_device( struct dinput *dinput, const GUID *guid, IDi impl->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": hid_joystick.base.crit"); impl->base.dwCoopLevel = DISCL_NONEXCLUSIVE | DISCL_BACKGROUND; impl->base.read_event = CreateEventW( NULL, TRUE, FALSE, NULL ); + impl->internal_ref = 1;
hr = hid_joystick_device_open( -1, &instance, impl->device_path, &impl->device, &impl->preparsed, &attrs, &impl->caps, dinput->dwVersion ); if (hr != DI_OK) goto failed;
- impl->internal_ref = 1; impl->base.instance = instance; impl->base.caps.dwDevType = instance.dwDevType; impl->attrs = attrs;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 47670ebd732..e35ca699126 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -1577,11 +1577,9 @@ static HRESULT hid_joystick_device_open( int index, DIDEVICEINSTANCEW *filter, W if (device_instance_is_disabled( &instance, &override )) goto next;
- if (override) + if (override && SetupDiGetDeviceInstanceIdW( set, &devinfo, device_id, MAX_PATH, NULL ) && + (tmp = wcsstr( device_id, L"&IG_" ))) { - if (!SetupDiGetDeviceInstanceIdW( set, &devinfo, device_id, MAX_PATH, NULL ) || - !(tmp = wcsstr( device_id, L"&IG_" ))) - goto next; memcpy( tmp, L"&XI_", sizeof(L"&XI_") - sizeof(WCHAR) ); if (!SetupDiOpenDeviceInfoW( xi_set, device_id, NULL, 0, &devinfo )) goto next;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index e35ca699126..68db935c44a 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -985,7 +985,7 @@ static HRESULT hid_joystick_get_effect_info( IDirectInputDevice8W *iface, DIEFFE } }
- if ((type & DIEFT_PERIODIC) && (collection = set_periodic->collection)) + if ((DIEFT_GETTYPE(type) == DIEFT_PERIODIC) && (collection = set_periodic->collection)) { if (set_periodic->magnitude_caps) info->dwDynamicParams |= DIEP_TYPESPECIFICPARAMS; if (set_periodic->offset_caps) info->dwDynamicParams |= DIEP_TYPESPECIFICPARAMS; @@ -993,7 +993,10 @@ static HRESULT hid_joystick_get_effect_info( IDirectInputDevice8W *iface, DIEFFE if (set_periodic->phase_caps) info->dwDynamicParams |= DIEP_TYPESPECIFICPARAMS; }
- if ((type & (DIEFT_PERIODIC | DIEFT_RAMPFORCE | DIEFT_CONSTANTFORCE)) && (collection = set_envelope->collection)) + if ((DIEFT_GETTYPE(type) == DIEFT_PERIODIC || + DIEFT_GETTYPE(type) == DIEFT_RAMPFORCE || + DIEFT_GETTYPE(type) == DIEFT_CONSTANTFORCE) && + (collection = set_envelope->collection)) { info->dwDynamicParams |= DIEP_ENVELOPE; if (set_envelope->attack_level_caps) type |= DIEFT_FFATTACK; @@ -1004,7 +1007,7 @@ static HRESULT hid_joystick_get_effect_info( IDirectInputDevice8W *iface, DIEFFE if (effect_update->trigger_repeat_interval_caps) info->dwDynamicParams |= DIEP_TRIGGERREPEATINTERVAL; }
- if ((type & DIEFT_CONDITION) && (collection = set_condition->collection)) + if (DIEFT_GETTYPE(type) == DIEFT_CONDITION && (collection = set_condition->collection)) { if (set_condition->center_point_offset_caps) info->dwDynamicParams |= DIEP_TYPESPECIFICPARAMS;