1 |
commit: b50fc04a3397c0d43f97e3ffc852e1066790d1b1 |
2 |
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Mar 27 19:53:18 2019 +0000 |
4 |
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Mar 27 19:54:01 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b50fc04a |
7 |
|
8 |
media-libs/freeglut: Pull in BSD support patches from upstream |
9 |
|
10 |
Closes: https://bugs.gentoo.org/544614 |
11 |
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org> |
12 |
|
13 |
.../files/freeglut-3.0.0-bsd-usb-joystick.patch | 753 +++++++++++++++++++++ |
14 |
media-libs/freeglut/freeglut-3.0.0.ebuild | 1 + |
15 |
2 files changed, 754 insertions(+) |
16 |
|
17 |
diff --git a/media-libs/freeglut/files/freeglut-3.0.0-bsd-usb-joystick.patch b/media-libs/freeglut/files/freeglut-3.0.0-bsd-usb-joystick.patch |
18 |
new file mode 100644 |
19 |
index 00000000000..505b3467ec4 |
20 |
--- /dev/null |
21 |
+++ b/media-libs/freeglut/files/freeglut-3.0.0-bsd-usb-joystick.patch |
22 |
@@ -0,0 +1,753 @@ |
23 |
+From 5908c36a4a3964cdc8db5c7bfdfd4381ec0996df Mon Sep 17 00:00:00 2001 |
24 |
+From: dcnieho <dcnieho@7f0cb862-5218-0410-a997-914c9d46530a> |
25 |
+Date: Wed, 12 Jul 2017 20:44:35 +0000 |
26 |
+Subject: [PATCH] Fix build on NetBSD. |
27 |
+ |
28 |
+(cherry picked from commit 06e1d815cf9abda49b845754ff420734446eb95b) |
29 |
+ |
30 |
+(cherry picked from commit c4294ad59093c27159ea6028d33e3c9581df5354) |
31 |
+ |
32 |
+git-svn-id: http://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1829 7f0cb862-5218-0410-a997-914c9d46530a |
33 |
+--- |
34 |
+ src/fg_joystick.c | 5 ++--- |
35 |
+ src/x11/fg_joystick_x11.c | 10 +++++----- |
36 |
+ 2 files changed, 7 insertions(+), 8 deletions(-) |
37 |
+ |
38 |
+diff --git a/src/fg_joystick.c b/src/fg_joystick.c |
39 |
+index 6f6771c..b73d7e7 100644 |
40 |
+--- a/src/fg_joystick.c |
41 |
++++ b/src/fg_joystick.c |
42 |
+@@ -46,21 +46,20 @@ |
43 |
+ |
44 |
+ # ifdef HAVE_USB_JS |
45 |
+ # if defined(__NetBSD__) |
46 |
+-/* XXX The below hack is done until freeglut's autoconf is updated. */ |
47 |
+-# define HAVE_USBHID_H 1 |
48 |
+ # ifdef HAVE_USBHID_H |
49 |
+ # include <usbhid.h> |
50 |
+ # else |
51 |
+ # include <usb.h> |
52 |
+ # endif |
53 |
++# include <dev/usb/usb.h> |
54 |
+ # elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) |
55 |
+ # ifdef HAVE_USBHID_H |
56 |
+ # include <usbhid.h> |
57 |
+ # else |
58 |
+ # include <libusbhid.h> |
59 |
+ # endif |
60 |
++# include <legacy/dev/usb/usb.h> |
61 |
+ # endif |
62 |
+-# include <legacy/dev/usb/usb.h> |
63 |
+ # include <dev/usb/usbhid.h> |
64 |
+ |
65 |
+ /* Compatibility with older usb.h revisions */ |
66 |
+diff --git a/src/x11/fg_joystick_x11.c b/src/x11/fg_joystick_x11.c |
67 |
+index a37388b..04bc373 100644 |
68 |
+--- a/src/x11/fg_joystick_x11.c |
69 |
++++ b/src/x11/fg_joystick_x11.c |
70 |
+@@ -50,7 +50,7 @@ void fgPlatformJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes ) |
71 |
+ { |
72 |
+ int status; |
73 |
+ |
74 |
+-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) |
75 |
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) |
76 |
+ int len; |
77 |
+ |
78 |
+ if ( joy->pJoystick.os->is_analog ) |
79 |
+@@ -215,7 +215,7 @@ void fgPlatformJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes ) |
80 |
+ |
81 |
+ void fgPlatformJoystickOpen( SFG_Joystick* joy ) |
82 |
+ { |
83 |
+-#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ ) |
84 |
++#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) |
85 |
+ int i = 0; |
86 |
+ char *cp; |
87 |
+ #endif |
88 |
+@@ -229,7 +229,7 @@ void fgPlatformJoystickOpen( SFG_Joystick* joy ) |
89 |
+ # endif |
90 |
+ #endif |
91 |
+ |
92 |
+-#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ ) |
93 |
++#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) |
94 |
+ for( i = 0; i < _JS_MAX_AXES; i++ ) |
95 |
+ joy->pJoystick.os->cache_axes[ i ] = 0.0f; |
96 |
+ |
97 |
+@@ -409,7 +409,7 @@ void fgPlatformJoystickOpen( SFG_Joystick* joy ) |
98 |
+ |
99 |
+ void fgPlatformJoystickInit( SFG_Joystick *fgJoystick[], int ident ) |
100 |
+ { |
101 |
+-#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ ) |
102 |
++#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) |
103 |
+ fgJoystick[ ident ]->id = ident; |
104 |
+ fgJoystick[ ident ]->error = GL_FALSE; |
105 |
+ |
106 |
+@@ -436,7 +436,7 @@ void fgPlatformJoystickInit( SFG_Joystick *fgJoystick[], int ident ) |
107 |
+ |
108 |
+ void fgPlatformJoystickClose ( int ident ) |
109 |
+ { |
110 |
+-#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ ) |
111 |
++#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) |
112 |
+ if( fgJoystick[ident]->pJoystick.os ) |
113 |
+ { |
114 |
+ if( ! fgJoystick[ ident ]->error ) |
115 |
+-- |
116 |
+2.19.2 |
117 |
+ |
118 |
+From c0f0f1e0903a5dd848825db0fe1f01d5db37c4e1 Mon Sep 17 00:00:00 2001 |
119 |
+From: dcnieho <dcnieho@7f0cb862-5218-0410-a997-914c9d46530a> |
120 |
+Date: Wed, 12 Jul 2017 20:44:47 +0000 |
121 |
+Subject: [PATCH] some whitespace cleanup |
122 |
+ |
123 |
+(cherry picked from commit 2dd5aa4aa1b5c19392f9abd00e0f6893907df205) |
124 |
+ |
125 |
+git-svn-id: http://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1830 7f0cb862-5218-0410-a997-914c9d46530a |
126 |
+--- |
127 |
+ src/fg_init.c | 32 ++-- |
128 |
+ src/fg_joystick.c | 8 +- |
129 |
+ src/fg_main.c | 14 +- |
130 |
+ src/freeglutdll.def.in | 312 +++++++++++++++++----------------- |
131 |
+ src/mswin/fg_joystick_mswin.c | 2 +- |
132 |
+ src/mswin/fg_main_mswin.c | 160 ++++++++--------- |
133 |
+ 6 files changed, 264 insertions(+), 264 deletions(-) |
134 |
+ |
135 |
+diff --git a/src/fg_joystick.c b/src/fg_joystick.c |
136 |
+index b73d7e7..2f4f6ed 100644 |
137 |
+--- a/src/fg_joystick.c |
138 |
++++ b/src/fg_joystick.c |
139 |
+@@ -581,7 +581,7 @@ void fgPlatformJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes ) |
140 |
+ |
141 |
+ void fgPlatformJoystickOpen( SFG_Joystick* joy ) |
142 |
+ { |
143 |
+- int i = 0; |
144 |
++ int i = 0; |
145 |
+ OSStatus err; |
146 |
+ |
147 |
+ /* XXX FIXME: get joystick name in Mac */ |
148 |
+@@ -856,7 +856,7 @@ static void fghJoystickOpen( SFG_Joystick* joy ) |
149 |
+ joy->num_axes = joy->num_buttons = 0; |
150 |
+ joy->name[ 0 ] = '\0'; |
151 |
+ |
152 |
+- fgPlatformJoystickOpen ( joy ); |
153 |
++ fgPlatformJoystickOpen ( joy ); |
154 |
+ |
155 |
+ } |
156 |
+ |
157 |
+@@ -878,7 +878,7 @@ static void fghJoystickInit( int ident ) |
158 |
+ fgJoystick[ ident ]->num_axes = fgJoystick[ ident ]->num_buttons = 0; |
159 |
+ fgJoystick[ ident ]->error = GL_TRUE; |
160 |
+ |
161 |
+- fgPlatformJoystickInit( fgJoystick, ident ); |
162 |
++ fgPlatformJoystickInit( fgJoystick, ident ); |
163 |
+ |
164 |
+ fghJoystickOpen( fgJoystick[ ident ] ); |
165 |
+ } |
166 |
+@@ -906,7 +906,7 @@ void fgJoystickClose( void ) |
167 |
+ { |
168 |
+ if( fgJoystick[ ident ] ) |
169 |
+ { |
170 |
+- fgPlatformJoystickClose ( ident ); |
171 |
++ fgPlatformJoystickClose ( ident ); |
172 |
+ |
173 |
+ free( fgJoystick[ ident ] ); |
174 |
+ fgJoystick[ ident ] = NULL; |
175 |
+-- |
176 |
+2.19.2 |
177 |
+ |
178 |
+From 6096caf2468ad4557968b9156ea9fcab2efb3fd1 Mon Sep 17 00:00:00 2001 |
179 |
+From: dcnieho <dcnieho@7f0cb862-5218-0410-a997-914c9d46530a> |
180 |
+Date: Wed, 12 Jul 2017 20:45:07 +0000 |
181 |
+Subject: [PATCH] moved static variables and functions that should not have |
182 |
+ stuck behind in fg_joystick.c, but should have been in fg_joystick_x11.c |
183 |
+ |
184 |
+(cherry picked from commit 0d98472817921dc95d070f13bba59b72d792a7b2) |
185 |
+ |
186 |
+git-svn-id: http://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1832 7f0cb862-5218-0410-a997-914c9d46530a |
187 |
+--- |
188 |
+ src/fg_joystick.c | 173 ---------------------------------- |
189 |
+ src/x11/fg_joystick_x11.c | 190 +++++++++++++++++++++++++++++++++++++- |
190 |
+ 2 files changed, 185 insertions(+), 178 deletions(-) |
191 |
+ |
192 |
+diff --git a/src/fg_joystick.c b/src/fg_joystick.c |
193 |
+index 2f4f6ed..e548c04 100644 |
194 |
+--- a/src/fg_joystick.c |
195 |
++++ b/src/fg_joystick.c |
196 |
+@@ -68,8 +68,6 @@ |
197 |
+ # endif |
198 |
+ # endif |
199 |
+ |
200 |
+-static int hatmap_x[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 }; |
201 |
+-static int hatmap_y[9] = { 0, 1, 1, 0, -1, -1, -1, 0, 1 }; |
202 |
+ struct os_specific_s { |
203 |
+ char fname [128 ]; |
204 |
+ int fd; |
205 |
+@@ -98,178 +96,7 @@ struct os_specific_s { |
206 |
+ # define UHIDDEV "/dev/uhid" |
207 |
+ # define AJSDEV "/dev/joy" |
208 |
+ |
209 |
+-# ifdef HAVE_USB_JS |
210 |
+-/* |
211 |
+- * fghJoystickFindUSBdev (and its helper, fghJoystickWalkUSBdev) try to locate |
212 |
+- * the full name of a USB device. If /dev/usbN isn't readable, we punt and |
213 |
+- * return the uhidN device name. We warn the user of this situation once. |
214 |
+- */ |
215 |
+-static char *fghJoystickWalkUSBdev(int f, char *dev, char *out, int outlen) |
216 |
+-{ |
217 |
+- struct usb_device_info di; |
218 |
+- int i, a; |
219 |
+- char *cp; |
220 |
+- |
221 |
+- for (a = 1; a < USB_MAX_DEVICES; a++) { |
222 |
+- di.udi_addr = a; |
223 |
+- if (ioctl(f, USB_DEVICEINFO, &di) != 0) |
224 |
+- return NULL; |
225 |
+- for (i = 0; i < USB_MAX_DEVNAMES; i++) |
226 |
+- if (di.udi_devnames[i][0] && |
227 |
+- strcmp(di.udi_devnames[i], dev) == 0) { |
228 |
+- cp = calloc( 1, strlen(di.udi_vendor) + strlen(di.udi_product) + 2); |
229 |
+- strcpy(cp, di.udi_vendor); |
230 |
+- strcat(cp, " "); |
231 |
+- strcat(cp, di.udi_product); |
232 |
+- strncpy(out, cp, outlen - 1); |
233 |
+- out[outlen - 1] = 0; |
234 |
+- free( cp ); |
235 |
+- return out; |
236 |
+- } |
237 |
+- } |
238 |
+- return NULL; |
239 |
+-} |
240 |
+- |
241 |
+-static int fghJoystickFindUSBdev(char *name, char *out, int outlen) |
242 |
+-{ |
243 |
+- int i, f; |
244 |
+- char buf[50]; |
245 |
+- char *cp; |
246 |
+- static int protection_warned = 0; |
247 |
+- |
248 |
+- for (i = 0; i < 16; i++) { |
249 |
+- snprintf(buf, sizeof(buf), "%s%d", USBDEV, i); |
250 |
+- f = open(buf, O_RDONLY); |
251 |
+- if (f >= 0) { |
252 |
+- cp = fghJoystickWalkUSBdev(f, name, out, outlen); |
253 |
+- close(f); |
254 |
+- if (cp) |
255 |
+- return 1; |
256 |
+- } |
257 |
+- else if (errno == EACCES) { |
258 |
+- if (!protection_warned) { |
259 |
+- fgWarning ( "Can't open %s for read!", buf ); |
260 |
+- protection_warned = 1; |
261 |
+- } |
262 |
+- } |
263 |
+- } |
264 |
+- return 0; |
265 |
+-} |
266 |
+ |
267 |
+-static int fghJoystickInitializeHID(struct os_specific_s *os, |
268 |
+- int *num_axes, int *num_buttons) |
269 |
+-{ |
270 |
+- int size, is_joystick; |
271 |
+-# ifdef HAVE_USBHID_H |
272 |
+- int report_id = 0; |
273 |
+-# endif |
274 |
+- struct hid_data *d; |
275 |
+- struct hid_item h; |
276 |
+- report_desc_t rd; |
277 |
+- |
278 |
+- if ( ( rd = hid_get_report_desc( os->fd ) ) == 0 ) |
279 |
+- { |
280 |
+- fgWarning ( "error: %s: %s", os->fname, strerror( errno ) ); |
281 |
+- return FALSE; |
282 |
+- } |
283 |
+- |
284 |
+- os->hids = NULL; |
285 |
+- |
286 |
+-# ifdef HAVE_USBHID_H |
287 |
+- if( ioctl( os->fd, USB_GET_REPORT_ID, &report_id ) < 0) |
288 |
+- { |
289 |
+- /*** XXX {report_id} may not be the right variable? ***/ |
290 |
+- fgWarning ( "error: %s%d: %s", UHIDDEV, report_id, strerror( errno ) ); |
291 |
+- return FALSE; |
292 |
+- } |
293 |
+- |
294 |
+- size = hid_report_size( rd, hid_input, report_id ); |
295 |
+-# else |
296 |
+- size = hid_report_size( rd, 0, hid_input ); |
297 |
+-# endif |
298 |
+- os->hid_data_buf = calloc( 1, size ); |
299 |
+- os->hid_dlen = size; |
300 |
+- |
301 |
+- is_joystick = 0; |
302 |
+-# ifdef HAVE_USBHID_H |
303 |
+- d = hid_start_parse( rd, 1 << hid_input, report_id ); |
304 |
+-# else |
305 |
+- d = hid_start_parse( rd, 1 << hid_input ); |
306 |
+-# endif |
307 |
+- while( hid_get_item( d, &h ) ) |
308 |
+- { |
309 |
+- int usage, page, interesting_hid; |
310 |
+- |
311 |
+- page = HID_PAGE( h.usage ); |
312 |
+- usage = HID_USAGE( h.usage ); |
313 |
+- |
314 |
+- /* This test is somewhat too simplistic, but this is how MicroSoft |
315 |
+- * does, so I guess it works for all joysticks/game pads. */ |
316 |
+- is_joystick = is_joystick || |
317 |
+- ( h.kind == hid_collection && |
318 |
+- page == HUP_GENERIC_DESKTOP && |
319 |
+- ( usage == HUG_JOYSTICK || usage == HUG_GAME_PAD ) ); |
320 |
+- |
321 |
+- if( h.kind != hid_input ) |
322 |
+- continue; |
323 |
+- |
324 |
+- if( !is_joystick ) |
325 |
+- continue; |
326 |
+- |
327 |
+- interesting_hid = TRUE; |
328 |
+- if( page == HUP_GENERIC_DESKTOP ) |
329 |
+- { |
330 |
+- switch( usage ) |
331 |
+- { |
332 |
+- case HUG_X: |
333 |
+- case HUG_RX: |
334 |
+- case HUG_Y: |
335 |
+- case HUG_RY: |
336 |
+- case HUG_Z: |
337 |
+- case HUG_RZ: |
338 |
+- case HUG_SLIDER: |
339 |
+- if( *num_axes < _JS_MAX_AXES ) |
340 |
+- { |
341 |
+- os->axes_usage[ *num_axes ] = usage; |
342 |
+- ( *num_axes )++; |
343 |
+- } |
344 |
+- break; |
345 |
+- case HUG_HAT_SWITCH: |
346 |
+- /* Allocate two axes for a hat */ |
347 |
+- if( *num_axes + 1 < _JS_MAX_AXES ) |
348 |
+- { |
349 |
+- os->axes_usage[ *num_axes ] = usage; |
350 |
+- (*num_axes)++; |
351 |
+- os->axes_usage[ *num_axes ] = usage; |
352 |
+- (*num_axes)++; |
353 |
+- } |
354 |
+- break; |
355 |
+- default: |
356 |
+- interesting_hid = FALSE; |
357 |
+- break; |
358 |
+- } |
359 |
+- } |
360 |
+- else if( page == HUP_BUTTON ) |
361 |
+- { |
362 |
+- interesting_hid = ( usage > 0 ) && |
363 |
+- ( usage <= _JS_MAX_BUTTONS ); |
364 |
+- |
365 |
+- if( interesting_hid && usage - 1 > *num_buttons ) |
366 |
+- *num_buttons = usage - 1; |
367 |
+- } |
368 |
+- |
369 |
+- if( interesting_hid ) |
370 |
+- { |
371 |
+- h.next = os->hids; |
372 |
+- os->hids = calloc( 1, sizeof ( struct hid_item ) ); |
373 |
+- *os->hids = h; |
374 |
+- } |
375 |
+- } |
376 |
+- hid_end_parse( d ); |
377 |
+- |
378 |
+- return os->hids != NULL; |
379 |
+-} |
380 |
+-# endif |
381 |
+ #endif |
382 |
+ |
383 |
+ /* |
384 |
+diff --git a/src/x11/fg_joystick_x11.c b/src/x11/fg_joystick_x11.c |
385 |
+index 04bc373..30ad4b5 100644 |
386 |
+--- a/src/x11/fg_joystick_x11.c |
387 |
++++ b/src/x11/fg_joystick_x11.c |
388 |
+@@ -42,8 +42,188 @@ |
389 |
+ #include <fcntl.h> |
390 |
+ |
391 |
+ |
392 |
++#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) |
393 |
++ |
394 |
++static int hatmap_x[9] = {0, 0, 1, 1, 1, 0, -1, -1, -1}; |
395 |
++static int hatmap_y[9] = {0, 1, 1, 0, -1, -1, -1, 0, 1}; |
396 |
++ |
397 |
++# ifdef HAVE_USB_JS |
398 |
++/* |
399 |
++* fghJoystickFindUSBdev (and its helper, fghJoystickWalkUSBdev) try to locate |
400 |
++* the full name of a USB device. If /dev/usbN isn't readable, we punt and |
401 |
++* return the uhidN device name. We warn the user of this situation once. |
402 |
++*/ |
403 |
++static char *fghJoystickWalkUSBdev(int f, char *dev, char *out, int outlen) |
404 |
++{ |
405 |
++ struct usb_device_info di; |
406 |
++ int i, a; |
407 |
++ char *cp; |
408 |
++ |
409 |
++ for (a = 1; a < USB_MAX_DEVICES; a++) { |
410 |
++ di.udi_addr = a; |
411 |
++ if (ioctl(f, USB_DEVICEINFO, &di) != 0) |
412 |
++ return NULL; |
413 |
++ for (i = 0; i < USB_MAX_DEVNAMES; i++) |
414 |
++ if (di.udi_devnames[i][0] && |
415 |
++ strcmp(di.udi_devnames[i], dev) == 0) { |
416 |
++ cp = calloc(1, strlen(di.udi_vendor) + strlen(di.udi_product) + 2); |
417 |
++ strcpy(cp, di.udi_vendor); |
418 |
++ strcat(cp, " "); |
419 |
++ strcat(cp, di.udi_product); |
420 |
++ strncpy(out, cp, outlen - 1); |
421 |
++ out[outlen - 1] = 0; |
422 |
++ free(cp); |
423 |
++ return out; |
424 |
++ } |
425 |
++ } |
426 |
++ return NULL; |
427 |
++} |
428 |
++ |
429 |
++static int fghJoystickFindUSBdev(char *name, char *out, int outlen) |
430 |
++{ |
431 |
++ int i, f; |
432 |
++ char buf[50]; |
433 |
++ char *cp; |
434 |
++ static int protection_warned = 0; |
435 |
++ |
436 |
++ for (i = 0; i < 16; i++) { |
437 |
++ snprintf(buf, sizeof(buf), "%s%d", USBDEV, i); |
438 |
++ f = open(buf, O_RDONLY); |
439 |
++ if (f >= 0) { |
440 |
++ cp = fghJoystickWalkUSBdev(f, name, out, outlen); |
441 |
++ close(f); |
442 |
++ if (cp) |
443 |
++ return 1; |
444 |
++ } |
445 |
++ else if (errno == EACCES) { |
446 |
++ if (!protection_warned) { |
447 |
++ fgWarning("Can't open %s for read!", buf); |
448 |
++ protection_warned = 1; |
449 |
++ } |
450 |
++ } |
451 |
++ } |
452 |
++ return 0; |
453 |
++} |
454 |
++ |
455 |
++static int fghJoystickInitializeHID(struct os_specific_s *os, |
456 |
++ int *num_axes, int *num_buttons) |
457 |
++{ |
458 |
++ int size, is_joystick; |
459 |
++# ifdef HAVE_USBHID_H |
460 |
++ int report_id = 0; |
461 |
++# endif |
462 |
++ struct hid_data *d; |
463 |
++ struct hid_item h; |
464 |
++ report_desc_t rd; |
465 |
++ |
466 |
++ if ((rd = hid_get_report_desc(os->fd)) == 0) |
467 |
++ { |
468 |
++ fgWarning("error: %s: %s", os->fname, strerror(errno)); |
469 |
++ return FALSE; |
470 |
++ } |
471 |
++ |
472 |
++ os->hids = NULL; |
473 |
++ |
474 |
++# ifdef HAVE_USBHID_H |
475 |
++ if (ioctl(os->fd, USB_GET_REPORT_ID, &report_id) < 0) |
476 |
++ { |
477 |
++ /*** XXX {report_id} may not be the right variable? ***/ |
478 |
++ fgWarning("error: %s%d: %s", UHIDDEV, report_id, strerror(errno)); |
479 |
++ return FALSE; |
480 |
++ } |
481 |
++ |
482 |
++ size = hid_report_size(rd, hid_input, report_id); |
483 |
++# else |
484 |
++ size = hid_report_size(rd, 0, hid_input); |
485 |
++# endif |
486 |
++ os->hid_data_buf = calloc(1, size); |
487 |
++ os->hid_dlen = size; |
488 |
++ |
489 |
++ is_joystick = 0; |
490 |
++# ifdef HAVE_USBHID_H |
491 |
++ d = hid_start_parse(rd, 1 << hid_input, report_id); |
492 |
++# else |
493 |
++ d = hid_start_parse(rd, 1 << hid_input); |
494 |
++# endif |
495 |
++ while (hid_get_item(d, &h)) |
496 |
++ { |
497 |
++ int usage, page, interesting_hid; |
498 |
++ |
499 |
++ page = HID_PAGE(h.usage); |
500 |
++ usage = HID_USAGE(h.usage); |
501 |
++ |
502 |
++ /* This test is somewhat too simplistic, but this is how MicroSoft |
503 |
++ * does, so I guess it works for all joysticks/game pads. */ |
504 |
++ is_joystick = is_joystick || |
505 |
++ (h.kind == hid_collection && |
506 |
++ page == HUP_GENERIC_DESKTOP && |
507 |
++ (usage == HUG_JOYSTICK || usage == HUG_GAME_PAD)); |
508 |
++ |
509 |
++ if (h.kind != hid_input) |
510 |
++ continue; |
511 |
++ |
512 |
++ if (!is_joystick) |
513 |
++ continue; |
514 |
++ |
515 |
++ interesting_hid = TRUE; |
516 |
++ if (page == HUP_GENERIC_DESKTOP) |
517 |
++ { |
518 |
++ switch (usage) |
519 |
++ { |
520 |
++ case HUG_X: |
521 |
++ case HUG_RX: |
522 |
++ case HUG_Y: |
523 |
++ case HUG_RY: |
524 |
++ case HUG_Z: |
525 |
++ case HUG_RZ: |
526 |
++ case HUG_SLIDER: |
527 |
++ if (*num_axes < _JS_MAX_AXES) |
528 |
++ { |
529 |
++ os->axes_usage[*num_axes] = usage; |
530 |
++ (*num_axes)++; |
531 |
++ } |
532 |
++ break; |
533 |
++ case HUG_HAT_SWITCH: |
534 |
++ /* Allocate two axes for a hat */ |
535 |
++ if (*num_axes + 1 < _JS_MAX_AXES) |
536 |
++ { |
537 |
++ os->axes_usage[*num_axes] = usage; |
538 |
++ (*num_axes)++; |
539 |
++ os->axes_usage[*num_axes] = usage; |
540 |
++ (*num_axes)++; |
541 |
++ } |
542 |
++ break; |
543 |
++ default: |
544 |
++ interesting_hid = FALSE; |
545 |
++ break; |
546 |
++ } |
547 |
++ } |
548 |
++ else if (page == HUP_BUTTON) |
549 |
++ { |
550 |
++ interesting_hid = (usage > 0) && |
551 |
++ (usage <= _JS_MAX_BUTTONS); |
552 |
++ |
553 |
++ if (interesting_hid && usage - 1 > *num_buttons) |
554 |
++ *num_buttons = usage - 1; |
555 |
++ } |
556 |
++ |
557 |
++ if (interesting_hid) |
558 |
++ { |
559 |
++ h.next = os->hids; |
560 |
++ os->hids = calloc(1, sizeof(struct hid_item)); |
561 |
++ *os->hids = h; |
562 |
++ } |
563 |
++ } |
564 |
++ hid_end_parse(d); |
565 |
++ |
566 |
++ return os->hids != NULL; |
567 |
++} |
568 |
++# endif |
569 |
++#endif |
570 |
++ |
571 |
++ |
572 |
+ /*this should be defined in a header file */ |
573 |
+-#define MAX_NUM_JOYSTICKS 2 |
574 |
++#define MAX_NUM_JOYSTICKS 2 |
575 |
+ extern SFG_Joystick *fgJoystick [ MAX_NUM_JOYSTICKS ]; |
576 |
+ |
577 |
+ void fgPlatformJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes ) |
578 |
+@@ -216,15 +396,15 @@ void fgPlatformJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes ) |
579 |
+ void fgPlatformJoystickOpen( SFG_Joystick* joy ) |
580 |
+ { |
581 |
+ #if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) |
582 |
+- int i = 0; |
583 |
++ int i = 0; |
584 |
+ char *cp; |
585 |
+ #endif |
586 |
+ #ifdef JS_NEW |
587 |
+ unsigned char u; |
588 |
+- int i=0; |
589 |
++ int i=0; |
590 |
+ #else |
591 |
+ # if defined( __linux__ ) || TARGET_HOST_SOLARIS |
592 |
+- int i = 0; |
593 |
++ int i = 0; |
594 |
+ int counter = 0; |
595 |
+ # endif |
596 |
+ #endif |
597 |
+@@ -448,7 +628,7 @@ void fgPlatformJoystickClose ( int ident ) |
598 |
+ free( fgJoystick[ ident ]->pJoystick.os->hid_data_buf ); |
599 |
+ #endif |
600 |
+ free( fgJoystick[ident]->pJoystick.os ); |
601 |
+- } |
602 |
++ } |
603 |
+ #endif |
604 |
+ |
605 |
+ if( ! fgJoystick[ident]->error ) |
606 |
+-- |
607 |
+2.19.2 |
608 |
+ |
609 |
+From f310b56bb6f93e255cf880c8970c794e0f2efc8d Mon Sep 17 00:00:00 2001 |
610 |
+From: dcnieho <dcnieho@7f0cb862-5218-0410-a997-914c9d46530a> |
611 |
+Date: Mon, 31 Jul 2017 20:49:26 +0000 |
612 |
+Subject: [PATCH] Fix build on NetBSD. |
613 |
+ |
614 |
+(cherry picked from commit 1236c7644508227b616e97e29e123b34257e36d1) |
615 |
+ |
616 |
+git-svn-id: http://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1835 7f0cb862-5218-0410-a997-914c9d46530a |
617 |
+--- |
618 |
+ src/fg_joystick.c | 59 ------------------------------------- |
619 |
+ src/x11/fg_joystick_x11.c | 61 +++++++++++++++++++++++++++++++++++++++ |
620 |
+ 2 files changed, 61 insertions(+), 59 deletions(-) |
621 |
+ |
622 |
+diff --git a/src/fg_joystick.c b/src/fg_joystick.c |
623 |
+index e548c04..b24476a 100644 |
624 |
+--- a/src/fg_joystick.c |
625 |
++++ b/src/fg_joystick.c |
626 |
+@@ -40,65 +40,6 @@ |
627 |
+ #define JS_TRUE 1 |
628 |
+ #define JS_FALSE 0 |
629 |
+ |
630 |
+-/* BSD defines from "jsBSD.cxx" around lines 42-270 */ |
631 |
+- |
632 |
+-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) |
633 |
+- |
634 |
+-# ifdef HAVE_USB_JS |
635 |
+-# if defined(__NetBSD__) |
636 |
+-# ifdef HAVE_USBHID_H |
637 |
+-# include <usbhid.h> |
638 |
+-# else |
639 |
+-# include <usb.h> |
640 |
+-# endif |
641 |
+-# include <dev/usb/usb.h> |
642 |
+-# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) |
643 |
+-# ifdef HAVE_USBHID_H |
644 |
+-# include <usbhid.h> |
645 |
+-# else |
646 |
+-# include <libusbhid.h> |
647 |
+-# endif |
648 |
+-# include <legacy/dev/usb/usb.h> |
649 |
+-# endif |
650 |
+-# include <dev/usb/usbhid.h> |
651 |
+- |
652 |
+-/* Compatibility with older usb.h revisions */ |
653 |
+-# if !defined(USB_MAX_DEVNAMES) && defined(MAXDEVNAMES) |
654 |
+-# define USB_MAX_DEVNAMES MAXDEVNAMES |
655 |
+-# endif |
656 |
+-# endif |
657 |
+- |
658 |
+-struct os_specific_s { |
659 |
+- char fname [128 ]; |
660 |
+- int fd; |
661 |
+- int is_analog; |
662 |
+- /* The following structure members are specific to analog joysticks */ |
663 |
+- struct joystick ajs; |
664 |
+-# ifdef HAVE_USB_JS |
665 |
+- /* The following structure members are specific to USB joysticks */ |
666 |
+- struct hid_item *hids; |
667 |
+- int hid_dlen; |
668 |
+- int hid_offset; |
669 |
+- char *hid_data_buf; |
670 |
+- int axes_usage [ _JS_MAX_AXES ]; |
671 |
+-# endif |
672 |
+- /* We keep button and axes state ourselves, as they might not be updated |
673 |
+- * on every read of a USB device |
674 |
+- */ |
675 |
+- int cache_buttons; |
676 |
+- float cache_axes [ _JS_MAX_AXES ]; |
677 |
+-}; |
678 |
+- |
679 |
+-/* Idents lower than USB_IDENT_OFFSET are for analog joysticks. */ |
680 |
+-# define USB_IDENT_OFFSET 2 |
681 |
+- |
682 |
+-# define USBDEV "/dev/usb" |
683 |
+-# define UHIDDEV "/dev/uhid" |
684 |
+-# define AJSDEV "/dev/joy" |
685 |
+- |
686 |
+- |
687 |
+-#endif |
688 |
+- |
689 |
+ /* |
690 |
+ * Functions associated with the "jsJoystick" class in PLIB |
691 |
+ */ |
692 |
+diff --git a/src/x11/fg_joystick_x11.c b/src/x11/fg_joystick_x11.c |
693 |
+index 30ad4b5..8c75bbe 100644 |
694 |
+--- a/src/x11/fg_joystick_x11.c |
695 |
++++ b/src/x11/fg_joystick_x11.c |
696 |
+@@ -42,8 +42,68 @@ |
697 |
+ #include <fcntl.h> |
698 |
+ |
699 |
+ |
700 |
++/* BSD defines from "jsBSD.cxx" around lines 42-270 */ |
701 |
++ |
702 |
++#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) |
703 |
++ |
704 |
++# ifdef HAVE_USB_JS |
705 |
++# if defined(__NetBSD__) |
706 |
++# ifdef HAVE_USBHID_H |
707 |
++# include <usbhid.h> |
708 |
++# else |
709 |
++# include <usb.h> |
710 |
++# endif |
711 |
++# include <dev/usb/usb.h> |
712 |
++# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) |
713 |
++# ifdef HAVE_USBHID_H |
714 |
++# include <usbhid.h> |
715 |
++# else |
716 |
++# include <libusbhid.h> |
717 |
++# endif |
718 |
++# include <legacy/dev/usb/usb.h> |
719 |
++# endif |
720 |
++# include <dev/usb/usbhid.h> |
721 |
++ |
722 |
++/* Compatibility with older usb.h revisions */ |
723 |
++# if !defined(USB_MAX_DEVNAMES) && defined(MAXDEVNAMES) |
724 |
++# define USB_MAX_DEVNAMES MAXDEVNAMES |
725 |
++# endif |
726 |
++# endif |
727 |
++ |
728 |
++struct os_specific_s { |
729 |
++ char fname [128 ]; |
730 |
++ int fd; |
731 |
++ int is_analog; |
732 |
++ /* The following structure members are specific to analog joysticks */ |
733 |
++ struct joystick ajs; |
734 |
++# ifdef HAVE_USB_JS |
735 |
++ /* The following structure members are specific to USB joysticks */ |
736 |
++ struct hid_item *hids; |
737 |
++ int hid_dlen; |
738 |
++ int hid_offset; |
739 |
++ char *hid_data_buf; |
740 |
++ int axes_usage [ _JS_MAX_AXES ]; |
741 |
++# endif |
742 |
++ /* We keep button and axes state ourselves, as they might not be updated |
743 |
++ * on every read of a USB device |
744 |
++ */ |
745 |
++ int cache_buttons; |
746 |
++ float cache_axes [ _JS_MAX_AXES ]; |
747 |
++}; |
748 |
++ |
749 |
++/* Idents lower than USB_IDENT_OFFSET are for analog joysticks. */ |
750 |
++# define USB_IDENT_OFFSET 2 |
751 |
++ |
752 |
++# define USBDEV "/dev/usb" |
753 |
++# define UHIDDEV "/dev/uhid" |
754 |
++# define AJSDEV "/dev/joy" |
755 |
++ |
756 |
++ |
757 |
++#endif |
758 |
++ |
759 |
+ #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) |
760 |
+ |
761 |
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) |
762 |
+ static int hatmap_x[9] = {0, 0, 1, 1, 1, 0, -1, -1, -1}; |
763 |
+ static int hatmap_y[9] = {0, 1, 1, 0, -1, -1, -1, 0, 1}; |
764 |
+ |
765 |
+@@ -104,6 +164,7 @@ static int fghJoystickFindUSBdev(char *name, char *out, int outlen) |
766 |
+ } |
767 |
+ return 0; |
768 |
+ } |
769 |
++#endif |
770 |
+ |
771 |
+ static int fghJoystickInitializeHID(struct os_specific_s *os, |
772 |
+ int *num_axes, int *num_buttons) |
773 |
+-- |
774 |
+2.19.2 |
775 |
+ |
776 |
|
777 |
diff --git a/media-libs/freeglut/freeglut-3.0.0.ebuild b/media-libs/freeglut/freeglut-3.0.0.ebuild |
778 |
index 95ec4c4bca8..3fcb972cf75 100644 |
779 |
--- a/media-libs/freeglut/freeglut-3.0.0.ebuild |
780 |
+++ b/media-libs/freeglut/freeglut-3.0.0.ebuild |
781 |
@@ -31,6 +31,7 @@ HTML_DOCS=( doc/. ) |
782 |
|
783 |
PATCHES=( |
784 |
"${FILESDIR}"/${P}-drop-unnecessary-x11-libs.patch |
785 |
+ "${FILESDIR}"/${P}-bsd-usb-joystick.patch |
786 |
) |
787 |
|
788 |
src_configure() { |