include/SDL_gamecontroller.h
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Mon, 20 Apr 2015 20:03:40 +0200
changeset 9569 162adf32623f
parent 9359 3d0af39849fa
child 9619 b94b6d0bff0f
permissions -rw-r--r--
Fixed SDL_GameControllerOpen() and SDL_JoystickOpen() documentation in header.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
  Simple DirectMedia Layer
8149
681eb46b8ac4 Fixed bug 2374 - Update copyright for 2014...
Sam Lantinga <slouken@libsdl.org>
parents: 8051
diff changeset
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
  This software is provided 'as-is', without any express or implied
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
  arising from the use of this software.
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
  freely, subject to the following restrictions:
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
     claim that you wrote the original software. If you use this software
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
     appreciated but is not required.
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
     misrepresented as being the original software.
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
*/
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
 *  \file SDL_gamecontroller.h
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
    24
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
 *  Include file for SDL game controller event handling
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
 */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
#ifndef _SDL_gamecontroller_h
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
#define _SDL_gamecontroller_h
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
#include "SDL_stdinc.h"
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
#include "SDL_error.h"
8051
a6981e0b9fe2 Added missing header for file IO
Sam Lantinga <slouken@libsdl.org>
parents: 8046
diff changeset
    33
#include "SDL_rwops.h"
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
#include "SDL_joystick.h"
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
#include "begin_code.h"
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
/* Set up for C function definitions, even when using C++ */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
#ifdef __cplusplus
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
extern "C" {
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
#endif
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
 *  \file SDL_gamecontroller.h
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
 *
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
 *  In order to use these functions, SDL_Init() must have been called
9225
5b97e1f05e53 Corrected header file documentation comment.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8149
diff changeset
    46
 *  with the ::SDL_INIT_GAMECONTROLLER flag.  This causes SDL to scan the system
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
 *  for game controllers, and load appropriate drivers.
7341
675c85d46f30 Added SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS to the documentation for the joystick and game controller APIs
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
    48
 *
675c85d46f30 Added SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS to the documentation for the joystick and game controller APIs
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
    49
 *  If you would like to receive controller updates while the application
675c85d46f30 Added SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS to the documentation for the joystick and game controller APIs
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
    50
 *  is in the background, you should set the following hint before calling
675c85d46f30 Added SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS to the documentation for the joystick and game controller APIs
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
    51
 *  SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
 */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
/* The gamecontroller structure used to identify an SDL game controller */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
struct _SDL_GameController;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
typedef struct _SDL_GameController SDL_GameController;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
    59
typedef enum
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    61
    SDL_CONTROLLER_BINDTYPE_NONE = 0,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    62
    SDL_CONTROLLER_BINDTYPE_BUTTON,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    63
    SDL_CONTROLLER_BINDTYPE_AXIS,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    64
    SDL_CONTROLLER_BINDTYPE_HAT
6917
47dc155b774d Changed the game controller enum types to match SDL naming conventions.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
    65
} SDL_GameControllerBindType;
47dc155b774d Changed the game controller enum types to match SDL naming conventions.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
    66
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
/**
6932
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
    68
 *  Get the SDL joystick layer binding for this controller button/axis mapping
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
 */
6932
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
    70
typedef struct SDL_GameControllerButtonBind
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    72
    SDL_GameControllerBindType bindType;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    73
    union
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    74
    {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    75
        int button;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    76
        int axis;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    77
        struct {
6932
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
    78
            int hat;
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
    79
            int hat_mask;
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
    80
        } hat;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    81
    } value;
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
} SDL_GameControllerButtonBind;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
 *  To count the number of game controllers in the system for the following:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    88
 *  int nJoysticks = SDL_NumJoysticks();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    89
 *  int nGameControllers = 0;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    90
 *  for ( int i = 0; i < nJoysticks; i++ ) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    91
 *      if ( SDL_IsGameController(i) ) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    92
 *          nGameControllers++;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    93
 *      }
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
 *  }
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
 *
