Commit 2337a684b363dfc4ba3d6f2773e029a3301cfdad

Sam Lantinga 2013-10-13T19:49:45

Fixed bug 2149 - Don't search for libusbhid except on BSD Joseph Carter There's a whole set of configure tests for BSD's libusbhid, and they only matter on BSD. However, if you have the library on Linux, it gets pulled in as library bloat. And it's bloat of the highest order since not a single function call to the library is ever made unless you're on a *BSD.

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
diff --git a/configure b/configure
index dae19ac..ba24894 100755
--- a/configure
+++ b/configure
@@ -21634,8 +21634,10 @@ $as_echo "#define SDL_LOADSO_DLOPEN 1" >>confdefs.h
 
 CheckUSBHID()
 {
-    if test x$enable_joystick = xyes; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusbhid" >&5
+    case "$host" in
+        *-*-*bsd*)
+            if test x$enable_joystick = xyes; then
+                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusbhid" >&5
 $as_echo_n "checking for hid_init in -lusbhid... " >&6; }
 if ${ac_cv_lib_usbhid_hid_init+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -21675,34 +21677,34 @@ if test "x$ac_cv_lib_usbhid_hid_init" = xyes; then :
   have_libusbhid=yes
 fi
 
-        if test x$have_libusbhid = xyes; then
-            ac_fn_c_check_header_mongrel "$LINENO" "usbhid.h" "ac_cv_header_usbhid_h" "$ac_includes_default"
+                if test x$have_libusbhid = xyes; then
+                    ac_fn_c_check_header_mongrel "$LINENO" "usbhid.h" "ac_cv_header_usbhid_h" "$ac_includes_default"
 if test "x$ac_cv_header_usbhid_h" = xyes; then :
   USB_CFLAGS="-DHAVE_USBHID_H"
 fi
 
 
-            ac_fn_c_check_header_mongrel "$LINENO" "libusbhid.h" "ac_cv_header_libusbhid_h" "$ac_includes_default"
+                    ac_fn_c_check_header_mongrel "$LINENO" "libusbhid.h" "ac_cv_header_libusbhid_h" "$ac_includes_default"
 if test "x$ac_cv_header_libusbhid_h" = xyes; then :
   USB_CFLAGS="-DHAVE_LIBUSBHID_H"
 fi
 
 
-            USB_LIBS="$USB_LIBS -lusbhid"
-        else
-            ac_fn_c_check_header_mongrel "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default"
+                    USB_LIBS="$USB_LIBS -lusbhid"
+                else
+                    ac_fn_c_check_header_mongrel "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default"
 if test "x$ac_cv_header_usb_h" = xyes; then :
   USB_CFLAGS="-DHAVE_USB_H"
 fi
 
 
-            ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default"
+                    ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default"
 if test "x$ac_cv_header_libusb_h" = xyes; then :
   USB_CFLAGS="-DHAVE_LIBUSB_H"
 fi
 
 
-            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusb" >&5
+                    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusb" >&5
 $as_echo_n "checking for hid_init in -lusb... " >&6; }
 if ${ac_cv_lib_usb_hid_init+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -21742,43 +21744,43 @@ if test "x$ac_cv_lib_usb_hid_init" = xyes; then :
   USB_LIBS="$USB_LIBS -lusb"
 fi
 
-        fi
+                fi
 
-        save_CFLAGS="$CFLAGS"
-        CFLAGS="$CFLAGS $USB_CFLAGS"
+                save_CFLAGS="$CFLAGS"
+                CFLAGS="$CFLAGS $USB_CFLAGS"
 
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usbhid" >&5
+                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usbhid" >&5
 $as_echo_n "checking for usbhid... " >&6; }
