View | Details | Raw Unified | Return to bug 254454
Collapse All | Expand All

(-)graphics/freeglut/Makefile (-2 / +1 lines)
Lines 2-9 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	freeglut
4
PORTNAME=	freeglut
5
PORTVERSION=	3.0.0
5
PORTVERSION=	3.2.1
6
PORTREVISION=	2
7
CATEGORIES=	graphics
6
CATEGORIES=	graphics
8
MASTER_SITES=	SF
7
MASTER_SITES=	SF
9
8
(-)graphics/freeglut/distinfo (-2 / +3 lines)
Lines 1-2 Link Here
1
SHA256 (freeglut-3.0.0.tar.gz) = 2a43be8515b01ea82bcfa17d29ae0d40bd128342f0930cd1f375f1ff999f76a2
1
TIMESTAMP = 1616308723
2
SIZE (freeglut-3.0.0.tar.gz) = 419095
2
SHA256 (freeglut-3.2.1.tar.gz) = d4000e02102acaf259998c870e25214739d1f16f67f99cb35e4f46841399da68
3
SIZE (freeglut-3.2.1.tar.gz) = 440228
(-)graphics/freeglut/files/patch-src_fg__joystick.c (-304 lines)
Lines 1-304 Link Here
1
--- src/fg_joystick.c.orig	2014-10-20 15:27:04 UTC
2
+++ src/fg_joystick.c
3
@@ -40,238 +40,6 @@
4
 #define JS_TRUE  1
5
 #define JS_FALSE 0
6
 