6964
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
    96
 *  Using the SDL_HINT_GAMECONTROLLERCONFIG hint or the SDL_GameControllerAddMapping you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
    97
 *  guid,name,mappings
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
 *
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
 *  Where GUID is the string value from SDL_JoystickGetGUIDString(), name is the human readable string for the device and mappings are controller mappings to joystick ones.
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
 *  Under Windows there is a reserved GUID of "xinput" that covers any XInput devices.
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   101
 *  The mapping format for joystick is:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   102
 *      bX - a joystick button, index X
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   103
 *      hX.Y - hat X with value Y
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   104
 *      aX - axis X of the joystick
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
 *  Buttons can be used as a controller axis and vice versa.
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
 *
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
 *  This string shows an example of a valid mapping for a controller
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   108
 *  "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7",
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
 *
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
 */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
6964
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   112
/**
8046
e7c89b29932a Adds SDL_GameControllerAddMappingsFromRW, updates controllermap
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8042
diff changeset
   113
 *  Load a set of mappings from a seekable SDL data stream (memory or file), filtered by the current SDL_GetPlatform()
8042
7863121cb7d5 Adds SDL_GameControllerAddMappingsFromFile
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7341
diff changeset
   114
 *  A community sourced database of controllers is available at https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt
7863121cb7d5 Adds SDL_GameControllerAddMappingsFromFile
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7341
diff changeset
   115
 *
8046
e7c89b29932a Adds SDL_GameControllerAddMappingsFromRW, updates controllermap
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8042
diff changeset
   116
 *  If \c freerw is non-zero, the stream will be closed after being read.
e7c89b29932a Adds SDL_GameControllerAddMappingsFromRW, updates controllermap
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8042
diff changeset
   117
 * 
8042
7863121cb7d5 Adds SDL_GameControllerAddMappingsFromFile
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7341
diff changeset
   118
 * \return number of mappings added, -1 on error
7863121cb7d5 Adds SDL_GameControllerAddMappingsFromFile
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7341
diff changeset
   119
 */
8046
e7c89b29932a Adds SDL_GameControllerAddMappingsFromRW, updates controllermap
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8042
diff changeset
   120
extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW( SDL_RWops * rw, int freerw );
e7c89b29932a Adds SDL_GameControllerAddMappingsFromRW, updates controllermap
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8042
diff changeset
   121
e7c89b29932a Adds SDL_GameControllerAddMappingsFromRW, updates controllermap
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8042
diff changeset
   122
/**
e7c89b29932a Adds SDL_GameControllerAddMappingsFromRW, updates controllermap
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8042
diff changeset
   123
 *  Load a set of mappings from a file, filtered by the current SDL_GetPlatform()
e7c89b29932a Adds SDL_GameControllerAddMappingsFromRW, updates controllermap
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8042
diff changeset
   124
 *
e7c89b29932a Adds SDL_GameControllerAddMappingsFromRW, updates controllermap
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8042
diff changeset
   125
 *  Convenience macro.
e7c89b29932a Adds SDL_GameControllerAddMappingsFromRW, updates controllermap
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8042
diff changeset
   126
 */
e7c89b29932a Adds SDL_GameControllerAddMappingsFromRW, updates controllermap
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8042
diff changeset
   127
#define SDL_GameControllerAddMappingsFromFile(file)   SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1)
8042
7863121cb7d5 Adds SDL_GameControllerAddMappingsFromFile
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7341
diff changeset
   128
7863121cb7d5 Adds SDL_GameControllerAddMappingsFromFile
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7341
diff changeset
   129
/**
6964
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   130
 *  Add or update an existing mapping configuration
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   131
 *
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   132
 * \return 1 if mapping is added, 0 if updated, -1 on error
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   133
 */
