src/joystick/bsd/SDL_sysjoystick.c
changeset 6963 4658b1101200
parent 6885 700f1b25f77f
child 7037 3fedf1f25b94
equal deleted inserted replaced
6962:6ce8edb5577b 6963:4658b1101200
    81 #define MAX_JOYS	(MAX_UHID_JOYS + MAX_JOY_JOYS)
    81 #define MAX_JOYS	(MAX_UHID_JOYS + MAX_JOY_JOYS)
    82 
    82 
    83 
    83 
    84 struct report
    84 struct report
    85 {
    85 {
    86 #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)
    86 #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000)
       
    87     void *buf; /* Buffer */
       
    88 #elif defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)
    87     struct usb_gen_descriptor *buf; /* Buffer */
    89     struct usb_gen_descriptor *buf; /* Buffer */
    88 #else
    90 #else
    89     struct usb_ctl_report *buf; /* Buffer */
    91     struct usb_ctl_report *buf; /* Buffer */
    90 #endif
    92 #endif
    91     size_t size;                /* Buffer size */
    93     size_t size;                /* Buffer size */
   147 static char *joydevnames[MAX_JOYS];
   149 static char *joydevnames[MAX_JOYS];
   148 
   150 
   149 static int report_alloc(struct report *, struct report_desc *, int);
   151 static int report_alloc(struct report *, struct report_desc *, int);
   150 static void report_free(struct report *);
   152 static void report_free(struct report *);
   151 
   153 
   152 #if defined(USBHID_UCR_DATA)
   154 #if defined(USBHID_UCR_DATA) || (defined(__FreeBSD_kernel__) && __FreeBSD_kernel_version <= 800063)
   153 #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data)
   155 #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data)
       
   156 #elif (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000))
       
   157 #define REP_BUF_DATA(rep) ((rep)->buf)
   154 #elif (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063))
   158 #elif (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063))
   155 #define REP_BUF_DATA(rep) ((rep)->buf->ugd_data)
   159 #define REP_BUF_DATA(rep) ((rep)->buf->ugd_data)
   156 #else
   160 #else
   157 #define REP_BUF_DATA(rep) ((rep)->buf->data)
   161 #define REP_BUF_DATA(rep) ((rep)->buf->data)
   158 #endif
   162 #endif
   634         return (-1);
   638         return (-1);
   635     }
   639     }
   636     r->size = len;
   640     r->size = len;
   637 
   641 
   638     if (r->size > 0) {
   642     if (r->size > 0) {
       
   643 #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000)
       
   644         r->buf = SDL_malloc(r->size);
       
   645 #else
   639         r->buf = SDL_malloc(sizeof(*r->buf) - sizeof(REP_BUF_DATA(r)) +
   646         r->buf = SDL_malloc(sizeof(*r->buf) - sizeof(REP_BUF_DATA(r)) +
   640                             r->size);
   647                             r->size);
       
   648 #endif
   641         if (r->buf == NULL) {
   649         if (r->buf == NULL) {
   642             SDL_OutOfMemory();
   650             SDL_OutOfMemory();
   643             return (-1);
   651             return (-1);
   644         }
   652         }
   645     } else {
   653     } else {