-        have_usbhid=no
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+                have_usbhid=no
+                cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-          #include <sys/types.h>
-          #if defined(HAVE_USB_H)
-          #include <usb.h>
-          #endif
-          #ifdef __DragonFly__
-          # include <bus/usb/usb.h>
-          # include <bus/usb/usbhid.h>
-          #else
-          # include <dev/usb/usb.h>
-          # include <dev/usb/usbhid.h>
-          #endif
-          #if defined(HAVE_USBHID_H)
-          #include <usbhid.h>
-          #elif defined(HAVE_LIBUSB_H)
-          #include <libusb.h>
-          #elif defined(HAVE_LIBUSBHID_H)
-          #include <libusbhid.h>
-          #endif
+                  #include <sys/types.h>
+                  #if defined(HAVE_USB_H)
+                  #include <usb.h>
+                  #endif
+                  #ifdef __DragonFly__
+                  # include <bus/usb/usb.h>
+                  # include <bus/usb/usbhid.h>
+                  #else
+                  # include <dev/usb/usb.h>
+                  # include <dev/usb/usbhid.h>
+                  #endif
+                  #if defined(HAVE_USBHID_H)
+                  #include <usbhid.h>
+                  #elif defined(HAVE_LIBUSB_H)
+                  #include <libusb.h>
+                  #elif defined(HAVE_LIBUSBHID_H)
+                  #include <libusbhid.h>
+                  #endif
 
 int
 main ()
 {
 
-          struct report_desc *repdesc;
-          struct usb_ctl_report *repbuf;
-          hid_kind_t hidkind;
+                  struct report_desc *repdesc;
+                  struct usb_ctl_report *repbuf;
+                  hid_kind_t hidkind;
 
   ;
   return 0;
@@ -21786,45 +21788,45 @@ main ()
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
 
-        have_usbhid=yes
+                have_usbhid=yes
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid" >&5
+                { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid" >&5
 $as_echo "$have_usbhid" >&6; }
 
-        if test x$have_usbhid = xyes; then
-            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ucr_data member of usb_ctl_report" >&5
+                if test x$have_usbhid = xyes; then
+                    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ucr_data member of usb_ctl_report" >&5
 $as_echo_n "checking for ucr_data member of usb_ctl_report... " >&6; }
-            have_usbhid_ucr_data=no
-            cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+                    have_usbhid_ucr_data=no
+                    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-              #include <sys/types.h>
-              #if defined(HAVE_USB_H)
-              #include <usb.h>
-              #endif
-              #ifdef __DragonFly__
-              # include <bus/usb/usb.h>
-              # include <bus/usb/usbhid.h>
-              #else
-              # include <dev/usb/usb.h>
-              # include <dev/usb/usbhid.h>
-              #endif
-              #if defined(HAVE_USBHID_H)
-              #include <usbhid.h>
-              #elif defined(HAVE_LIBUSB_H)
-              #include <libusb.h>
-              #elif defined(HAVE_LIBUSBHID_H)
-              #include <libusbhid.h>
-              #endif
+                      #include <sys/types.h>
+                      #if defined(HAVE_USB_H)
+                      #include <usb.h>
+                      #endif
+                      #ifdef __DragonFly__
+                      # include <bus/usb/usb.h>
+                      # include <bus/usb/usbhid.h>
+                      #else
+                      # include <dev/usb/usb.h>
+                      # include <dev/usb/usbhid.h>
+                      #endif
+                      #if defined(HAVE_USBHID_H)
+                      #include <usbhid.h>
+                      #elif defined(HAVE_LIBUSB_H)
+                      #include <libusb.h>
+                      #elif defined(HAVE_LIBUSBHID_H)
+                      #include <libusbhid.h>
+                      #endif
 
 int
 main ()
 {
 
-              struct usb_ctl_report buf;
-              if (buf.ucr_data) { }
+                      struct usb_ctl_report buf;
+                      if (buf.ucr_data) { }
 
   ;
   return 0;
@@ -21832,47 +21834,47 @@ main ()
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
 
-            have_usbhid_ucr_data=yes
+                    have_usbhid_ucr_data=yes
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-            if test x$have_usbhid_ucr_data = xyes; then
-                USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
-            fi
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_ucr_data" >&5
+                    if test x$have_usbhid_ucr_data = xyes; then
+                        USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
+                    fi
+                    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_ucr_data" >&5
 $as_echo "$have_usbhid_ucr_data" >&6; }
 
-            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for new usbhid API" >&5
+                    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for new usbhid API" >&5
 $as_echo_n "checking for new usbhid API... " >&6; }