7061
45df4552bdfe Fixed a typo (thanks, Ethan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 6964
diff changeset
   134
extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping( const char* mappingString );
6964
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   135
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   136
/**
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   137
 *  Get a mapping string for a GUID
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   138
 *
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   139
 *  \return the mapping string.  Must be freed with SDL_free.  Returns NULL if no mapping is available
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   140
 */
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   141
extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID( SDL_JoystickGUID guid );
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   142
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   143
/**
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   144
 *  Get a mapping string for an open GameController
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   145
 *
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   146
 *  \return the mapping string.  Must be freed with SDL_free.  Returns NULL if no mapping is available
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   147
 */
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   148
extern DECLSPEC char * SDLCALL SDL_GameControllerMapping( SDL_GameController * gamecontroller );
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   149
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   150
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
 *  Is the joystick on this index supported by the game controller interface?
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   152
 */
6871
bd681c870ccf Check bounds in SDL_IsGameController. Switch two functions to SDL_bool.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6795
diff changeset
   153
extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index);
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
 *  Get the implementation dependent name of a game controller.
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   158
 *  This can be called before any controllers are opened.
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   159
 *  If no name can be found, this function returns NULL.
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
 */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index);
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
/**
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   164
 *  Open a game controller for use.
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   165
 *  The index passed as an argument refers to the N'th game controller on the system.
9569
162adf32623f Fixed SDL_GameControllerOpen() and SDL_JoystickOpen() documentation in header.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9359
diff changeset
   166
 *  This index is not the value which will identify this controller in future
162adf32623f Fixed SDL_GameControllerOpen() and SDL_JoystickOpen() documentation in header.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9359
diff changeset
   167
 *  controller events.  The joystick's instance id (::SDL_JoystickID) will be
162adf32623f Fixed SDL_GameControllerOpen() and SDL_JoystickOpen() documentation in header.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9359
diff changeset
   168
 *  used there instead.
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   169
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
 *  \return A controller identifier, or NULL if an error occurred.
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
 */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index);
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   173
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   174
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   175
 *  Return the name for this currently opened controller
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   176
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   177
extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller);
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   178
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   179
/**
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   180
 *  Returns SDL_TRUE if the controller has been opened and currently connected,
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   181
 *  or SDL_FALSE if it has not.
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   182
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   183
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller);
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   184
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   185
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   186
 *  Get the underlying joystick object used by a controller
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   187
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   188
extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller);
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   190
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   191
 *  Enable/disable controller event polling.
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   192
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   193
 *  If controller events are disabled, you must call SDL_GameControllerUpdate()
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   194
 *  yourself and check the state of the controller when you want controller
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   195
 *  information.
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   196
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   197
 *  The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE.
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   198
 */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   199
extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state);
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   200
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   201
/**
6919
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   202
 *  Update the current state of the open game controllers.
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   203
 *
6919
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   204
 *  This is called automatically by the event loop if any game controller
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   205
 *  events are enabled.
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   206
 */
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   207
extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void);
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   208
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   209
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   210
/**
7174
3dfec8235a71 Corrected spelling in header file.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7125
diff changeset
   211
 *  The list of axes available from a controller
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   212
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   213
typedef enum
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   214
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   215
    SDL_CONTROLLER_AXIS_INVALID = -1,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   216
    SDL_CONTROLLER_AXIS_LEFTX,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   217
    SDL_CONTROLLER_AXIS_LEFTY,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   218
    SDL_CONTROLLER_AXIS_RIGHTX,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   219
    SDL_CONTROLLER_AXIS_RIGHTY,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   220
    SDL_CONTROLLER_AXIS_TRIGGERLEFT,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   221
    SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   222
    SDL_CONTROLLER_AXIS_MAX
6917
47dc155b774d Changed the game controller enum types to match SDL naming conventions.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   223
} SDL_GameControllerAxis;
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   224
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   225
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   226
 *  turn this string into a axis mapping
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   227
 */
