src/joystick/SDL_sysjoystick.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 07 Jul 2014 11:44:14 -0700
changeset 8985 a89acd7254f2
parent 8972 dfc759d7486f
child 9380 07b7c1005a23
permissions -rw-r--r--
SDL_SYS_IsXInputGamepad_DeviceIndex() is only available if SDL_JOYSTICK_XINPUT is true.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     2
  Simple DirectMedia Layer
8149
681eb46b8ac4 Fixed bug 2374 - Update copyright for 2014...
Sam Lantinga <slouken@libsdl.org>
parents: 8093
diff changeset
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     7
  arising from the use of this software.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    11
  freely, subject to the following restrictions:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    20
*/
8093
b43765095a6f Make internal SDL sources include SDL_internal.h instead of SDL_config.h
Ryan C. Gordon <icculus@icculus.org>
parents: 7685
diff changeset
    21
#include "../SDL_internal.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    22
8972
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents: 8920
diff changeset
    23
#ifndef _SDL_sysjoystick_h
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents: 8920
diff changeset
    24
#define _SDL_sysjoystick_h
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents: 8920
diff changeset
    25
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    26
/* This is the system specific header for the SDL joystick API */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    27
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    28
#include "SDL_joystick.h"
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    29
#include "SDL_joystick_c.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    30
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    31
/* The SDL joystick structure */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    32
struct _SDL_Joystick
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    33
{
6949
4de584a3a027 Fixed the joystick id usage in the joystick and game controller events.
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    34
    SDL_JoystickID instance_id; /* Device instance, monotonically increasing from 0 */
4de584a3a027 Fixed the joystick id usage in the joystick and game controller events.
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    35
    char *name;                 /* Joystick name - system dependent */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    36
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    37
    int naxes;                  /* Number of axis controls on the joystick */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    38
    Sint16 *axes;               /* Current axis states */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    39
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    40
    int nhats;                  /* Number of hats on the joystick */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    41
    Uint8 *hats;                /* Current hat states */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    42
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    43
    int nballs;                 /* Number of trackballs on the joystick */
6949
4de584a3a027 Fixed the joystick id usage in the joystick and game controller events.
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    44
    struct balldelta {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    45
        int dx;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    46
        int dy;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    47
    } *balls;                   /* Current ball motion deltas */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    48
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    49
    int nbuttons;               /* Number of buttons on the joystick */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    50
    Uint8 *buttons;             /* Current button states */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    51
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    52
    struct joystick_hwdata *hwdata;     /* Driver dependent information */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    53
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    54
    int ref_count;              /* Reference count for multiple opens */
6949
4de584a3a027 Fixed the joystick id usage in the joystick and game controller events.
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    55
8920
21ccd40c778a Fixed bug 2553 - Add support to all XInput devices
Sam Lantinga <slouken@libsdl.org>
parents: 8860
diff changeset
    56
    SDL_bool closed;            /* SDL_TRUE if this device is no longer valid */
21ccd40c778a Fixed bug 2553 - Add support to all XInput devices
Sam Lantinga <slouken@libsdl.org>
parents: 8860
diff changeset
    57
    SDL_bool uncentered;        /* SDL_TRUE if this device needs to have its state reset to 0 */
6949
4de584a3a027 Fixed the joystick id usage in the joystick and game controller events.
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    58
    struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    59
};
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    60
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    61
/* Function to scan the system for joysticks.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    62
 * Joystick 0 should be the system default joystick.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    63
 * This function should return the number of available joysticks, or -1
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    64
 * on an unrecoverable fatal error.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    65
 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    66
extern int SDL_SYS_JoystickInit(void);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    67
6707
70eeb7e3ec2f Organized joystick hotplug code a bit.
Sam Lantinga <slouken@libsdl.org>
parents: 6701
diff changeset
    68
/* Function to return the number of joystick devices plugged in right now */
70eeb7e3ec2f Organized joystick hotplug code a bit.
Sam Lantinga <slouken@libsdl.org>
parents: 6701
diff changeset
    69
extern int SDL_SYS_NumJoysticks();
70eeb7e3ec2f Organized joystick hotplug code a bit.
Sam Lantinga <slouken@libsdl.org>
parents: 6701
diff changeset
    70
70eeb7e3ec2f Organized joystick hotplug code a bit.
Sam Lantinga <slouken@libsdl.org>
parents: 6701
diff changeset
    71
/* Function to cause any queued joystick insertions to be processed */
70eeb7e3ec2f Organized joystick hotplug code a bit.
Sam Lantinga <slouken@libsdl.org>
parents: 6701
diff changeset
    72
extern void SDL_SYS_JoystickDetect();
70eeb7e3ec2f Organized joystick hotplug code a bit.
Sam Lantinga <slouken@libsdl.org>
parents: 6701
diff changeset
    73
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    74
/* Function to get the device-dependent name of a joystick */
6707
70eeb7e3ec2f Organized joystick hotplug code a bit.
Sam Lantinga <slouken@libsdl.org>
parents: 6701
diff changeset
    75
