From 95cc64aa731d9babfba677d6dca97d13efebd476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Thu, 23 Sep 2021 14:01:53 +0200 Subject: [PATCH] joy.cpl: Refresh joystick test device list when activated. 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 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/dlls/joy.cpl/main.c b/dlls/joy.cpl/main.c index ef905c65a93..3dee30a4b5b 100644 --- a/dlls/joy.cpl/main.c +++ b/dlls/joy.cpl/main.c @@ -533,6 +533,14 @@ static void draw_joystick_axes(HWND hwnd, struct JoystickData* data) * test_dlgproc [internal] * */ +static void refresh_test_joystick_list(HWND hwnd, struct JoystickData *data) +{ + struct Joystick *joy, *joy_end; + SendDlgItemMessageW(hwnd, IDC_TESTSELECTCOMBO, CB_RESETCONTENT, 0, 0); + for (joy = data->joysticks, joy_end = joy + data->num_joysticks; joy != joy_end; ++joy) + SendDlgItemMessageW(hwnd, IDC_TESTSELECTCOMBO, CB_ADDSTRING, 0, (LPARAM)joy->instance.tszInstanceName); +} + static INT_PTR CALLBACK test_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { static HANDLE thread; @@ -543,17 +551,9 @@ static INT_PTR CALLBACK test_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM { case WM_INITDIALOG: { - int i; - data = (struct JoystickData*) ((PROPSHEETPAGEW*)lparam)->lParam; - /* Add enumerated joysticks to the combobox */ - for (i = 0; i < data->num_joysticks; i++) - { - struct Joystick *joy = &data->joysticks[i]; - SendDlgItemMessageW(hwnd, IDC_TESTSELECTCOMBO, CB_ADDSTRING, 0, (LPARAM) joy->instance.tszInstanceName); - } - + refresh_test_joystick_list(hwnd, data); draw_joystick_buttons(hwnd, data); draw_joystick_axes(hwnd, data); @@ -576,6 +576,8 @@ static INT_PTR CALLBACK test_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM { DWORD tid; + refresh_test_joystick_list(hwnd, data); + /* Initialize input thread */ if (data->num_joysticks > 0) {