From: Tyson Whitehead twhitehead@gmail.com
--- dlls/joy.cpl/dinput.c | 28 ++++++++++++++++++++++++++-- dlls/joy.cpl/joy.rc | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/dlls/joy.cpl/dinput.c b/dlls/joy.cpl/dinput.c index 8f172879e46..f6cd7f5c44e 100644 --- a/dlls/joy.cpl/dinput.c +++ b/dlls/joy.cpl/dinput.c @@ -77,7 +77,7 @@ static BOOL CALLBACK enum_effects( const DIEFFECTINFOW *info, void *context ) { .dwSize = sizeof(DIEFFECT), .dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS, - .dwDuration = 2 * DI_SECONDS, + .dwDuration = INFINITE, .dwGain = DI_FFNOMINALMAX, .rglDirection = direction, .rgdwAxes = axes, @@ -112,6 +112,7 @@ static BOOL CALLBACK enum_effects( const DIEFFECTINFOW *info, void *context ) if (IsEqualGUID( &info->guid, &GUID_RampForce )) { params.cbTypeSpecificParams = sizeof(ramp); + params.dwDuration = 2 * DI_SECONDS; params.lpvTypeSpecificParams = &ramp; } else if (IsEqualGUID( &info->guid, &GUID_ConstantForce )) @@ -267,6 +268,7 @@ static void clear_devices(void) static DWORD WINAPI input_thread( void *param ) { HANDLE events[2] = {param, state_event}; + IDirectInputEffect *playing = NULL;
while (WaitForMultipleObjects( 2, events, FALSE, INFINITE ) != 0) { @@ -289,16 +291,38 @@ static DWORD WINAPI input_thread( void *param ) .cAxes = 2, };
- if (pressed) + if (playing && (!pressed || playing != effect)) + { + IDirectInputEffect_Stop( playing ); + IDirectInputEffect_Release( playing ); + playing = NULL; + } + + if (pressed && !playing) { do hr = IDirectInputEffect_SetParameters( effect, ¶ms, DIEP_DIRECTION | DIEP_NORESTART ); while (FAILED(hr) && --params.cAxes);
IDirectInputEffect_Start( effect, 1, 0 ); + IDirectInputEffect_AddRef( effect ); + playing = effect; }
IDirectInputEffect_Release( effect ); } + else if (playing) + { + IDirectInputEffect_Stop( playing ); + IDirectInputEffect_Release( playing ); + playing = NULL; + } + } + + if (playing) + { + IDirectInputEffect_Stop( playing ); + IDirectInputEffect_Release( playing ); + playing = NULL; }
return 0; diff --git a/dlls/joy.cpl/joy.rc b/dlls/joy.cpl/joy.rc index 1eb62d86ab3..c98bbe886c4 100644 --- a/dlls/joy.cpl/joy.rc +++ b/dlls/joy.cpl/joy.rc @@ -63,7 +63,7 @@ FONT 8, "Ms Shell Dlg" GROUPBOX "Buttons", IDC_DI_BUTTONS, 15, 100, 291, 86 LTEXT "Force Feedback Effect", IDC_STATIC, 15, 196, 291, 10 LISTBOX IDC_DI_EFFECTS, 15, 206, 291, 54, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY - LTEXT "Press any button in the controller to activate the chosen effect. The effect direction can be changed with the controller axis.", + LTEXT "Hold any button in the controller to play the chosen effect. The effect direction can be changed with the controller axis.", IDC_STATIC, 15, 260, 291, 25 }