extern const char *SDL_SYS_JoystickNameForDeviceIndex(int device_index);
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    76
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    77
/* Function to get the current instance id of the joystick located at device_index */
6707
70eeb7e3ec2f Organized joystick hotplug code a bit.
Sam Lantinga <slouken@libsdl.org>
parents: 6701
diff changeset
    78
extern SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    79
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    80
/* Function to open a joystick for use.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    81
   The joystick to open is specified by the index field of the joystick.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    82
   This should fill the nbuttons and naxes fields of the joystick structure.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    83
   It returns 0, or -1 if there is an error.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    84
 */
6707
70eeb7e3ec2f Organized joystick hotplug code a bit.
Sam Lantinga <slouken@libsdl.org>
parents: 6701
diff changeset
    85
extern int SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index);
70eeb7e3ec2f Organized joystick hotplug code a bit.
Sam Lantinga <slouken@libsdl.org>
parents: 6701
diff changeset
    86
70eeb7e3ec2f Organized joystick hotplug code a bit.
Sam Lantinga <slouken@libsdl.org>
parents: 6701
diff changeset
    87
/* Function to query if the joystick is currently attached
70eeb7e3ec2f Organized joystick hotplug code a bit.
Sam Lantinga <slouken@libsdl.org>
parents: 6701
diff changeset
    88
 *   It returns 1 if attached, 0 otherwise.
70eeb7e3ec2f Organized joystick hotplug code a bit.
Sam Lantinga <slouken@libsdl.org>
parents: 6701
diff changeset
    89
 */
70eeb7e3ec2f Organized joystick hotplug code a bit.
Sam Lantinga <slouken@libsdl.org>
parents: 6701
diff changeset
    90
extern SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick * joystick);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    91
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    92
/* Function to update the state of a joystick - called as a device poll.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    93
 * This function shouldn't update the joystick structure directly,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    94
 * but instead should call SDL_PrivateJoystick*() to deliver events
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    95
 * and update joystick device state.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    96
 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    97
extern void SDL_SYS_JoystickUpdate(SDL_Joystick * joystick);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    98
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    99
/* Function to close a joystick after use */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   100
extern void SDL_SYS_JoystickClose(SDL_Joystick * joystick);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   101
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   102
/* Function to perform any system-specific joystick related cleanup */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   103
extern void SDL_SYS_JoystickQuit(void);
1978
542c78b6fb12 MacOS Classic is no longer supported.
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   104
6707
70eeb7e3ec2f Organized joystick hotplug code a bit.
Sam Lantinga <slouken@libsdl.org>
parents: 6701
diff changeset
   105
/* Function to return the stable GUID for a plugged in device */
6738
b408d5a406a3 Changes from Alfred:
Sam Lantinga <slouken@libsdl.org>
parents: 6707
diff changeset
   106
extern SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID(int device_index);
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   107
6707
70eeb7e3ec2f Organized joystick hotplug code a bit.
Sam Lantinga <slouken@libsdl.org>
parents: 6701
diff changeset
   108
/* Function to return the stable GUID for a opened joystick */
6738
b408d5a406a3 Changes from Alfred:
Sam Lantinga <slouken@libsdl.org>
parents: 6707
diff changeset
   109
extern SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick);
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   110
8985
a89acd7254f2 SDL_SYS_IsXInputGamepad_DeviceIndex() is only available if SDL_JOYSTICK_XINPUT is true.
Sam Lantinga <slouken@libsdl.org>
parents: 8972
diff changeset
   111
#if SDL_JOYSTICK_XINPUT
8920
21ccd40c778a Fixed bug 2553 - Add support to all XInput devices
Sam Lantinga <slouken@libsdl.org>
parents: 8860
diff changeset
   112
/* Function returns SDL_TRUE if this device is an XInput gamepad */
8972
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents: 8920
diff changeset
   113
extern SDL_bool SDL_SYS_IsXInputGamepad_DeviceIndex(int device_index);
8985
a89acd7254f2 SDL_SYS_IsXInputGamepad_DeviceIndex() is only available if SDL_JOYSTICK_XINPUT is true.
Sam Lantinga <slouken@libsdl.org>
parents: 8972
diff changeset
   114
#endif
8972
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents: 8920
diff changeset
   115
dfc759d7486f Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
Sam Lantinga <slouken@libsdl.org>
parents: 8920
diff changeset
   116
#endif /* _SDL_sysjoystick_h */
6707
70eeb7e3ec2f Organized joystick hotplug code a bit.
Sam Lantinga <slouken@libsdl.org>
parents: 6701
diff changeset
   117
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   118
/* vi: set ts=4 sw=4 expandtab: */