winmm/tests: Add a basic joystick interactive test (try 2)

Bruno Jesus 00cpxxx at gmail.com
Sun Mar 22 09:51:12 CDT 2015


Use the Ex function and display all information possible, superseeds
110128. Sample output:

joystick.c:213: X: 33288, Y: 29695, Z: 32511, POV:     0
joystick.c:215: R: 30207, U:     0, V:     0
joystick.c:217: BUTTONS: 0x0000, BUTTON_COUNT:  0, REMAINING: 2250 ms

joystick.c:213: X: 33288, Y: 31231, Z: 34068, POV:     0
joystick.c:215: R: 30463, U:     0, V:     0
joystick.c:217: BUTTONS: 0x0004, BUTTON_COUNT:  1, REMAINING: 1688 ms

joystick.c:213: X: 32511, Y: 30719, Z: 33028, POV:     0
joystick.c:215: R: 27647, U:     0, V:     0
joystick.c:217: BUTTONS: 0x0006, BUTTON_COUNT:  2, REMAINING: 1110 ms

joystick.c:213: X: 32767, Y: 29695, Z: 32767, POV:     0
joystick.c:215: R: 26111, U:     0, V:     0
joystick.c:217: BUTTONS: 0x0306, BUTTON_COUNT:  4, REMAINING: 531 ms
-------------- next part --------------
diff --git a/dlls/winmm/tests/joystick.c b/dlls/winmm/tests/joystick.c
index 21e90e3..358476a 100644
--- a/dlls/winmm/tests/joystick.c
+++ b/dlls/winmm/tests/joystick.c
@@ -195,6 +195,35 @@ static void test_api(void)
         ret = joyGetPosEx(joyid, &infoex.ex);
         ok(ret == JOYERR_NOERROR, "Expected %d, got %d\n", JOYERR_NOERROR, ret);
     }
+
+    /* the interactive tests spans for 15 seconds, a 500ms polling is used to get
+     * changes in the joystick. */
+    if (winetest_interactive)
+    {
+        #define MAX_TIME 15000
+        DWORD tick = GetTickCount(), spent;
+        infoex.ex.dwSize = sizeof(infoex.ex);
+        infoex.ex.dwFlags = JOY_RETURNALL;
+        do
+        {
+            spent = GetTickCount() - tick;
+            ret = joyGetPosEx(joyid, &infoex.ex);
+            if (ret == JOYERR_NOERROR)
+            {
+                trace("X: %5d, Y: %5d, Z: %5d, POV: %5d\n",
+                       infoex.ex.dwXpos, infoex.ex.dwYpos, infoex.ex.dwZpos, infoex.ex.dwPOV); 
+                trace("R: %5d, U: %5d, V: %5d\n",
+                       infoex.ex.dwRpos, infoex.ex.dwUpos, infoex.ex.dwVpos);
+                trace("BUTTONS: 0x%04X, BUTTON_COUNT: %2d, REMAINING: %d ms\n\n",
+                       infoex.ex.dwButtons, infoex.ex.dwButtonNumber, MAX_TIME - spent);
+            }
+            Sleep(500);
+        }
+        while (spent < MAX_TIME);
+        #undef MAX_TIME
+    }
+    else
+        skip("Skipping interactive tests for the joystick\n");
 }
 
 START_TEST(joystick)


More information about the wine-patches mailing list