From 5fad09d24653bd19a0113734d147087c9bcb59ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Thu, 23 Sep 2021 14:01:52 +0200 Subject: [PATCH] joy.cpl: Enumerate force-feedback effects with the devices. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: RĂ©mi Bernon Signed-off-by: Alexandre Julliard --- dlls/joy.cpl/main.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/dlls/joy.cpl/main.c b/dlls/joy.cpl/main.c index 43e124a0a33..ef905c65a93 100644 --- a/dlls/joy.cpl/main.c +++ b/dlls/joy.cpl/main.c @@ -60,6 +60,7 @@ BOOL WINAPI DllMain(HINSTANCE hdll, DWORD reason, LPVOID reserved) * First time it checks if space for the joysticks was already reserved * and if not, just counts how many there are. */ +static BOOL CALLBACK ff_effects_callback(const DIEFFECTINFOW *pdei, void *pvRef); static BOOL CALLBACK enum_callback(const DIDEVICEINSTANCEW *instance, void *context) { struct JoystickData *data = context; @@ -101,6 +102,18 @@ static BOOL CALLBACK enum_callback(const DIDEVICEINSTANCEW *instance, void *cont IDirectInputDevice_SetProperty(joystick->device, DIPROP_RANGE, &proprange.diph); + if (!joystick->forcefeedback) return DIENUM_CONTINUE; + + /* Count device effects and then store them */ + joystick->num_effects = 0; + joystick->effects = NULL; + IDirectInputDevice8_EnumEffects(joystick->device, ff_effects_callback, (void *)joystick, 0); + joystick->effects = malloc(sizeof(struct Effect) * joystick->num_effects); + + joystick->cur_effect = 0; + IDirectInputDevice8_EnumEffects(joystick->device, ff_effects_callback, (void*)joystick, 0); + joystick->num_effects = joystick->cur_effect; + return DIENUM_CONTINUE; } @@ -818,16 +831,6 @@ static INT_PTR CALLBACK ff_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp SendDlgItemMessageW(hwnd, IDC_FFSELECTCOMBO, CB_SETITEMDATA, cur, i); cur++; - - /* Count device effects and then store them */ - joy->num_effects = 0; - joy->effects = NULL; - IDirectInputDevice8_EnumEffects(joy->device, ff_effects_callback, (void *) joy, 0); - joy->effects = malloc(sizeof(struct Effect) * joy->num_effects); - - joy->cur_effect = 0; - IDirectInputDevice8_EnumEffects(joy->device, ff_effects_callback, (void*) joy, 0); - joy->num_effects = joy->cur_effect; } }