src/joystick/darwin/SDL_sysjoystick_c.h
author Sam Lantinga <slouken@libsdl.org>
Tue, 11 Dec 2012 12:35:11 -0800
changeset 6745 de3683865c14
parent 6690 9548c8a58103
child 6885 700f1b25f77f
permissions -rw-r--r--
Fixed building joystick code on Mac OS X
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     4 
     5   This software is provided 'as-is', without any express or implied
     6   warranty.  In no event will the authors be held liable for any damages
     7   arising from the use of this software.
     8 
     9   Permission is granted to anyone to use this software for any purpose,
    10   including commercial applications, and to alter it and redistribute it
    11   freely, subject to the following restrictions:
    12 
    13   1. The origin of this software must not be misrepresented; you must not
    14      claim that you wrote the original software. If you use this software
    15      in a product, an acknowledgment in the product documentation would be
    16      appreciated but is not required.
    17   2. Altered source versions must be plainly marked as such, and must not be
    18      misrepresented as being the original software.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    21 #include "SDL_config.h"
    22 
    23 #ifndef SDL_JOYSTICK_IOKIT_H
    24 
    25 
    26 #include <IOKit/hid/IOHIDLib.h>
    27 #include <IOKit/hid/IOHIDKeys.h>
    28 #include <IOKit/IOKitLib.h>
    29 
    30 
    31 struct recElement
    32 {
    33     IOHIDElementCookie cookie;  /* unique value which identifies element, will NOT change */
    34     long usagePage, usage;      /* HID usage */
    35     long min;                   /* reported min value possible */
    36     long max;                   /* reported max value possible */
    37 #if 0
    38     /* TODO: maybe should handle the following stuff somehow? */
    39 
    40     long scaledMin;             /* reported scaled min value possible */
    41     long scaledMax;             /* reported scaled max value possible */
    42     long size;                  /* size in bits of data return from element */
    43     Boolean relative;           /* are reports relative to last report (deltas) */
    44     Boolean wrapping;           /* does element wrap around (one value higher than max is min) */
    45     Boolean nonLinear;          /* are the values reported non-linear relative to element movement */
    46     Boolean preferredState;     /* does element have a preferred state (such as a button) */
    47     Boolean nullState;          /* does element have null state */
    48 #endif                          /* 0 */
    49 
    50     /* runtime variables used for auto-calibration */
    51     long minReport;             /* min returned value */
    52     long maxReport;             /* max returned value */
    53 
    54     struct recElement *pNext;   /* next element in list */
    55 };
    56 typedef struct recElement recElement;
    57 
    58 struct joystick_hwdata
    59 {
    60     io_service_t ffservice;     /* Interface for force feedback, 0 = no ff */
    61     IOHIDDeviceInterface **interface;   /* interface to device, NULL = no interface */
    62 	IONotificationPortRef notificationPort; /* port to be notified on joystick removal */
    63 	io_iterator_t portIterator; /* iterator for removal callback */
    64 	
    65     char product[256];          /* name of product */
    66     long usage;                 /* usage page from IOUSBHID Parser.h which defines general usage */
    67     long usagePage;             /* usage within above page from IOUSBHID Parser.h which defines specific usage */
    68 
    69     long axes;                  /* number of axis (calculated, not reported by device) */
    70     long buttons;               /* number of buttons (calculated, not reported by device) */
    71     long hats;                  /* number of hat switches (calculated, not reported by device) */
    72     long elements;              /* number of total elements (shouldbe total of above) (calculated, not reported by device) */
    73 
    74     recElement *firstAxis;
    75     recElement *firstButton;
    76     recElement *firstHat;
    77 
    78     int removed;
    79     int uncentered;
    80 	
    81 	int instance_id;
    82 	SDL_JoystickGUID guid;
    83 	Uint8 send_open_event;		/* 1 if we need to send an Added event for this device */
    84 
    85     struct joystick_hwdata *pNext;      /* next device */
    86 };
    87 typedef struct joystick_hwdata recDevice;
    88 
    89 
    90 #endif /* SDL_JOYSTICK_IOKIT_H */