diff options
-rw-r--r-- | devel/SDL2/distinfo | 3 | ||||
-rw-r--r-- | devel/SDL2/patches/patch-src_joystick_bsd_SDL__sysjoystick.c | 67 |
2 files changed, 69 insertions, 1 deletions
diff --git a/devel/SDL2/distinfo b/devel/SDL2/distinfo index 2e5d36b7925..42b649c3994 100644 --- a/devel/SDL2/distinfo +++ b/devel/SDL2/distinfo @@ -1,10 +1,11 @@ -$NetBSD: distinfo,v 1.8 2015/02/13 19:21:12 jmcneill Exp $ +$NetBSD: distinfo,v 1.9 2015/02/13 23:31:06 jmcneill Exp $ SHA1 (SDL2-2.0.3.tar.gz) = 21c45586a4e94d7622e371340edec5da40d06ecc RMD160 (SDL2-2.0.3.tar.gz) = e6f3718c7366c5da793c1454cf0ec0972e8bd347 Size (SDL2-2.0.3.tar.gz) = 3871267 bytes SHA1 (patch-configure) = 7f0469ef69c2a7fc6a769435f0d29a01148df122 SHA1 (patch-src_cpuinfo_SDL_cpuinfo.c) = 9482910e62023b92e80ce4d3b670a1a1e666789f +SHA1 (patch-src_joystick_bsd_SDL__sysjoystick.c) = 9bfc6667d67bfa7e5d45aa4aaf5a2bbb94d4bdc8 SHA1 (patch-src_thread_pthread_SDL__systhread.c) = 68f32770d067d2b6dcffe96da2dd4aa6b4c82050 SHA1 (patch-src_video_SDL__egl.c) = 67e9bc3a32616b3c6e86c5bc5ccd475f55fbcfa7 SHA1 (patch-src_video_x11_SDL__x11opengl.c) = a435634da8b8bd5e74a281b9a26e8fb8a294e56b diff --git a/devel/SDL2/patches/patch-src_joystick_bsd_SDL__sysjoystick.c b/devel/SDL2/patches/patch-src_joystick_bsd_SDL__sysjoystick.c new file mode 100644 index 00000000000..a9d9f059ff3 --- /dev/null +++ b/devel/SDL2/patches/patch-src_joystick_bsd_SDL__sysjoystick.c @@ -0,0 +1,67 @@ +$NetBSD: patch-src_joystick_bsd_SDL__sysjoystick.c,v 1.1 2015/02/13 23:31:06 jmcneill Exp $ + +Skip non-joystick HID devices, and give joysticks on NetBSD a human readable +name. + +--- src/joystick/bsd/SDL_sysjoystick.c.orig 2014-03-16 02:31:41.000000000 +0000 ++++ src/joystick/bsd/SDL_sysjoystick.c +@@ -76,7 +76,7 @@ + #include "../SDL_sysjoystick.h" + #include "../SDL_joystick_c.h" + +-#define MAX_UHID_JOYS 16 ++#define MAX_UHID_JOYS 64 + #define MAX_JOY_JOYS 2 + #define MAX_JOYS (MAX_UHID_JOYS + MAX_JOY_JOYS) + +@@ -342,6 +342,38 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy, + #endif + rep->rid = -1; /* XXX */ + } ++#if defined(__NetBSD__) ++ usb_device_descriptor_t udd; ++ struct usb_string_desc usd; ++ if (ioctl(fd, USB_GET_DEVICE_DESC, &udd) == -1) ++ goto desc_failed; ++ ++ /* Get default language */ ++ usd.usd_string_index = USB_LANGUAGE_TABLE; ++ usd.usd_language_id = 0; ++ if (ioctl(fd, USB_GET_STRING_DESC, &usd) == -1 || usd.usd_desc.bLength < 4) { ++ usd.usd_language_id = 0; ++ } else { ++ usd.usd_language_id = UGETW(usd.usd_desc.bString[0]); ++ } ++ ++ usd.usd_string_index = udd.iProduct; ++ if (ioctl(fd, USB_GET_STRING_DESC, &usd) == 0) { ++ char str[128]; ++ char *new_name = NULL; ++ int i; ++ for (i = 0; i < (usd.usd_desc.bLength >> 1) - 1 && i < sizeof(str) - 1; i++) { ++ str[i] = UGETW(usd.usd_desc.bString[i]); ++ } ++ str[i] = '\0'; ++ asprintf(&new_name, "%s @ %s", str, path); ++ if (new_name != NULL) { ++ free(joydevnames[SDL_SYS_numjoysticks]); ++ joydevnames[SDL_SYS_numjoysticks] = new_name; ++ } ++ } ++desc_failed: ++#endif + if (report_alloc(rep, hw->repdesc, REPORT_INPUT) < 0) { + goto usberr; + } +@@ -414,6 +446,11 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy, + if (hw->axis_map[i] > 0) + hw->axis_map[i] = joy->naxes++; + ++ if (joy->naxes == 0 && joy->nbuttons == 0 && joy->nhats == 0 && joy->nballs == 0) { ++ SDL_SetError("%s: Not a joystick, ignoring", hw->path); ++ goto usberr; ++ } ++ + usbend: + /* The poll blocks the event thread. */ + fcntl(fd, F_SETFL, O_NONBLOCK); |