-            have_usbhid_new=no
-            cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+                    have_usbhid_new=no
+                    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-              #include <sys/types.h>
-              #if defined(HAVE_USB_H)
-              #include <usb.h>
-              #endif
-              #ifdef __DragonFly__
-              #include <bus/usb/usb.h>
-              #include <bus/usb/usbhid.h>
-              #else
-              #include <dev/usb/usb.h>
-              #include <dev/usb/usbhid.h>
-              #endif
-              #if defined(HAVE_USBHID_H)
-              #include <usbhid.h>
-              #elif defined(HAVE_LIBUSB_H)
-              #include <libusb.h>
-              #elif defined(HAVE_LIBUSBHID_H)
-              #include <libusbhid.h>
-              #endif
+                      #include <sys/types.h>
+                      #if defined(HAVE_USB_H)
+                      #include <usb.h>
+                      #endif
+                      #ifdef __DragonFly__
+                      #include <bus/usb/usb.h>
+                      #include <bus/usb/usbhid.h>
+                      #else
+                      #include <dev/usb/usb.h>
+                      #include <dev/usb/usbhid.h>
+                      #endif
+                      #if defined(HAVE_USBHID_H)
+                      #include <usbhid.h>
+                      #elif defined(HAVE_LIBUSB_H)
+                      #include <libusb.h>
+                      #elif defined(HAVE_LIBUSBHID_H)
+                      #include <libusbhid.h>
+                      #endif
 
 int
 main ()
 {
 
-              report_desc_t d;
-              hid_start_parse(d, 1, 1);
+                      report_desc_t d;
+                      hid_start_parse(d, 1, 1);
 
   ;
   return 0;
@@ -21880,29 +21882,29 @@ main ()
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
 
-            have_usbhid_new=yes
+                    have_usbhid_new=yes
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-            if test x$have_usbhid_new = xyes; then
-                USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
-            fi
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_new" >&5
+                    if test x$have_usbhid_new = xyes; then
+                        USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
+                    fi
+                    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_new" >&5
 $as_echo "$have_usbhid_new" >&6; }
 
-            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct joystick in machine/joystick.h" >&5
+                    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct joystick in machine/joystick.h" >&5
 $as_echo_n "checking for struct joystick in machine/joystick.h... " >&6; }
-            have_machine_joystick=no
-            cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+                    have_machine_joystick=no
+                    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-              #include <machine/joystick.h>
+                      #include <machine/joystick.h>
 
 int
 main ()
 {
 
-              struct joystick t;
+                      struct joystick t;
 
   ;
   return 0;
@@ -21910,28 +21912,30 @@ main ()
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
 
-            have_machine_joystick=yes
+                    have_machine_joystick=yes
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-            if test x$have_machine_joystick = xyes; then
+                    if test x$have_machine_joystick = xyes; then
 
 $as_echo "#define SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H 1" >>confdefs.h
 
-            fi
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_machine_joystick" >&5
+                    fi
+                    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_machine_joystick" >&5
 $as_echo "$have_machine_joystick" >&6; }
 
 
 $as_echo "#define SDL_JOYSTICK_USBHID 1" >>confdefs.h
 
-            SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
-            EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
-            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
-            have_joystick=yes
-        fi
-        CFLAGS="$save_CFLAGS"
-    fi
+                    SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
+                    EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
+                    EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
+                    have_joystick=yes
+                fi
+                CFLAGS="$save_CFLAGS"
+            fi
+        ;;
+    esac
 }
 
 CheckClockGettime()
