forked from Ravenports/Ravenports
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfreeglut
720 lines (676 loc) · 20.6 KB
/
freeglut
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
# Buildsheet autogenerated by ravenadm tool -- Do not edit.
NAMEBASE= freeglut
VERSION= 3.0.0
KEYWORDS= graphics
VARIANTS= standard
SDESC[standard]= FOSS implementation of the GLUT library
HOMEPAGE= http://freeglut.sourceforge.net/
CONTACT= nobody
DOWNLOAD_GROUPS= main
SITES[main]= SF/freeglut/freeglut/3.0.0
DISTFILE[1]= freeglut-3.0.0.tar.gz:main
DF_INDEX= 1
SPKGS[standard]= complete
primary
docs
examples
OPTIONS_AVAILABLE= none
OPTIONS_STANDARD= none
BUILDRUN_DEPENDS= libGLU:single:standard
USES= cmake mesa
XORG_COMPONENTS= ice x11 xi xrandr
LICENSE= MIT:primary
LICENSE_FILE= MIT:{{WRKSRC}}/COPYING
LICENSE_SCHEME= solo
FPC_EQUIVALENT= graphics/freeglut
INSTALL_TARGET= install/strip
VAR_OPSYS[freebsd]= LDFLAGS=-lusbhid
LDFLAGS=-lm
VAR_OPSYS[sunos]= LDFLAGS=-lrt
post-patch:
.for fract in Fractals/fractals.c Fractals_random/fractals_random.c
${REINPLACE_CMD} -e "s|/usr/local|${PREFIX}|g" \
${WRKSRC}/progs/demos/${fract}
.endfor
post-install:
@${MKDIR} ${STAGEDIR}${STD_DOCDIR} ${STAGEDIR}${STD_EXAMPLESDIR}
.for f in download.html freeglut.html freeglut_logo.png freeglut_user_interface.html index.html ogl_sm.png progress.html structure.html
${INSTALL_DATA} ${WRKSRC}/doc/${f} ${STAGEDIR}${STD_DOCDIR}
.endfor
${INSTALL_DATA} ${WRKSRC}/progs/demos/Fractals/fractals.dat \
${STAGEDIR}${STD_EXAMPLESDIR}
.for prog in CallbackMaker Fractals Fractals_random Lorenz One Resizer multi-touch shapes smooth_opengl3 spaceball subwin timer
${INSTALL_PROGRAM} ${WRKSRC}/bin/${prog} ${STAGEDIR}${STD_EXAMPLESDIR}
.endfor
[FILE:537:descriptions/desc.primary]
freeglut is a completely OpenSourced alternative to the OpenGL Utility
Toolkit (GLUT) library. GLUT was originally written by Mark Kilgard to
support the sample programs in the second edition OpenGL 'RedBook'.
Since then, GLUT has been used in a wide variety of practical applications
because it is simple, universally available and highly portable.
GLUT (and hence freeglut) allows the user to create and manage windows
containing OpenGL contexts on a wide range of platforms and also read the
mouse, keyboard and joystick functions.
[FILE:100:distinfo]
2a43be8515b01ea82bcfa17d29ae0d40bd128342f0930cd1f375f1ff999f76a2 419095 freeglut-3.0.0.tar.gz
[FILE:151:manifests/plist.primary]
include/GL/
freeglut.h
freeglut_ext.h
freeglut_std.h
glut.h
lib/
libglut.a
libglut.so
libglut.so.3
libglut.so.3.10.0
lib/pkgconfig/freeglut.pc
[FILE:154:manifests/plist.docs]
share/doc/freeglut/
download.html
freeglut.html
freeglut_logo.png
freeglut_user_interface.html
index.html
ogl_sm.png
progress.html
structure.html
[FILE:166:manifests/plist.examples]
share/examples/freeglut/
CallbackMaker
Fractals
Fractals_random
Lorenz
One
Resizer
fractals.dat
multi-touch
shapes
smooth_opengl3
spaceball
subwin
timer
[FILE:440:patches/patch-src_fg__internal.h]
--- src/fg_internal.h.orig 2014-12-22 16:27:02 UTC
+++ src/fg_internal.h
@@ -967,6 +967,7 @@ int fgJoystickDetect( void );
void fgInitialiseJoysticks( void );
void fgJoystickClose( void );
void fgJoystickPollWindow( SFG_Window* window );
+void fgJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes );
/* InputDevice Initialisation and Closure */
int fgInputDeviceDetect( void );
[FILE:8688:patches/patch-src_fg__joystick.c]
--- src/fg_joystick.c.orig 2014-10-20 15:27:04 UTC
+++ src/fg_joystick.c
@@ -40,238 +40,6 @@
#define JS_TRUE 1
#define JS_FALSE 0
-/* BSD defines from "jsBSD.cxx" around lines 42-270 */
-
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-
-# ifdef HAVE_USB_JS
-# if defined(__NetBSD__)
-/* XXX The below hack is done until freeglut's autoconf is updated. */
-# define HAVE_USBHID_H 1
-# ifdef HAVE_USBHID_H
-# include <usbhid.h>
-# else
-# include <usb.h>
-# endif
-# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-# ifdef HAVE_USBHID_H
-# include <usbhid.h>
-# else
-# include <libusbhid.h>
-# endif
-# endif
-# include <legacy/dev/usb/usb.h>
-# include <dev/usb/usbhid.h>
-
-/* Compatibility with older usb.h revisions */
-# if !defined(USB_MAX_DEVNAMES) && defined(MAXDEVNAMES)
-# define USB_MAX_DEVNAMES MAXDEVNAMES
-# endif
-# endif
-
-static int hatmap_x[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 };
-static int hatmap_y[9] = { 0, 1, 1, 0, -1, -1, -1, 0, 1 };
-struct os_specific_s {
- char fname [128 ];
- int fd;
- int is_analog;
- /* The following structure members are specific to analog joysticks */
- struct joystick ajs;
-# ifdef HAVE_USB_JS
- /* The following structure members are specific to USB joysticks */
- struct hid_item *hids;
- int hid_dlen;
- int hid_offset;
- char *hid_data_buf;
- int axes_usage [ _JS_MAX_AXES ];
-# endif
- /* We keep button and axes state ourselves, as they might not be updated
- * on every read of a USB device
- */
- int cache_buttons;
- float cache_axes [ _JS_MAX_AXES ];
-};
-
-/* Idents lower than USB_IDENT_OFFSET are for analog joysticks. */
-# define USB_IDENT_OFFSET 2
-
-# define USBDEV "/dev/usb"
-# define UHIDDEV "/dev/uhid"
-# define AJSDEV "/dev/joy"
-
-# ifdef HAVE_USB_JS
-/*
- * fghJoystickFindUSBdev (and its helper, fghJoystickWalkUSBdev) try to locate
- * the full name of a USB device. If /dev/usbN isn't readable, we punt and
- * return the uhidN device name. We warn the user of this situation once.
- */
-static char *fghJoystickWalkUSBdev(int f, char *dev, char *out, int outlen)
-{
- struct usb_device_info di;
- int i, a;
- char *cp;
-
- for (a = 1; a < USB_MAX_DEVICES; a++) {
- di.udi_addr = a;
- if (ioctl(f, USB_DEVICEINFO, &di) != 0)
- return NULL;
- for (i = 0; i < USB_MAX_DEVNAMES; i++)
- if (di.udi_devnames[i][0] &&
- strcmp(di.udi_devnames[i], dev) == 0) {
- cp = calloc( 1, strlen(di.udi_vendor) + strlen(di.udi_product) + 2);
- strcpy(cp, di.udi_vendor);
- strcat(cp, " ");
- strcat(cp, di.udi_product);
- strncpy(out, cp, outlen - 1);
- out[outlen - 1] = 0;
- free( cp );
- return out;
- }
- }
- return NULL;
-}
-
-static int fghJoystickFindUSBdev(char *name, char *out, int outlen)
-{
- int i, f;
- char buf[50];
- char *cp;
- static int protection_warned = 0;
-
- for (i = 0; i < 16; i++) {
- snprintf(buf, sizeof(buf), "%s%d", USBDEV, i);
- f = open(buf, O_RDONLY);
- if (f >= 0) {
- cp = fghJoystickWalkUSBdev(f, name, out, outlen);
- close(f);
- if (cp)
- return 1;
- }
- else if (errno == EACCES) {
- if (!protection_warned) {
- fgWarning ( "Can't open %s for read!", buf );
- protection_warned = 1;
- }
- }
- }
- return 0;
-}
-
-static int fghJoystickInitializeHID(struct os_specific_s *os,
- int *num_axes, int *num_buttons)
-{
- int size, is_joystick;
-# ifdef HAVE_USBHID_H
- int report_id = 0;
-# endif
- struct hid_data *d;
- struct hid_item h;
- report_desc_t rd;
-
- if ( ( rd = hid_get_report_desc( os->fd ) ) == 0 )
- {
- fgWarning ( "error: %s: %s", os->fname, strerror( errno ) );
- return FALSE;
- }
-
- os->hids = NULL;
-
-# ifdef HAVE_USBHID_H
- if( ioctl( os->fd, USB_GET_REPORT_ID, &report_id ) < 0)
- {
- /*** XXX {report_id} may not be the right variable? ***/
- fgWarning ( "error: %s%d: %s", UHIDDEV, report_id, strerror( errno ) );
- return FALSE;
- }
-
- size = hid_report_size( rd, hid_input, report_id );
-# else
- size = hid_report_size( rd, 0, hid_input );
-# endif
- os->hid_data_buf = calloc( 1, size );
- os->hid_dlen = size;
-
- is_joystick = 0;
-# ifdef HAVE_USBHID_H
- d = hid_start_parse( rd, 1 << hid_input, report_id );
-# else
- d = hid_start_parse( rd, 1 << hid_input );
-# endif
- while( hid_get_item( d, &h ) )
- {
- int usage, page, interesting_hid;
-
- page = HID_PAGE( h.usage );
- usage = HID_USAGE( h.usage );
-
- /* This test is somewhat too simplistic, but this is how MicroSoft
- * does, so I guess it works for all joysticks/game pads. */
- is_joystick = is_joystick ||
- ( h.kind == hid_collection &&
- page == HUP_GENERIC_DESKTOP &&
- ( usage == HUG_JOYSTICK || usage == HUG_GAME_PAD ) );
-
- if( h.kind != hid_input )
- continue;
-
- if( !is_joystick )
- continue;
-
- interesting_hid = TRUE;
- if( page == HUP_GENERIC_DESKTOP )
- {
- switch( usage )
- {
- case HUG_X:
- case HUG_RX:
- case HUG_Y:
- case HUG_RY:
- case HUG_Z:
- case HUG_RZ:
- case HUG_SLIDER:
- if( *num_axes < _JS_MAX_AXES )
- {
- os->axes_usage[ *num_axes ] = usage;
- ( *num_axes )++;
- }
- break;
- case HUG_HAT_SWITCH:
- /* Allocate two axes for a hat */
- if( *num_axes + 1 < _JS_MAX_AXES )
- {
- os->axes_usage[ *num_axes ] = usage;
- (*num_axes)++;
- os->axes_usage[ *num_axes ] = usage;
- (*num_axes)++;
- }
- break;
- default:
- interesting_hid = FALSE;
- break;
- }
- }
- else if( page == HUP_BUTTON )
- {
- interesting_hid = ( usage > 0 ) &&
- ( usage <= _JS_MAX_BUTTONS );
-
- if( interesting_hid && usage - 1 > *num_buttons )
- *num_buttons = usage - 1;
- }
-
- if( interesting_hid )
- {
- h.next = os->hids;
- os->hids = calloc( 1, sizeof ( struct hid_item ) );
- *os->hids = h;
- }
- }
- hid_end_parse( d );
-
- return os->hids != NULL;
-}
-# endif
-#endif
/*
* Functions associated with the "jsJoystick" class in PLIB
@@ -306,26 +74,6 @@ extern void fgPlatformJoystickClose ( in
#define MAX_NUM_JOYSTICKS 2
SFG_Joystick *fgJoystick [ MAX_NUM_JOYSTICKS ];
-/*
- * Read the raw joystick data
- */
-static void fghJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
-{
- int i;
-
- /* Defaults */
- if( buttons )
- *buttons = 0;
-
- if( axes )
- for( i = 0; i < joy->num_axes; i++ )
- axes[ i ] = 1500.0f;
-
- if( joy->error )
- return;
-
- fgPlatformJoystickRawRead ( joy, buttons, axes );
-}
/*
* Correct the joystick axis data
@@ -384,7 +132,7 @@ static void fghJoystickRead( SFG_Joystic
axes[ i ] = 0.0f;
}
- fghJoystickRawRead( joy, buttons, raw_axes );
+ fgJoystickRawRead( joy, buttons, raw_axes );
if( axes )
for( i=0; i<joy->num_axes; i++ )
@@ -966,6 +714,26 @@ int fgJoystickDetect( void )
}
/*
+ * Read the raw joystick data
+ */
+void fgJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
+{
+ int i;
+
+ /* Defaults */
+ if( buttons )
+ *buttons = 0;
+
+ if( axes )
+ for( i = 0; i < joy->num_axes; i++ )
+ axes[ i ] = 1500.0f;
+
+ if( joy->error )
+ return;
+
+ fgPlatformJoystickRawRead ( joy, buttons, axes );
+}
+/*
* Joystick information, setup and execution functions
*/
[FILE:2673:patches/patch-src_x11_fg__internal__x11.h]
--- src/x11/fg_internal_x11.h.orig 2014-10-20 15:27:04 UTC
+++ src/x11/fg_internal_x11.h
@@ -136,8 +136,42 @@ struct tagSFG_PlatformWindowState
#include <string.h>
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
+
+static int hatmap_x[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 };
+static int hatmap_y[9] = { 0, 1, 1, 0, -1, -1, -1, 0, 1 };
+
+/* Idents lower than USB_IDENT_OFFSET are for analog joysticks. */
+# define USB_IDENT_OFFSET 2
+
+# define USBDEV "/dev/usb"
+# define UHIDDEV "/dev/uhid"
+# define AJSDEV "/dev/joy"
+
/* XXX The below hack is done until freeglut's autoconf is updated. */
# define HAVE_USB_JS 1
+# if defined(__NetBSD__)
+/* XXX The below hack is done until freeglut's autoconf is updated. */
+# define HAVE_USBHID_H 1
+# ifdef HAVE_USBHID_H
+# include <usbhid.h>
+# else
+# include <usb.h>
+# endif
+# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+# ifdef HAVE_USBHID_H
+# include <usbhid.h>
+# else
+# include <libusbhid.h>
+# endif
+# include <dev/usb/usb_ioctl.h>
+# endif
+# include <dev/usb/usb.h>
+# include <dev/usb/usbhid.h>
+
+/* Compatibility with older usb.h revisions */
+# if !defined(USB_MAX_DEVNAMES) && defined(MAXDEVNAMES)
+# define USB_MAX_DEVNAMES MAXDEVNAMES
+# endif
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# include <sys/joystick.h>
@@ -189,6 +223,30 @@ struct tagSFG_PlatformWindowState
*/
# define _JS_MAX_AXES 16
typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
+
+# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
+struct os_specific_s {
+ char fname [128 ];
+ int fd;
+ int is_analog;
+ /* The following structure members are specific to analog joysticks */
+ struct joystick ajs;
+# ifdef HAVE_USB_JS
+ /* The following structure members are specific to USB joysticks */
+ struct hid_item *hids;
+ int hid_dlen;
+ int hid_offset;
+ char *hid_data_buf;
+ int axes_usage [ _JS_MAX_AXES ];
+# endif
+ /* We keep button and axes state ourselves, as they might not be updated
+ * on every read of a USB device
+ */
+ int cache_buttons;
+ float cache_axes [ _JS_MAX_AXES ];
+};
+# endif
+
struct tagSFG_PlatformJoystick
{
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
[FILE:6209:patches/patch-src_x11_fg__joystick__x11.c]
--- src/x11/fg_joystick_x11.c.orig 2014-12-02 05:22:12 UTC
+++ src/x11/fg_joystick_x11.c
@@ -46,6 +46,183 @@
#define MAX_NUM_JOYSTICKS 2
extern SFG_Joystick *fgJoystick [ MAX_NUM_JOYSTICKS ];
+#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+# ifdef HAVE_USB_JS
+/*
+ * fghJoystickFindUSBdev (and its helper, fghJoystickWalkUSBdev) try to locate
+ * the full name of a USB device. If /dev/usbN isn't readable, we punt and
+ * return the uhidN device name. We warn the user of this situation once.
+ */
+static char *fghJoystickWalkUSBdev(int f, char *dev, char *out, int outlen)
+{
+#if __FreeBSD_version < 800061
+ struct usb_device_info di;
+ int i, a;
+ char *cp;
+
+ for (a = 1; a < USB_MAX_DEVICES; a++) {
+ di.udi_addr = a;
+ if (ioctl(f, USB_DEVICEINFO, &di) != 0)
+ return NULL;
+ for (i = 0; i < USB_MAX_DEVNAMES; i++)
+ if (di.udi_devnames[i][0] &&
+ strcmp(di.udi_devnames[i], dev) == 0) {
+ cp = calloc( 1, strlen(di.udi_vendor) + strlen(di.udi_product) + 2);
+ strcpy(cp, di.udi_vendor);
+ strcat(cp, " ");
+ strcat(cp, di.udi_product);
+ strncpy(out, cp, outlen - 1);
+ out[outlen - 1] = 0;
+ free( cp );
+ return out;
+ }
+ }
+#endif
+ return NULL;
+}
+
+static int fghJoystickFindUSBdev(char *name, char *out, int outlen)
+{
+ int i, f;
+ char buf[50];
+ char *cp;
+ static int protection_warned = 0;
+
+ for (i = 0; i < 16; i++) {
+ snprintf(buf, sizeof(buf), "%s%d", USBDEV, i);
+ f = open(buf, O_RDONLY);
+ if (f >= 0) {
+ cp = fghJoystickWalkUSBdev(f, name, out, outlen);
+ close(f);
+ if (cp)
+ return 1;
+ }
+ else if (errno == EACCES) {
+ if (!protection_warned) {
+ fgWarning ( "Can't open %s for read!", buf );
+ protection_warned = 1;
+ }
+ }
+ }
+ return 0;
+}
+
+static int fghJoystickInitializeHID(struct os_specific_s *os,
+ int *num_axes, int *num_buttons)
+{
+ int size, is_joystick;
+# ifdef HAVE_USBHID_H
+ int report_id = 0;
+# endif
+ struct hid_data *d;
+ struct hid_item h;
+ report_desc_t rd;
+
+ if ( ( rd = hid_get_report_desc( os->fd ) ) == 0 )
+ {
+ fgWarning ( "error: %s: %s", os->fname, strerror( errno ) );
+ return FALSE;
+ }
+
+ os->hids = NULL;
+
+# ifdef HAVE_USBHID_H
+ if( ioctl( os->fd, USB_GET_REPORT_ID, &report_id ) < 0)
+ {
+ /*** XXX {report_id} may not be the right variable? ***/
+ fgWarning ( "error: %s%d: %s", UHIDDEV, report_id, strerror( errno ) );
+ return FALSE;
+ }
+
+ size = hid_report_size( rd, hid_input, report_id );
+# else
+ size = hid_report_size( rd, 0, hid_input );
+# endif
+ os->hid_data_buf = calloc( 1, size );
+ os->hid_dlen = size;
+
+ is_joystick = 0;
+# ifdef HAVE_USBHID_H
+ d = hid_start_parse( rd, 1 << hid_input, report_id );
+# else
+ d = hid_start_parse( rd, 1 << hid_input );
+# endif
+ while( hid_get_item( d, &h ) )
+ {
+ int usage, page, interesting_hid;
+
+ page = HID_PAGE( h.usage );
+ usage = HID_USAGE( h.usage );
+
+ /* This test is somewhat too simplistic, but this is how MicroSoft
+ * does, so I guess it works for all joysticks/game pads. */
+ is_joystick = is_joystick ||
+ ( h.kind == hid_collection &&
+ page == HUP_GENERIC_DESKTOP &&
+ ( usage == HUG_JOYSTICK || usage == HUG_GAME_PAD ) );
+
+ if( h.kind != hid_input )
+ continue;
+
+ if( !is_joystick )
+ continue;
+
+ interesting_hid = TRUE;
+ if( page == HUP_GENERIC_DESKTOP )
+ {
+ switch( usage )
+ {
+ case HUG_X:
+ case HUG_RX:
+ case HUG_Y:
+ case HUG_RY:
+ case HUG_Z:
+ case HUG_RZ:
+ case HUG_SLIDER:
+ if( *num_axes < _JS_MAX_AXES )
+ {
+ os->axes_usage[ *num_axes ] = usage;
+ ( *num_axes )++;
+ }
+ break;
+ case HUG_HAT_SWITCH:
+ /* Allocate two axes for a hat */
+ if( *num_axes + 1 < _JS_MAX_AXES )
+ {
+ os->axes_usage[ *num_axes ] = usage;
+ (*num_axes)++;
+ os->axes_usage[ *num_axes ] = usage;
+ (*num_axes)++;
+ }
+ break;
+ default:
+ interesting_hid = FALSE;
+ break;
+ }
+ }
+ else if( page == HUP_BUTTON )
+ {
+ interesting_hid = ( usage > 0 ) &&
+ ( usage <= _JS_MAX_BUTTONS );
+
+ if( interesting_hid && usage - 1 > *num_buttons )
+ *num_buttons = usage - 1;
+ }
+
+ if( interesting_hid )
+ {
+ h.next = os->hids;
+ os->hids = calloc( 1, sizeof ( struct hid_item ) );
+ *os->hids = h;
+ }
+ }
+ hid_end_parse( d );
+
+ return os->hids != NULL;
+}
+# endif /* HAVE_USB_JS */
+#endif /* FreeBSD or NetBSD */
+
void fgPlatformJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
{
int status;
@@ -259,7 +436,7 @@ void fgPlatformJoystickOpen( SFG_Joystic
joy->num_axes = 2;
joy->num_buttons = 32;
- fghJoystickRawRead( joy, buttons, axes );
+ fgJoystickRawRead( joy, buttons, axes );
joy->error = axes[ 0 ] < -1000000000.0f;
if( joy->error )
return;
@@ -379,7 +556,7 @@ void fgPlatformJoystickOpen( SFG_Joystic
do
{
- fghJoystickRawRead( joy, NULL, joy->center );
+ fgJoystickRawRead( joy, NULL, joy->center );
counter++;
} while( !joy->error &&
counter < 100 &&