include/SDL_gamecontroller.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 05 Dec 2013 09:54:22 -0800
changeset 8051 a6981e0b9fe2
parent 8046 e7c89b29932a
child 8149 681eb46b8ac4
permissions -rw-r--r--
Added missing header for file IO
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
6885
700f1b25f77f Happy New Year!
Sam Lantinga <slouken@libsdl.org>
parents: 6873
diff changeset
     3
  Copyright (C) 1997-2013 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
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
 *  with the ::SDL_INIT_JOYSTICK flag.  This causes SDL to scan the system
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.
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   166
 *  This index is the value which will identify this controller in future controller
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
 *  events.
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   168
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
 *  \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
   170
 */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
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
   172
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
 *  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
   175
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   176
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
   177
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   178
/**
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   179
 *  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
   180
 *  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
   181
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   182
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
   183
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
 *  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
   186
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   187
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
   188
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
 *  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
   191
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   192
 *  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
   193
 *  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
   194
 *  information.
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   195
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   196
 *  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
   197
 */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   198
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
   199
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   200
/**
6919
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   201
 *  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
   202
 *
6919
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   203
 *  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
   204
 *  events are enabled.
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   205
 */
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   206
extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void);
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   207
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
/**
7174
3dfec8235a71 Corrected spelling in header file.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7125
diff changeset
   210
 *  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
   211
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   212
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
   213
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   214
    SDL_CONTROLLER_AXIS_INVALID = -1,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   215
    SDL_CONTROLLER_AXIS_LEFTX,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   216
    SDL_CONTROLLER_AXIS_LEFTY,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   217
    SDL_CONTROLLER_AXIS_RIGHTX,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   218
    SDL_CONTROLLER_AXIS_RIGHTY,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   219
    SDL_CONTROLLER_AXIS_TRIGGERLEFT,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   220
    SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   221
    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
   222
} 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
   223
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
 *  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
   226
 */
6917
47dc155b774d Changed the game controller enum types to match SDL naming conventions.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   227
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
   228
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   229
/**
6964
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   230
 *  turn this axis enum into a string mapping
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   231
 */
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   232
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis);
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   233
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   234
/**
6932
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
   235
 *  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
   236
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   237
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
   238
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
   239
                                 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
   240
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
 *  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
   243
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   244
 *  The state is a value ranging from -32768 to 32767.
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   245
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   246
 *  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
   247
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   248
extern DECLSPEC Sint16 SDLCALL
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   249
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
   250
                          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
   251
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   252
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   253
 *  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
   254
 */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   255
typedef enum
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   256
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   257
    SDL_CONTROLLER_BUTTON_INVALID = -1,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   258
    SDL_CONTROLLER_BUTTON_A,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   259
    SDL_CONTROLLER_BUTTON_B,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   260
    SDL_CONTROLLER_BUTTON_X,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   261
    SDL_CONTROLLER_BUTTON_Y,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   262
    SDL_CONTROLLER_BUTTON_BACK,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   263
    SDL_CONTROLLER_BUTTON_GUIDE,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   264
    SDL_CONTROLLER_BUTTON_START,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   265
    SDL_CONTROLLER_BUTTON_LEFTSTICK,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   266
    SDL_CONTROLLER_BUTTON_RIGHTSTICK,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   267
    SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   268
    SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   269
    SDL_CONTROLLER_BUTTON_DPAD_UP,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   270
    SDL_CONTROLLER_BUTTON_DPAD_DOWN,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   271
    SDL_CONTROLLER_BUTTON_DPAD_LEFT,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   272
    SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7174
diff changeset
   273
    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
   274
} 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
   275
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   276
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   277
 *  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
   278
 */
6917
47dc155b774d Changed the game controller enum types to match SDL naming conventions.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   279
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
   280
6964
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   281
/**
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   282
 *  turn this button enum into a string mapping
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
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
   285
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   286
/**
6932
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
   287
 *  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
   288
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   289
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
   290
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
   291
                                   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
   292
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   293
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
 *  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
   296
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   297
 *  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
   298
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   299
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
   300
                                                          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
   301
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   302
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   303
 *  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
   304
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   305
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
   306
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   307
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   308
/* 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
   309
#ifdef __cplusplus
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   310
}
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   311
#endif
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   312
#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
   313
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   314
#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
   315
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   316
/* vi: set ts=4 sw=4 expandtab: */