7
-/* BSD defines from "jsBSD.cxx" around lines 42-270 */
8
-
9
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
10
-
11
-#    ifdef HAVE_USB_JS
12
-#        if defined(__NetBSD__)
13
-/* XXX The below hack is done until freeglut's autoconf is updated. */
14
-#            define HAVE_USBHID_H 1
15
-#            ifdef HAVE_USBHID_H
16
-#                include <usbhid.h>
17
-#            else
18
-#                include <usb.h>
19
-#            endif
20
-#        elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
21
-#            ifdef HAVE_USBHID_H
22
-#                include <usbhid.h>
23
-#            else
24
-#                include <libusbhid.h>
25
-#            endif
26
-#        endif
27
-#        include <legacy/dev/usb/usb.h>
28
-#        include <dev/usb/usbhid.h>
29
-
30
-/* Compatibility with older usb.h revisions */
31
-#        if !defined(USB_MAX_DEVNAMES) && defined(MAXDEVNAMES)
32
-#            define USB_MAX_DEVNAMES MAXDEVNAMES
33
-#        endif
34
-#    endif
35
-
36
-static int hatmap_x[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 };
37
-static int hatmap_y[9] = { 0, 1, 1, 0, -1, -1, -1, 0, 1 };
38
-struct os_specific_s {
39
-  char             fname [128 ];
40
-  int              fd;
41
-  int              is_analog;
42
-  /* The following structure members are specific to analog joysticks */
43
-  struct joystick  ajs;
44
-#    ifdef HAVE_USB_JS
45
-  /* The following structure members are specific to USB joysticks */
46
-  struct hid_item *hids;
47
-  int              hid_dlen;
48
-  int              hid_offset;
49
-  char            *hid_data_buf;
50
-  int              axes_usage [ _JS_MAX_AXES ];
51
-#    endif
52
-  /* We keep button and axes state ourselves, as they might not be updated
53
-   * on every read of a USB device
54
-   */
55
-  int              cache_buttons;
56
-  float            cache_axes [ _JS_MAX_AXES ];
57
-};
58
-
59
-/* Idents lower than USB_IDENT_OFFSET are for analog joysticks. */
60
-#    define USB_IDENT_OFFSET    2
61
-
62
-#    define USBDEV "/dev/usb"
63
-#    define UHIDDEV "/dev/uhid"
64
-#    define AJSDEV "/dev/joy"
65
-
66
-#    ifdef HAVE_USB_JS
67
-/*
68
- * fghJoystickFindUSBdev (and its helper, fghJoystickWalkUSBdev) try to locate
69
- * the full name of a USB device. If /dev/usbN isn't readable, we punt and
70
- * return the uhidN device name. We warn the user of this situation once.
71
- */
72
-static char *fghJoystickWalkUSBdev(int f, char *dev, char *out, int outlen)
73
-{
74
-  struct usb_device_info di;
75
-  int i, a;
76
-  char *cp;
77
-
78
-  for (a = 1; a < USB_MAX_DEVICES; a++) {
79
-    di.udi_addr = a;
80
-    if (ioctl(f, USB_DEVICEINFO, &di) != 0)
81
-      return NULL;
82
-    for (i = 0; i < USB_MAX_DEVNAMES; i++)
83
-      if (di.udi_devnames[i][0] &&
84
-          strcmp(di.udi_devnames[i], dev) == 0) {
85
-        cp =  calloc( 1, strlen(di.udi_vendor) + strlen(di.udi_product) + 2);
86
-        strcpy(cp, di.udi_vendor);
87
-        strcat(cp, " ");
88
-        strcat(cp, di.udi_product);
89
-        strncpy(out, cp, outlen - 1);
90
-        out[outlen - 1] = 0;
91
-        free( cp );
92
-        return out;
93
-      }
94
-  }
95
-  return NULL;
96
-}
97
-
98
-static int fghJoystickFindUSBdev(char *name, char *out, int outlen)
99
-{
100
-  int i, f;
101
-  char buf[50];
102
-  char *cp;
103
-  static int protection_warned = 0;
104
-
105
-  for (i = 0; i < 16; i++) {
106
-    snprintf(buf, sizeof(buf), "%s%d", USBDEV, i);
107
-    f = open(buf, O_RDONLY);
108
-    if (f >= 0) {
109
-      cp = fghJoystickWalkUSBdev(f, name, out, outlen);
110
-      close(f);
111
-      if (cp)
112
-        return 1;
113
-    }
114
-    else if (errno == EACCES) {
115
-      if (!protection_warned) {
116
-        fgWarning ( "Can't open %s for read!", buf );
117
-        protection_warned = 1;
118
-      }
119
-    }
120
-  }
121
-  return 0;
122
-}
123
-
124
-static int fghJoystickInitializeHID(struct os_specific_s *os,
125
-       int *num_axes, int *num_buttons)
126
-{
127
-    int size, is_joystick;
128
-#   ifdef HAVE_USBHID_H
129
-        int report_id = 0;
130
-#   endif
131
-    struct hid_data *d;
132
-    struct hid_item h;
133
-    report_desc_t rd;
134
-
135
-    if ( ( rd = hid_get_report_desc( os->fd ) ) == 0 )
136
-    {
137
-        fgWarning ( "error: %s: %s", os->fname, strerror( errno ) );
138
-        return FALSE;
139
-    }
140
-
141
-    os->hids = NULL;
142
-
143
-#   ifdef HAVE_USBHID_H
144
-        if( ioctl( os->fd, USB_GET_REPORT_ID, &report_id ) < 0)
145
-        {
146
-            /*** XXX {report_id} may not be the right variable? ***/
147
-            fgWarning ( "error: %s%d: %s", UHIDDEV, report_id, strerror( errno ) );
148
-            return FALSE;
149
-        }
150
-
151
-        size = hid_report_size( rd, hid_input, report_id );
152
-#   else
153
-        size = hid_report_size( rd, 0, hid_input );
154
-#   endif
155
-    os->hid_data_buf = calloc( 1, size );
156
-    os->hid_dlen = size;
157
-
158
-    is_joystick = 0;
159
-#   ifdef HAVE_USBHID_H
160
-        d = hid_start_parse( rd, 1 << hid_input, report_id );
161
-#   else
162
-        d = hid_start_parse( rd, 1 << hid_input );
163
-#   endif
164
-        while( hid_get_item( d, &h ) )
165
-        {
166
-            int usage, page, interesting_hid;
167
-
168
-            page = HID_PAGE( h.usage );
169
-            usage = HID_USAGE( h.usage );
170
-
171
-            /* This test is somewhat too simplistic, but this is how MicroSoft
172
-             * does, so I guess it works for all joysticks/game pads. */
173
-            is_joystick = is_joystick ||
174
-                ( h.kind == hid_collection &&
175
-                  page == HUP_GENERIC_DESKTOP &&
176
-                  ( usage == HUG_JOYSTICK || usage == HUG_GAME_PAD ) );
177
-
178
-            if( h.kind != hid_input )
179
-                continue;
180
-
181
-            if( !is_joystick )
182
-                continue;
183
-
184
-            interesting_hid = TRUE;
185
-            if( page == HUP_GENERIC_DESKTOP )
186
-            {
187
-                switch( usage )
188
-                {
189
-                case HUG_X:
190
-                case HUG_RX:
191
-                case HUG_Y:
192
-                case HUG_RY:
193
-                case HUG_Z:
194
-                case HUG_RZ:
195
-                case HUG_SLIDER:
196
-                    if( *num_axes < _JS_MAX_AXES )
197
-                    {
198
-                        os->axes_usage[ *num_axes ] = usage;
199
-                        ( *num_axes )++;
200
-                    }
201
-                    break;
202
-                case HUG_HAT_SWITCH:
203
-                    /* Allocate two axes for a hat */
204
-                    if( *num_axes + 1 < _JS_MAX_AXES )
205
-                    {
206
-                        os->axes_usage[ *num_axes ] = usage;
207
-                        (*num_axes)++;
208
-                        os->axes_usage[ *num_axes ] = usage;
209
-                        (*num_axes)++;
210
-                    }
211
-                    break;
212
-                default:
213
-                    interesting_hid = FALSE;
214
-                    break;
215
-                }
216
-            }
217
-            else if( page == HUP_BUTTON )
218
-            {
219
-                interesting_hid = ( usage > 0 ) &&
220
-                    ( usage <= _JS_MAX_BUTTONS );
221
-
222
-                if( interesting_hid && usage - 1 > *num_buttons )
223
-                    *num_buttons = usage - 1;
224
-            }
225
-
226
-            if( interesting_hid )
227
-            {
228
-                h.next = os->hids;
229
-                os->hids = calloc( 1, sizeof ( struct hid_item ) );
230
-                *os->hids = h;
231
-            }
232
-        }
233
-        hid_end_parse( d );
234
-
235
-        return os->hids != NULL;
236
-}
237
-#    endif
238
-#endif
239
 
