src/joystick/darwin/SDL_sysjoystick_c.h
author Edgar Simo <bobbens@gmail.com>
Sun, 10 Aug 2008 19:45:38 +0000
branchgsoc2008_force_feedback
changeset 2637 2f826c229d77
parent 2632 9e7f58b1b255
permissions -rw-r--r--
First draft of darwin haptic<->joystick stuff.
bobbens@2632
     1
/*
bobbens@2632
     2
	SDL - Simple DirectMedia Layer
bobbens@2632
     3
    Copyright (C) 1997-2004 Sam Lantinga
bobbens@2632
     4
bobbens@2632
     5
	This library is free software; you can redistribute it and/or
bobbens@2632
     6
	modify it under the terms of the GNU Library General Public
bobbens@2632
     7
	License as published by the Free Software Foundation; either
bobbens@2632
     8
	version 2 of the License, or (at your option) any later version.
bobbens@2632
     9
bobbens@2632
    10
	This library is distributed in the hope that it will be useful,
bobbens@2632
    11
	but WITHOUT ANY WARRANTY; without even the implied warranty of
bobbens@2632
    12
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
bobbens@2632
    13
	Library General Public License for more details.
bobbens@2632
    14
bobbens@2632
    15
	You should have received a copy of the GNU Library General Public
bobbens@2632
    16
	License along with this library; if not, write to the Free
bobbens@2632
    17
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
bobbens@2632
    18
bobbens@2632
    19
	Sam Lantinga
bobbens@2632
    20
	slouken@libsdl.org
bobbens@2632
    21
*/
bobbens@2632
    22
#include "SDL_config.h"
bobbens@2632
    23
bobbens@2632
    24
#ifndef SDL_JOYSTICK_IOKIT_H
bobbens@2632
    25
bobbens@2632
    26
bobbens@2632
    27
#if MAC_OS_X_VERSION_MIN_REQUIRED == 1030
bobbens@2632
    28
#include "10.3.9-FIX/IOHIDLib.h"
bobbens@2632
    29
#else
bobbens@2632
    30
#include <IOKit/hid/IOHIDLib.h>
bobbens@2632
    31
#endif
bobbens@2632
    32
#include <IOKit/hid/IOHIDKeys.h>
bobbens@2632
    33
bobbens@2632
    34
bobbens@2632
    35
struct recElement
bobbens@2632
    36
{
bobbens@2632
    37
    IOHIDElementCookie cookie;  /* unique value which identifies element, will NOT change */
bobbens@2632
    38
    long min;                   /* reported min value possible */
bobbens@2632
    39
    long max;                   /* reported max value possible */
bobbens@2632
    40
#if 0
bobbens@2632
    41
    /* TODO: maybe should handle the following stuff somehow? */
bobbens@2632
    42
bobbens@2632
    43
    long scaledMin;             /* reported scaled min value possible */
bobbens@2632
    44
    long scaledMax;             /* reported scaled max value possible */
bobbens@2632
    45
    long size;                  /* size in bits of data return from element */
bobbens@2632
    46
    Boolean relative;           /* are reports relative to last report (deltas) */
bobbens@2632
    47
    Boolean wrapping;           /* does element wrap around (one value higher than max is min) */
bobbens@2632
    48
    Boolean nonLinear;          /* are the values reported non-linear relative to element movement */
bobbens@2632
    49
    Boolean preferredState;     /* does element have a preferred state (such as a button) */
bobbens@2632
    50
    Boolean nullState;          /* does element have null state */
bobbens@2632
    51
#endif                          /* 0 */
bobbens@2632
    52
bobbens@2632
    53
    /* runtime variables used for auto-calibration */
bobbens@2632
    54
    long minReport;             /* min returned value */
bobbens@2632
    55
    long maxReport;             /* max returned value */
bobbens@2632
    56
bobbens@2632
    57
    struct recElement *pNext;   /* next element in list */
bobbens@2632
    58
};
bobbens@2632
    59
typedef struct recElement recElement;
bobbens@2632
    60
bobbens@2632
    61
struct joystick_hwdata
bobbens@2632
    62
{
bobbens@2637
    63
    io_service_t ffservice;             /* Interface for force feedback, 0 = no ff */
bobbens@2632
    64
    IOHIDDeviceInterface **interface;   /* interface to device, NULL = no interface */
bobbens@2632
    65
bobbens@2632
    66
    char product[256];          /* name of product */
bobbens@2632
    67
    long usage;                 /* usage page from IOUSBHID Parser.h which defines general usage */
bobbens@2632
    68
    long usagePage;             /* usage within above page from IOUSBHID Parser.h which defines specific usage */
bobbens@2632
    69
bobbens@2632
    70
    long axes;                  /* number of axis (calculated, not reported by device) */
bobbens@2632
    71
    long buttons;               /* number of buttons (calculated, not reported by device) */
bobbens@2632
    72
    long hats;                  /* number of hat switches (calculated, not reported by device) */
bobbens@2632
    73
    long elements;              /* number of total elements (shouldbe total of above) (calculated, not reported by device) */
bobbens@2632
    74
bobbens@2632
    75
    recElement *firstAxis;
bobbens@2632
    76
    recElement *firstButton;
bobbens@2632
    77
    recElement *firstHat;
bobbens@2632
    78
bobbens@2632
    79
    int removed;
bobbens@2632
    80
    int uncentered;
bobbens@2632
    81
bobbens@2632
    82
    struct joystick_hwdata *pNext;      /* next device */
bobbens@2632
    83
};
bobbens@2632
    84
typedef struct joystick_hwdata recDevice;
bobbens@2632
    85
bobbens@2632
    86
bobbens@2632
    87
#endif /* SDL_JOYSTICK_IOKIT_H */
bobbens@2632
    88