6917
47dc155b774d Changed the game controller enum types to match SDL naming conventions.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   228
extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *pchString);
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   229
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   230
/**
6964
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   231
 *  turn this axis enum into a string mapping
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   232
 */
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   233
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis);
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   234
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   235
/**
6932
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
   236
 *  Get the SDL joystick layer binding for this controller button mapping
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   237
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   238
extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   239
SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
6917
47dc155b774d Changed the game controller enum types to match SDL naming conventions.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   240
                                 SDL_GameControllerAxis axis);
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   241
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   242
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   243
 *  Get the current state of an axis control on a game controller.
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   244
 *
9359
3d0af39849fa Corrected documentation about triggers values in SDL_GameControllerGetAxis().
Ryan C. Gordon <icculus@icculus.org>
parents: 9225
diff changeset
   245
 *  The state is a value ranging from -32768 to 32767 (except for the triggers,
3d0af39849fa Corrected documentation about triggers values in SDL_GameControllerGetAxis().
Ryan C. Gordon <icculus@icculus.org>
parents: 9225
diff changeset
   246
 *  which range from 0 to 32767).
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   247
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   248
 *  The axis indices start at index 0.
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   249
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   250
extern DECLSPEC Sint16 SDLCALL
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   251
SDL_GameControllerGetAxis(SDL_GameController *gamecontroller,
6917
47dc155b774d Changed the game controller enum types to match SDL naming conventions.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   252
                          SDL_GameControllerAxis axis);
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   253
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   254
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   255
 *  The list of buttons available from a controller
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   256
 */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   257
typedef enum
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   258
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   259
    SDL_CONTROLLER_BUTTON_INVALID = -1,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   260
    SDL_CONTROLLER_BUTTON_A,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   261
    SDL_CONTROLLER_BUTTON_B,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   262
    SDL_CONTROLLER_BUTTON_X,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   263
    SDL_CONTROLLER_BUTTON_Y,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   264
    SDL_CONTROLLER_BUTTON_BACK,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   265
    SDL_CONTROLLER_BUTTON_GUIDE,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   266
    SDL_CONTROLLER_BUTTON_START,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   267
    SDL_CONTROLLER_BUTTON_LEFTSTICK,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   268
    SDL_CONTROLLER_BUTTON_RIGHTSTICK,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   269
    SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   270
    SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   271
    SDL_CONTROLLER_BUTTON_DPAD_UP,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   272
    SDL_CONTROLLER_BUTTON_DPAD_DOWN,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   273
    SDL_CONTROLLER_BUTTON_DPAD_LEFT,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   274
    SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   275
    SDL_CONTROLLER_BUTTON_MAX
6917
47dc155b774d Changed the game controller enum types to match SDL naming conventions.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   276
} SDL_GameControllerButton;
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   277
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   278
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   279
 *  turn this string into a button mapping
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   280
 */
6917
47dc155b774d Changed the game controller enum types to match SDL naming conventions.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   281
extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *pchString);
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   282
6964
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   283
/**
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   284
 *  turn this button enum into a string mapping
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   285
 */
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   286
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button);
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   287
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   288
/**
6932
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
   289
 *  Get the SDL joystick layer binding for this controller button mapping
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   290
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   291
extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   292
SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
6917
47dc155b774d Changed the game controller enum types to match SDL naming conventions.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   293
                                   SDL_GameControllerButton button);
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   294
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   295
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   296
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   297
 *  Get the current state of a button on a game controller.
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   298
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   299
 *  The button indices start at index 0.
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   300
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   301
extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller,
6917
47dc155b774d Changed the game controller enum types to match SDL naming conventions.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   302
                                                          SDL_GameControllerButton button);
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   303
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   304
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   305
 *  Close a controller previously opened with SDL_GameControllerOpen().
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   306
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   307
extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller);
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   308
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   309
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   310
/* Ends C function definitions when using C++ */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   311
#ifdef __cplusplus
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   312
}
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   313
#endif
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   314
#include "close_code.h"
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   315
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   316
#endif /* _SDL_gamecontroller_h */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   317
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   318
/* vi: set ts=4 sw=4 expandtab: */