diff --git a/configure.in b/configure.in
index 890503c..5c56f00 100644
--- a/configure.in
+++ b/configure.in
@@ -2189,138 +2189,142 @@ AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[de
 dnl Check for the usbhid(3) library on *BSD
 CheckUSBHID()
 {
-    if test x$enable_joystick = xyes; then
-        AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
-        if test x$have_libusbhid = xyes; then
-            AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
-            AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
-            USB_LIBS="$USB_LIBS -lusbhid"
-        else
-            AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
-            AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
-            AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
-        fi
-            
-        save_CFLAGS="$CFLAGS"
-        CFLAGS="$CFLAGS $USB_CFLAGS"
-
-        AC_MSG_CHECKING(for usbhid)
-        have_usbhid=no
-        AC_TRY_COMPILE([
-          #include <sys/types.h>
-          #if defined(HAVE_USB_H)
-          #include <usb.h>
-          #endif
-          #ifdef __DragonFly__
-          # include <bus/usb/usb.h>
-          # include <bus/usb/usbhid.h>
-          #else
-          # include <dev/usb/usb.h>
-          # include <dev/usb/usbhid.h>
-          #endif
-          #if defined(HAVE_USBHID_H)
-          #include <usbhid.h>
-          #elif defined(HAVE_LIBUSB_H)
-          #include <libusb.h>
-          #elif defined(HAVE_LIBUSBHID_H)
-          #include <libusbhid.h>
-          #endif
-        ],[
-          struct report_desc *repdesc;
-          struct usb_ctl_report *repbuf;
-          hid_kind_t hidkind;
-        ],[
-        have_usbhid=yes
-        ])
-        AC_MSG_RESULT($have_usbhid)
+    case "$host" in
+        *-*-*bsd*)
+            if test x$enable_joystick = xyes; then
+                AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
+                if test x$have_libusbhid = xyes; then
+                    AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
+                    AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
+                    USB_LIBS="$USB_LIBS -lusbhid"
+                else
+                    AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
+                    AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
+                    AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
+                fi
+                    
+                save_CFLAGS="$CFLAGS"
+                CFLAGS="$CFLAGS $USB_CFLAGS"
 
-        if test x$have_usbhid = xyes; then
-            AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
-            have_usbhid_ucr_data=no
-            AC_TRY_COMPILE([
-              #include <sys/types.h>
-              #if defined(HAVE_USB_H)
-              #include <usb.h>
-              #endif
-              #ifdef __DragonFly__
-              # include <bus/usb/usb.h>
-              # include <bus/usb/usbhid.h>
-              #else
-              # include <dev/usb/usb.h>
-              # include <dev/usb/usbhid.h>
-              #endif
-              #if defined(HAVE_USBHID_H)
-              #include <usbhid.h>
-              #elif defined(HAVE_LIBUSB_H)
-              #include <libusb.h>
-              #elif defined(HAVE_LIBUSBHID_H)
-              #include <libusbhid.h>
-              #endif
-            ],[
-              struct usb_ctl_report buf;
-              if (buf.ucr_data) { }
-            ],[
-            have_usbhid_ucr_data=yes
-            ])
-            if test x$have_usbhid_ucr_data = xyes; then
-                USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
-            fi
-            AC_MSG_RESULT($have_usbhid_ucr_data)
-            
-            AC_MSG_CHECKING(for new usbhid API)
-            have_usbhid_new=no
-            AC_TRY_COMPILE([
-              #include <sys/types.h>
-              #if defined(HAVE_USB_H)
-              #include <usb.h>
-              #endif
-              #ifdef __DragonFly__
-              #include <bus/usb/usb.h>
-              #include <bus/usb/usbhid.h>
-              #else
-              #include <dev/usb/usb.h>
-              #include <dev/usb/usbhid.h>
-              #endif
-              #if defined(HAVE_USBHID_H)
-              #include <usbhid.h>
-              #elif defined(HAVE_LIBUSB_H)
-              #include <libusb.h>
-              #elif defined(HAVE_LIBUSBHID_H)
-              #include <libusbhid.h>
-              #endif
-            ],[
-              report_desc_t d;
-              hid_start_parse(d, 1, 1);
-            ],[
-            have_usbhid_new=yes
-            ])
-            if test x$have_usbhid_new = xyes; then
-                USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
-            fi
-            AC_MSG_RESULT($have_usbhid_new)
+                AC_MSG_CHECKING(for usbhid)
+                have_usbhid=no
+                AC_TRY_COMPILE([
+                  #include <sys/types.h>
+                  #if defined(HAVE_USB_H)
+                  #include <usb.h>
+                  #endif
+                  #ifdef __DragonFly__
+                  # include <bus/usb/usb.h>
+                  # include <bus/usb/usbhid.h>
+                  #else
+                  # include <dev/usb/usb.h>
+                  # include <dev/usb/usbhid.h>
+                  #endif
+                  #if defined(HAVE_USBHID_H)
+                  #include <usbhid.h>
+                  #elif defined(HAVE_LIBUSB_H)
+                  #include <libusb.h>
+                  #elif defined(HAVE_LIBUSBHID_H)
+                  #include <libusbhid.h>
+                  #endif
+                ],[
+                  struct report_desc *repdesc;
+                  struct usb_ctl_report *repbuf;
+                  hid_kind_t hidkind;
+                ],[
+                have_usbhid=yes
+                ])
+                AC_MSG_RESULT($have_usbhid)
+
+                if test x$have_usbhid = xyes; then
+                    AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
+                    have_usbhid_ucr_data=no
+                    AC_TRY_COMPILE([
+                      #include <sys/types.h>
+                      #if defined(HAVE_USB_H)
+                      #include <usb.h>
+                      #endif
+                      #ifdef __DragonFly__
+                      # include <bus/usb/usb.h>
+                      # include <bus/usb/usbhid.h>
+                      #else
+                      # include <dev/usb/usb.h>
+                      # include <dev/usb/usbhid.h>
+                      #endif
+                      #if defined(HAVE_USBHID_H)
+                      #include <usbhid.h>
+                      #elif defined(HAVE_LIBUSB_H)
+                      #include <libusb.h>
+                      #elif defined(HAVE_LIBUSBHID_H)
+                      #include <libusbhid.h>
+                      #endif
+                    ],[
+                      struct usb_ctl_report buf;
+                      if (buf.ucr_data) { }
+                    ],[
+                    have_usbhid_ucr_data=yes
+                    ])
+                    if test x$have_usbhid_ucr_data = xyes; then
+                        USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
+                    fi
+                    AC_MSG_RESULT($have_usbhid_ucr_data)
+                    
+                    AC_MSG_CHECKING(for new usbhid API)
+                    have_usbhid_new=no
+                    AC_TRY_COMPILE([
+                      #include <sys/types.h>
+                      #if defined(HAVE_USB_H)
+                      #include <usb.h>
+                      #endif
+                      #ifdef __DragonFly__
+                      #include <bus/usb/usb.h>
+                      #include <bus/usb/usbhid.h>
+                      #else
+                      #include <dev/usb/usb.h>
+                      #include <dev/usb/usbhid.h>
+                      #endif
+                      #if defined(HAVE_USBHID_H)
+                      #include <usbhid.h>
+                      #elif defined(HAVE_LIBUSB_H)
+                      #include <libusb.h>
+                      #elif defined(HAVE_LIBUSBHID_H)
+                      #include <libusbhid.h>
+                      #endif
+                    ],[
+                      report_desc_t d;
+                      hid_start_parse(d, 1, 1);
+                    ],[
+                    have_usbhid_new=yes
+                    ])
+                    if test x$have_usbhid_new = xyes; then
+                        USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
+                    fi
+                    AC_MSG_RESULT($have_usbhid_new)
+
+                    AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
+                    have_machine_joystick=no
+                    AC_TRY_COMPILE([
+                      #include <machine/joystick.h>
+                    ],[
+                      struct joystick t;
+                    ],[
+                    have_machine_joystick=yes
+                    ])
+                    if test x$have_machine_joystick = xyes; then
+                        AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H, 1, [ ])
+                    fi
+                    AC_MSG_RESULT($have_machine_joystick)
 
