added glutGetProcAddress() and GLUT_FPS env var option
[mesa.git] / src / glut / glx / glut_input.c
index eea96349eaf3b9fc7ce5a0b2373e16bdb022dd8c..6f6f41f1d6597e4427944cab4f69cc0709a05bff 100644 (file)
@@ -5,6 +5,10 @@
    and is provided without guarantee or warrantee expressed or
    implied. This program is -not- in the public domain. */
 
+#ifdef __VMS
+#include <GL/vms_x_fix.h>
+#endif
+
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -159,7 +163,7 @@ tabletPosChange(GLUTwindow * window, int first, int count, int *data)
 }
 #endif /* !_WIN32 */
 
-int
+static int
 __glutProcessDeviceEvents(XEvent * event)
 {
 #if !defined(_WIN32)
@@ -264,18 +268,21 @@ __glutProcessDeviceEvents(XEvent * event)
 #else
   {
     JOYINFOEX info;
-    int njoyId = 0;
-    int nConnected = 0;
-    MMRESULT result;
-
-    /* Loop through all possible joystick IDs until we get the error
-       JOYERR_PARMS. Count the number of times we get JOYERR_NOERROR
-       indicating an installed joystick driver with a joystick currently
-       attached to the port. */
-    while ((result = joyGetPosEx(njoyId++,&info)) != JOYERR_PARMS) {
-      if (result == JOYERR_NOERROR) {
-        ++nConnected;  /* The count of connected joysticks. */
-      }
+    JOYCAPS joyCaps;
+
+    memset(&info, 0, sizeof(JOYINFOEX)); 
+    info.dwSize = sizeof(JOYINFOEX); 
+    info.dwFlags = JOY_RETURNALL;
+
+    if (joyGetPosEx(JOYSTICKID1,&info) != JOYERR_NOERROR) {
+      __glutHasJoystick = 1;
+      joyGetDevCaps(JOYSTICKID1, &joyCaps, sizeof(joyCaps));
+      __glutNumJoystickButtons = joyCaps.wNumButtons;
+      __glutNumJoystickAxes = joyCaps.wNumAxes;
+    } else {
+      __glutHasJoystick = 0;
+      __glutNumJoystickButtons = 0;
+      __glutNumJoystickAxes = 0;
     }
   }
 #endif /* !_WIN32 */
@@ -308,7 +315,7 @@ probeDevices(void)
   XButtonInfoPtr b;
   XValuatorInfoPtr v;
   XAxisInfoPtr a;
-  int num_dev, btns, dials;
+  int num_dev = 0, btns = 0, dials = 0;
   int i, j, k;
 #endif /* !_WIN32 */