240
 /*
241
  * Functions associated with the "jsJoystick" class in PLIB
242
@@ -306,26 +74,6 @@ extern void fgPlatformJoystickClose ( in
243
 #define MAX_NUM_JOYSTICKS  2
244
 SFG_Joystick *fgJoystick [ MAX_NUM_JOYSTICKS ];
245
 
246
-/*
247
- * Read the raw joystick data
248
- */
249
-static void fghJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
250
-{
251
-    int i;
252
-
253
-    /* Defaults */
254
-    if( buttons )
255
-        *buttons = 0;
256
-
257
-    if( axes )
258
-        for( i = 0; i < joy->num_axes; i++ )
259
-            axes[ i ] = 1500.0f;
260
-
261
-    if( joy->error )
262
-        return;
263
-
264
-	fgPlatformJoystickRawRead ( joy, buttons, axes );
265
-}
266
 
267
 /*
268
  * Correct the joystick axis data
269
@@ -384,7 +132,7 @@ static void fghJoystickRead( SFG_Joystic
270
                 axes[ i ] = 0.0f;
271
     }
272
 
273
-    fghJoystickRawRead( joy, buttons, raw_axes );
274
+    fgJoystickRawRead( joy, buttons, raw_axes );
275
 
276
     if( axes )
277
         for( i=0; i<joy->num_axes; i++ )
278
@@ -966,6 +714,26 @@ int fgJoystickDetect( void )
279
 }
280
 
281
 /*
282
+ * Read the raw joystick data
283
+ */
284
+void fgJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
285
+{
286
+    int i;
287
+
288
+    /* Defaults */
289
+    if( buttons )
290
+        *buttons = 0;
291
+
292
+    if( axes )
293
+        for( i = 0; i < joy->num_axes; i++ )
294
+            axes[ i ] = 1500.0f;
295
+
296
+    if( joy->error )
297
+        return;
298
+
299
+	fgPlatformJoystickRawRead ( joy, buttons, axes );
300
+}
301
+/*
302
  * Joystick information, setup and execution functions
303
  */
304
 
(-)graphics/freeglut/files/patch-src_x11_fg__joystick__x11.c (-79 / +278 lines)
Lines 1-23 Link Here
1
--- src/x11/fg_joystick_x11.c.orig	2014-12-02 05:22:12 UTC
1
--- src/x11/fg_joystick_x11.c.orig	2021-03-21 08:11:11 UTC
2
+++ src/x11/fg_joystick_x11.c
2
+++ src/x11/fg_joystick_x11.c
3
@@ -46,6 +46,183 @@
3
@@ -41,196 +41,135 @@
4
 #define MAX_NUM_JOYSTICKS  2   
5
 extern SFG_Joystick *fgJoystick [ MAX_NUM_JOYSTICKS ];
6
 
4
 
7
+#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
5
 #include <fcntl.h>
6
 
7
+/*this should be defined in a header file */
8
+#define MAX_NUM_JOYSTICKS  2
9
 
10
-/* BSD defines from "jsBSD.cxx" around lines 42-270 */
11
-
12
 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
