src/joystick/SDL_sysjoystick.h
author Sam Lantinga
Wed, 03 Oct 2012 13:39:42 -0700
changeset 6544 c03db4864789
parent 6138 4c64952a58fb
child 6690 9548c8a58103
permissions -rw-r--r--
Use Ctrl modifier for window resize key bindings
     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 /* This is the system specific header for the SDL joystick API */
    24 
    25 #include "SDL_joystick.h"
    26 
    27 /* The SDL joystick structure */
    28 struct _SDL_Joystick
    29 {
    30     Uint8 index;                /* Device index */
    31     const char *name;           /* Joystick name - system dependent */
    32 
    33     int naxes;                  /* Number of axis controls on the joystick */
    34     Sint16 *axes;               /* Current axis states */
    35 
    36     int nhats;                  /* Number of hats on the joystick */
    37     Uint8 *hats;                /* Current hat states */
    38 
    39     int nballs;                 /* Number of trackballs on the joystick */
    40     struct balldelta
    41     {
    42         int dx;
    43         int dy;
    44     } *balls;                   /* Current ball motion deltas */
    45 
    46     int nbuttons;               /* Number of buttons on the joystick */
    47     Uint8 *buttons;             /* Current button states */
    48 
    49     struct joystick_hwdata *hwdata;     /* Driver dependent information */
    50 
    51     int ref_count;              /* Reference count for multiple opens */
    52 };
    53 
    54 /* Function to scan the system for joysticks.
    55  * Joystick 0 should be the system default joystick.
    56  * This function should return the number of available joysticks, or -1
    57  * on an unrecoverable fatal error.
    58  */
    59 extern int SDL_SYS_JoystickInit(void);
    60 
    61 /* Function to get the device-dependent name of a joystick */
    62 extern const char *SDL_SYS_JoystickName(int index);
    63 
    64 /* Function to open a joystick for use.
    65    The joystick to open is specified by the index field of the joystick.
    66    This should fill the nbuttons and naxes fields of the joystick structure.
    67    It returns 0, or -1 if there is an error.
    68  */
    69 extern int SDL_SYS_JoystickOpen(SDL_Joystick * joystick);
    70 
    71 /* Function to update the state of a joystick - called as a device poll.
    72  * This function shouldn't update the joystick structure directly,
    73  * but instead should call SDL_PrivateJoystick*() to deliver events
    74  * and update joystick device state.
    75  */
    76 extern void SDL_SYS_JoystickUpdate(SDL_Joystick * joystick);
    77 
    78 /* Function to close a joystick after use */
    79 extern void SDL_SYS_JoystickClose(SDL_Joystick * joystick);
    80 
    81 /* Function to perform any system-specific joystick related cleanup */
    82 extern void SDL_SYS_JoystickQuit(void);
    83 
    84 /* vi: set ts=4 sw=4 expandtab: */