-            AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
-            have_machine_joystick=no
-            AC_TRY_COMPILE([
-              #include <machine/joystick.h>
-            ],[
-              struct joystick t;
-            ],[
-            have_machine_joystick=yes
-            ])
-            if test x$have_machine_joystick = xyes; then
-                AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H, 1, [ ])
+                    AC_DEFINE(SDL_JOYSTICK_USBHID, 1, [ ])
+                    SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
+                    EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
+                    EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
+                    have_joystick=yes
+                fi
+                CFLAGS="$save_CFLAGS"
             fi
-            AC_MSG_RESULT($have_machine_joystick)
-
-            AC_DEFINE(SDL_JOYSTICK_USBHID, 1, [ ])
-            SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
-            EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
-            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
-            have_joystick=yes
-        fi
-        CFLAGS="$save_CFLAGS"
-    fi
+        ;;
+    esac
 }
 
 dnl Check for clock_gettime()
diff --git a/test/configure b/test/configure
index 57da554..94a2f13 100755
--- a/test/configure
+++ b/test/configure
@@ -586,8 +586,8 @@ ac_subst_vars='LTLIBOBJS
 LIBOBJS
 SDL_TTF_LIB
 XLIB
-GLLIB
 GLESLIB
+GLLIB
 CPP
 XMKMF
 SDL_CONFIG
@@ -3874,6 +3874,7 @@ fi
 
 
 
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TTF_Init in -lSDL2_ttf" >&5
 $as_echo_n "checking for TTF_Init in -lSDL2_ttf... " >&6; }
 if ${ac_cv_lib_SDL2_ttf_TTF_Init+:} false; then :