joy.cpl: Correct joystick testing thread behavior

Lucas Zawacki lfzawacki at gmail.com
Wed Jul 11 13:43:44 CDT 2012


From: Lucas Zawacki <lfzawacki at gmail.com>

---
 dlls/joy.cpl/main.c |   17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/dlls/joy.cpl/main.c b/dlls/joy.cpl/main.c
index eb8f982..3aaf8af 100644
--- a/dlls/joy.cpl/main.c
+++ b/dlls/joy.cpl/main.c
@@ -378,6 +378,7 @@ static INT_PTR CALLBACK test_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
         case WM_INITDIALOG:
         {
             int i;
+            DWORD tid;
 
             data = (struct JoystickData*) ((PROPSHEETPAGEW*)lparam)->lParam;
 
@@ -391,6 +392,10 @@ static INT_PTR CALLBACK test_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
             draw_joystick_buttons(hwnd, data);
             draw_joystick_axes(hwnd, data);
 
+            /* Initialize input thread in suspended state */
+            thread = CreateThread(NULL, 0, input_thread, (void*) data, 0, &tid);
+            SuspendThread(thread);
+
             return TRUE;
         }
 
@@ -408,9 +413,6 @@ static INT_PTR CALLBACK test_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
             {
                 case PSN_SETACTIVE:
                 {
-                    DWORD tid;
-
-                    /* Initialize input thread */
                     if (data->num_joysticks > 0)
                     {
                         data->stop = FALSE;
@@ -419,14 +421,19 @@ static INT_PTR CALLBACK test_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
                         SendDlgItemMessageW(hwnd, IDC_TESTSELECTCOMBO, CB_SETCURSEL, 0, 0);
                         test_handle_joychange(hwnd, data);
 
-                        thread = CreateThread(NULL, 0, input_thread, (void*) data, 0, &tid);
+                        ResumeThread(thread);
                     }
                 }
                 break;
 
+                case PSN_KILLACTIVE:
+                    SuspendThread(thread);
+                break;
+
                 case PSN_RESET:
-                    /* Stop input thread */
+                    /* Stop input thread and wait a little */
                     data->stop = TRUE;
+                    WaitForSingleObject(thread, TEST_POLL_TIME);
                     CloseHandle(thread);
                 break;
             }
-- 
1.7.9.5




More information about the wine-patches mailing list