13
-
14
-#    ifdef HAVE_USB_JS
15
-#        if defined(__NetBSD__)
16
-#            ifdef HAVE_USBHID_H
17
-#                include <usbhid.h>
18
-#            else
19
-#                include <usb.h>
20
-#            endif
21
-#            include <dev/usb/usb.h>
22
-#        elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
23
-#            ifdef HAVE_USBHID_H
24
-#                include <usbhid.h>
25
-#            else
26
-#                include <libusbhid.h>
27
-#            endif
28
-#            include <legacy/dev/usb/usb.h>
29
-#        endif
30
-#        include <dev/usb/usbhid.h>
31
-
32
-/* Compatibility with older usb.h revisions */
33
-#        if !defined(USB_MAX_DEVNAMES) && defined(MAXDEVNAMES)
34
-#            define USB_MAX_DEVNAMES MAXDEVNAMES
35
-#        endif
36
-#    endif
37
-
38
-struct os_specific_s {
39
-  char             fname [128 ];
40
-  int              fd;
41
-  int              is_analog;
42
-  /* The following structure members are specific to analog joysticks */
43
-  struct joystick  ajs;
44
-#    ifdef HAVE_USB_JS
45
-  /* The following structure members are specific to USB joysticks */
46
-  struct hid_item *hids;
47
-  int              hid_dlen;
48
-  int              hid_offset;
49
-  char            *hid_data_buf;
50
-  int              axes_usage [ _JS_MAX_AXES ];
51
-#    endif
52
-  /* We keep button and axes state ourselves, as they might not be updated
53
-   * on every read of a USB device
54
-   */
55
-  int              cache_buttons;
56
-  float            cache_axes [ _JS_MAX_AXES ];
57
-};
58
-
59
-/* Idents lower than USB_IDENT_OFFSET are for analog joysticks. */
60
-#    define USB_IDENT_OFFSET    2
61
-
62
-#    define USBDEV "/dev/usb"
63
-#    define UHIDDEV "/dev/uhid"
64
-#    define AJSDEV "/dev/joy"
65
-
66
-
67
-#endif
68
-
69
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
70
-
71
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
72
-static int hatmap_x[9] = {0, 0, 1, 1, 1, 0, -1, -1, -1};
73
-static int hatmap_y[9] = {0, 1, 1, 0, -1, -1, -1, 0, 1};
74
-
75
-#    ifdef HAVE_USB_JS
8
+#  ifdef HAVE_USB_JS
76
+#  ifdef HAVE_USB_JS
9
+/*
77
 /*
78
-* fghJoystickFindUSBdev (and its helper, fghJoystickWalkUSBdev) try to locate
79
-* the full name of a USB device. If /dev/usbN isn't readable, we punt and
80
-* return the uhidN device name. We warn the user of this situation once.
81
-*/
10
+ * fghJoystickFindUSBdev (and its helper, fghJoystickWalkUSBdev) try to locate
82
+ * fghJoystickFindUSBdev (and its helper, fghJoystickWalkUSBdev) try to locate
11
+ * the full name of a USB device. If /dev/usbN isn't readable, we punt and
83
+ * the full name of a USB device. If /dev/usbN isn't readable, we punt and
12
+ * return the uhidN device name. We warn the user of this situation once.
84
+ * return the uhidN device name. We warn the user of this situation once.
13
+ */
85
+ */
14
+static char *fghJoystickWalkUSBdev(int f, char *dev, char *out, int outlen)
86
 static char *fghJoystickWalkUSBdev(int f, char *dev, char *out, int outlen)
15
+{
87
 {
88
-    struct usb_device_info di;
89
-    int i, a;
90
-    char *cp;
16
+#if __FreeBSD_version < 800061
91
+#if __FreeBSD_version < 800061
17
+  struct usb_device_info di;
92
+  struct usb_device_info di;
18
+  int i, a;
93
+  int i, a;
19
+  char *cp;
94
+  char *cp;
20
+
95
 
96
-    for (a = 1; a < USB_MAX_DEVICES; a++) {
97
-        di.udi_addr = a;
98
-        if (ioctl(f, USB_DEVICEINFO, &di) != 0)
99
-            return NULL;
100
-        for (i = 0; i < USB_MAX_DEVNAMES; i++)
101
-            if (di.udi_devnames[i][0] &&
102
-                strcmp(di.udi_devnames[i], dev) == 0) {
103
-                cp = calloc(1, strlen(di.udi_vendor) + strlen(di.udi_product) + 2);
104
-                strcpy(cp, di.udi_vendor);
105
-                strcat(cp, " ");
106
-                strcat(cp, di.udi_product);
107
-                strncpy(out, cp, outlen - 1);
108
-                out[outlen - 1] = 0;
109
-                free(cp);
110
-                return out;
111
-            }
112
-    }
113
-    return NULL;
21
+  for (a = 1; a < USB_MAX_DEVICES; a++) {
114
+  for (a = 1; a < USB_MAX_DEVICES; a++) {
22
+    di.udi_addr = a;
115
+    di.udi_addr = a;
23
+    if (ioctl(f, USB_DEVICEINFO, &di) != 0)
116
+    if (ioctl(f, USB_DEVICEINFO, &di) != 0)
Lines 37-51 Link Here
37
+  }
130
+  }
38
+#endif
131
+#endif
39
+  return NULL;
132
+  return NULL;
40
+}
133
 }
41
+
134
 
42
+static int fghJoystickFindUSBdev(char *name, char *out, int outlen)
135
 static int fghJoystickFindUSBdev(char *name, char *out, int outlen)
43
+{
136
 {
137
-    int i, f;
138
-    char buf[50];
139
-    char *cp;
140
-    static int protection_warned = 0;
44
+  int i, f;
141
+  int i, f;
45
+  char buf[50];
142
+  char buf[50];
46
+  char *cp;
143
+  char *cp;
47
+  static int protection_warned = 0;
144
+  static int protection_warned = 0;
48
+
145
 
146
-    for (i = 0; i < 16; i++) {
147
-        snprintf(buf, sizeof(buf), "%s%d", USBDEV, i);
148
-        f = open(buf, O_RDONLY);
149
-        if (f >= 0) {
150
-            cp = fghJoystickWalkUSBdev(f, name, out, outlen);
151
-            close(f);
152
-            if (cp)
153
-                return 1;
154
-        }
155
-        else if (errno == EACCES) {
156
-            if (!protection_warned) {
157
-                fgWarning("Can't open %s for read!", buf);
158
-                protection_warned = 1;
159
-            }
160
-        }
49
+  for (i = 0; i < 16; i++) {
161
+  for (i = 0; i < 16; i++) {
50
+    snprintf(buf, sizeof(buf), "%s%d", USBDEV, i);
162
+    snprintf(buf, sizeof(buf), "%s%d", USBDEV, i);
51
+    f = open(buf, O_RDONLY);
163
+    f = open(buf, O_RDONLY);
Lines 54-60 Link Here
54
+      close(f);
166
+      close(f);
55
+      if (cp)
167
+      if (cp)
56
+        return 1;
168
+        return 1;
57
+    }
169
     }
170
-    return 0;
58
+    else if (errno == EACCES) {
171
+    else if (errno == EACCES) {
59
+      if (!protection_warned) {
172
+      if (!protection_warned) {
60
+        fgWarning ( "Can't open %s for read!", buf );
173
+        fgWarning ( "Can't open %s for read!", buf );
Lines 63-90 Link Here
63
+    }
176
+    }
64
+  }
177
+  }
65
+  return 0;
178
+  return 0;
66
+}
179
 }
67
+
180
-#endif
68
+static int fghJoystickInitializeHID(struct os_specific_s *os,
181
 
182
 static int fghJoystickInitializeHID(struct os_specific_s *os,
183
-                                    int *num_axes, int *num_buttons)
69
+       int *num_axes, int *num_buttons)
184
+       int *num_axes, int *num_buttons)
70
+{
185
 {
71
+    int size, is_joystick;
186
     int size, is_joystick;
72
+#   ifdef HAVE_USBHID_H
187
 #   ifdef HAVE_USBHID_H
188
-    int report_id = 0;
73
+        int report_id = 0;
189
+        int report_id = 0;
74
+#   endif
190
 #   endif
75
+    struct hid_data *d;
191
     struct hid_data *d;
76
+    struct hid_item h;
192
     struct hid_item h;
77
+    report_desc_t rd;
193
     report_desc_t rd;
78
+
194
 
195
-    if ((rd = hid_get_report_desc(os->fd)) == 0)
79
+    if ( ( rd = hid_get_report_desc( os->fd ) ) == 0 )
196
+    if ( ( rd = hid_get_report_desc( os->fd ) ) == 0 )
80
+    {
197
     {
198
-        fgWarning("error: %s: %s", os->fname, strerror(errno));
81
+        fgWarning ( "error: %s: %s", os->fname, strerror( errno ) );
199
+        fgWarning ( "error: %s: %s", os->fname, strerror( errno ) );
82
+        return FALSE;
200
         return FALSE;
83
+    }
201
     }
84
+
202
 
85
+    os->hids = NULL;
203
     os->hids = NULL;
86
+
204
 
87
+#   ifdef HAVE_USBHID_H
205
 #   ifdef HAVE_USBHID_H
206
-    if (ioctl(os->fd, USB_GET_REPORT_ID, &report_id) < 0)
207
-    {
208
-        /*** XXX {report_id} may not be the right variable? ***/
209
-        fgWarning("error: %s%d: %s", UHIDDEV, report_id, strerror(errno));
210
-        return FALSE;
211
-    }
88
+        if( ioctl( os->fd, USB_GET_REPORT_ID, &report_id ) < 0)
212
+        if( ioctl( os->fd, USB_GET_REPORT_ID, &report_id ) < 0)
89
+        {
213
+        {
90
+            /*** XXX {report_id} may not be the right variable? ***/
214
+            /*** XXX {report_id} may not be the right variable? ***/
Lines 91-117 Link Here
91
+            fgWarning ( "error: %s%d: %s", UHIDDEV, report_id, strerror( errno ) );
215
+            fgWarning ( "error: %s%d: %s", UHIDDEV, report_id, strerror( errno ) );
92
+            return FALSE;
216
+            return FALSE;
93
+        }
217
+        }
94
+
218
 
219
-    size = hid_report_size(rd, hid_input, report_id);
95
+        size = hid_report_size( rd, hid_input, report_id );
220
+        size = hid_report_size( rd, hid_input, report_id );
96
+#   else
221
 #   else
222
-    size = hid_report_size(rd, 0, hid_input);
97
+        size = hid_report_size( rd, 0, hid_input );
223
+        size = hid_report_size( rd, 0, hid_input );
98
+#   endif
224
 #   endif
225
-    os->hid_data_buf = calloc(1, size);
99
+    os->hid_data_buf = calloc( 1, size );
226
+    os->hid_data_buf = calloc( 1, size );
100
+    os->hid_dlen = size;
227
     os->hid_dlen = size;
101
+
228
 
102
+    is_joystick = 0;
229
     is_joystick = 0;
103
+#   ifdef HAVE_USBHID_H
230
 #   ifdef HAVE_USBHID_H
231
-    d = hid_start_parse(rd, 1 << hid_input, report_id);
104
+        d = hid_start_parse( rd, 1 << hid_input, report_id );
232
+        d = hid_start_parse( rd, 1 << hid_input, report_id );
105
+#   else
233
 #   else
234
-    d = hid_start_parse(rd, 1 << hid_input);
106
+        d = hid_start_parse( rd, 1 << hid_input );
235
+        d = hid_start_parse( rd, 1 << hid_input );
107
+#   endif
236
 #   endif
237
-    while (hid_get_item(d, &h))
238
-    {
239
-        int usage, page, interesting_hid;
108
+        while( hid_get_item( d, &h ) )
240
+        while( hid_get_item( d, &h ) )
109
+        {
241
+        {
110
+            int usage, page, interesting_hid;
242
+            int usage, page, interesting_hid;
111
+
243
 
244
-        page = HID_PAGE(h.usage);
245
-        usage = HID_USAGE(h.usage);
112
+            page = HID_PAGE( h.usage );
246
+            page = HID_PAGE( h.usage );
113
+            usage = HID_USAGE( h.usage );
247
+            usage = HID_USAGE( h.usage );
114
+
248
 
249
-        /* This test is somewhat too simplistic, but this is how MicroSoft
250
-        * does, so I guess it works for all joysticks/game pads. */
251
-        is_joystick = is_joystick ||
252
-            (h.kind == hid_collection &&
253
-             page == HUP_GENERIC_DESKTOP &&
254
-             (usage == HUG_JOYSTICK || usage == HUG_GAME_PAD));
115
+            /* This test is somewhat too simplistic, but this is how MicroSoft
255
+            /* This test is somewhat too simplistic, but this is how MicroSoft
116
+             * does, so I guess it works for all joysticks/game pads. */
256
+             * does, so I guess it works for all joysticks/game pads. */
117
+            is_joystick = is_joystick ||
257
+            is_joystick = is_joystick ||
Lines 118-172 Link Here
118
+                ( h.kind == hid_collection &&
258
+                ( h.kind == hid_collection &&
119
+                  page == HUP_GENERIC_DESKTOP &&
259
+                  page == HUP_GENERIC_DESKTOP &&
120
+                  ( usage == HUG_JOYSTICK || usage == HUG_GAME_PAD ) );
260
+                  ( usage == HUG_JOYSTICK || usage == HUG_GAME_PAD ) );
121
+
261
 
262
-        if (h.kind != hid_input)
263
-            continue;
122
+            if( h.kind != hid_input )
264
+            if( h.kind != hid_input )
123
+                continue;
265
+                continue;
124
+
266
 
267
-        if (!is_joystick)
268
-            continue;
125
+            if( !is_joystick )
269
+            if( !is_joystick )
126
+                continue;
270
+                continue;
127
+
271
 
272
-        interesting_hid = TRUE;
273
-        if (page == HUP_GENERIC_DESKTOP)
274
-        {
275
-            switch (usage)
128
+            interesting_hid = TRUE;
276
+            interesting_hid = TRUE;
129
+            if( page == HUP_GENERIC_DESKTOP )
277
+            if( page == HUP_GENERIC_DESKTOP )
130
+            {
278
             {
131
+                switch( usage )
279
+                switch( usage )
132
+                {
280
+                {
133
+                case HUG_X:
281
                 case HUG_X:
134
+                case HUG_RX:
282
                 case HUG_RX:
135
+                case HUG_Y:
283
                 case HUG_Y:
136
+                case HUG_RY:
284
@@ -238,53 +177,51 @@ static int fghJoystickInitializeHID(struct os_specific
137
+                case HUG_Z:
285
                 case HUG_Z:
138
+                case HUG_RZ:
286
                 case HUG_RZ:
139
+                case HUG_SLIDER:
287
                 case HUG_SLIDER:
288
-                    if (*num_axes < _JS_MAX_AXES)
140
+                    if( *num_axes < _JS_MAX_AXES )
289
+                    if( *num_axes < _JS_MAX_AXES )
141
+                    {
290
                     {
291
-                        os->axes_usage[*num_axes] = usage;
292
-                        (*num_axes)++;
142
+                        os->axes_usage[ *num_axes ] = usage;
293
+                        os->axes_usage[ *num_axes ] = usage;
143
+                        ( *num_axes )++;
294
+                        ( *num_axes )++;
144
+                    }
295
                     }
145
+                    break;
296
                     break;
146
+                case HUG_HAT_SWITCH:
297
                 case HUG_HAT_SWITCH:
147
+                    /* Allocate two axes for a hat */
298
                     /* Allocate two axes for a hat */
299
-                    if (*num_axes + 1 < _JS_MAX_AXES)
148
+                    if( *num_axes + 1 < _JS_MAX_AXES )
300
+                    if( *num_axes + 1 < _JS_MAX_AXES )
149
+                    {
301
                     {
302
-                        os->axes_usage[*num_axes] = usage;
150
+                        os->axes_usage[ *num_axes ] = usage;
303
+                        os->axes_usage[ *num_axes ] = usage;
151
+                        (*num_axes)++;
304
                         (*num_axes)++;
305
-                        os->axes_usage[*num_axes] = usage;
152
+                        os->axes_usage[ *num_axes ] = usage;
306
+                        os->axes_usage[ *num_axes ] = usage;
153
+                        (*num_axes)++;
307
                         (*num_axes)++;
154
+                    }
308
                     }
155
+                    break;
309
                     break;
156
+                default:
310
                 default:
157
+                    interesting_hid = FALSE;
311
                     interesting_hid = FALSE;
158
+                    break;
312
                     break;
159
+                }
313
+                }
160
+            }
314
             }
315
-        }
316
-        else if (page == HUP_BUTTON)
317
-        {
318
-            interesting_hid = (usage > 0) &&
319
-                (usage <= _JS_MAX_BUTTONS);
161
+            else if( page == HUP_BUTTON )
320
+            else if( page == HUP_BUTTON )
162
+            {
321
+            {
163
+                interesting_hid = ( usage > 0 ) &&
322
+                interesting_hid = ( usage > 0 ) &&
164
+                    ( usage <= _JS_MAX_BUTTONS );
323
+                    ( usage <= _JS_MAX_BUTTONS );
165
+
324
 
325
-            if (interesting_hid && usage - 1 > *num_buttons)
326
-                *num_buttons = usage - 1;
327
-        }
166
+                if( interesting_hid && usage - 1 > *num_buttons )
328
+                if( interesting_hid && usage - 1 > *num_buttons )
167
+                    *num_buttons = usage - 1;
329
+                    *num_buttons = usage - 1;
168
+            }
330
+            }
169
+
331
 
332
-        if (interesting_hid)
333
-        {
334
-            h.next = os->hids;
335
-            os->hids = calloc(1, sizeof(struct hid_item));
336
-            *os->hids = h;
170
+            if( interesting_hid )
337
+            if( interesting_hid )
171
+            {
338
+            {
172
+                h.next = os->hids;
339
+                h.next = os->hids;
Lines 173-190 Link Here
173
+                os->hids = calloc( 1, sizeof ( struct hid_item ) );
340
+                os->hids = calloc( 1, sizeof ( struct hid_item ) );
174
+                *os->hids = h;
341
+                *os->hids = h;
175
+            }
342
+            }
176
+        }
343
         }
344
-    }
345
-    hid_end_parse(d);
177
+        hid_end_parse( d );
346
+        hid_end_parse( d );
178
+
347
 
348
-    return os->hids != NULL;
179
+        return os->hids != NULL;
349
+        return os->hids != NULL;
180
+}
350
 }
351
-#    endif
352
-#endif
181
+#  endif /* HAVE_USB_JS */
353
+#  endif /* HAVE_USB_JS */
182
+#endif /* FreeBSD or NetBSD */
354
+#endif /* FreeBSD or NetBSD */
183
+
355
 
356
 
357
-/*this should be defined in a header file */
358
-#define MAX_NUM_JOYSTICKS  2
359
 extern SFG_Joystick *fgJoystick [ MAX_NUM_JOYSTICKS ];
360
 
184
 void fgPlatformJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
361
 void fgPlatformJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
185
 {
362
@@ -500,7 +437,7 @@ void fgPlatformJoystickOpen( SFG_Joystick* joy )
186
     int status;
187
@@ -259,7 +436,7 @@ void fgPlatformJoystickOpen( SFG_Joystic
188
         joy->num_axes    =  2;
363
         joy->num_axes    =  2;
189
         joy->num_buttons = 32;
364
         joy->num_buttons = 32;
190
 
365
 
Lines 193-199 Link Here
193
         joy->error = axes[ 0 ] < -1000000000.0f;
368
         joy->error = axes[ 0 ] < -1000000000.0f;
194
         if( joy->error )
369
         if( joy->error )
195
             return;
370
             return;
196
@@ -379,7 +556,7 @@ void fgPlatformJoystickOpen( SFG_Joystic
371
@@ -620,7 +557,7 @@ void fgPlatformJoystickOpen( SFG_Joystick* joy )
197
 
372
 
198
     do
373
     do
199
     {
374
     {
Lines 202-204 Link Here
202
         counter++;
377
         counter++;
203
     } while( !joy->error &&
378
     } while( !joy->error &&
204
              counter < 100 &&
379
              counter < 100 &&
380
@@ -647,6 +584,23 @@ void fgPlatformJoystickOpen( SFG_Joystick* joy )
381
 #endif
382
 }
383
 
384
+void fgJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
385
+{
386
+    int i;
387
+
388
+    /* Defaults */
389
+    if( buttons )
390
+        *buttons = 0;
391
+
392
+    if( axes )
393
+        for( i = 0; i < joy->num_axes; i++ )
394
+            axes[ i ] = 1500.0f;
395
+
396
+    if( joy->error )
397
+        return;
398
+
399
+	fgPlatformJoystickRawRead ( joy, buttons, axes );
400
+}
401
 
402
 void fgPlatformJoystickInit( SFG_Joystick *fgJoystick[], int ident )
403
 {
(-)graphics/freeglut/pkg-plist (-4 / +9 lines)
Lines 1-24 Link Here
1
include/GL/freeglut.h
1
include/GL/freeglut.h
2
include/GL/freeglut_ext.h
2
include/GL/freeglut_ext.h
3
include/GL/freeglut_std.h
3
include/GL/freeglut_std.h
4
include/GL/freeglut_ucall.h
4
include/GL/glut.h
5
include/GL/glut.h
6
lib/cmake/FreeGLUT/FreeGLUTConfig.cmake
7
lib/cmake/FreeGLUT/FreeGLUTConfigVersion.cmake
8
lib/cmake/FreeGLUT/FreeGLUTTargets-%%CMAKE_BUILD_TYPE%%.cmake
9
lib/cmake/FreeGLUT/FreeGLUTTargets.cmake
5
lib/libglut.a
10
lib/libglut.a
6
lib/libglut.so
11
lib/libglut.so
7
lib/libglut.so.3
12
lib/libglut.so.3
8
lib/libglut.so.3.10.0
13
lib/libglut.so.3.11.0
9
libdata/pkgconfig/freeglut.pc
14
libdata/pkgconfig/glut.pc
10
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/CallbackMaker
15
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/CallbackMaker
11
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/Fractals
16
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/Fractals
12
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/Fractals_random
17
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/Fractals_random
13
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/fractals.dat
14
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/Lorenz
18
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/Lorenz
15
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/One
19
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/One
16
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/Resizer
20
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/Resizer
21
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/fractals.dat
17
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/multi-touch
22
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/multi-touch
23
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/shapes
18
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/smooth_opengl3
24
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/smooth_opengl3
19
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/spaceball
25
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/spaceball
20
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/subwin
26
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/subwin
21
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/shapes
22
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/timer
27
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/timer
23
%%PORTDOCS%%%%DOCSDIR%%/download.html
28
%%PORTDOCS%%%%DOCSDIR%%/download.html
24
%%PORTDOCS%%%%DOCSDIR%%/freeglut.html
29
%%PORTDOCS%%%%DOCSDIR%%/freeglut.html

Return to bug 254454