include/SDL_gamecontroller.h
author Edward Rudd <urkle@outoforder.cc>
Tue, 05 Mar 2013 17:59:36 -0500
changeset 6964 c8aa24f05042
parent 6932 361bebe92c66
child 7061 45df4552bdfe
permissions -rw-r--r--
add new gamecontroller APIs - add mappings after init (or even before w/o using the hint) - get string for axis - get string for button - get mapping string for controller or for GUID - new event to notify when a controller is remapped. (e.g. mapping was changed via the AddMapping method)
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"
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
#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
    34
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
#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
    36
/* 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
    37
#ifdef __cplusplus
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
/* *INDENT-OFF* */
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
/* *INDENT-ON* */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
#endif
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
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
 *  \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
    45
 *
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
 *  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
    47
 *  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
    48
 *  for game controllers, and load appropriate drivers.
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
 */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
/* 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
    52
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
    53
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
    54
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
    56
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
    57
{
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
	SDL_CONTROLLER_BINDTYPE_NONE = 0,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
	SDL_CONTROLLER_BINDTYPE_BUTTON,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
	SDL_CONTROLLER_BINDTYPE_AXIS,
6795
f445268492a7 Fixed bug 1653 - comma at the end of enum
Sam Lantinga <slouken@libsdl.org>
parents: 6690
diff changeset
    61
	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
    62
} SDL_GameControllerBindType;
47dc155b774d Changed the game controller enum types to match SDL naming conventions.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
    63
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
/**
6932
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
    65
 *  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
    66
 */
6932
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
    67
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
    68
{
6932
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
    69
	SDL_GameControllerBindType bindType;
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
	union
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
	{
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
		int button;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
		int axis;
6932
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
    74
		struct {
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
    75
            int hat;
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
    76
            int hat_mask;
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
    77
        } hat;
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
    78
	} value;
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
} SDL_GameControllerButtonBind;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
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
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
 *  To count the number of game controllers in the system for the following:
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
 *	int nJoysticks = SDL_NumJoysticks();
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
 *	int nGameControllers = 0;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
 *	for ( int i = 0; i < nJoysticks; i++ ) {
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
 *		if ( SDL_IsGameController(i) ) {
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
 *			nGameControllers++;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
 *		}
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
 *  }
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
 *
6964
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
    93
 *  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:
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
 *	guid,name,mappings
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
 *
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
 *  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
    97
 *  Under Windows there is a reserved GUID of "xinput" that covers any XInput devices.
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
    98
 *	The mapping format for joystick is:
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
 *		bX - a joystick button, index X
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
 *		hX.Y - hat X with value Y
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
 *		aX - axis X of the joystick
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
 *  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
   103
 *
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
 *  This string shows an example of a valid mapping for a controller
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
 * 	"341a3608000000000000504944564944,Aferglow 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",
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
 */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
6964
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   109
/**
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   110
 *  Add or update an existing mapping configuration
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   111
 *
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   112
 * \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
   113
 */
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   114
extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping( const char* mappingSring );
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   115
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   116
/**
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   117
 *  Get a mapping string for a GUID
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   118
 *
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   119
 *  \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
   120
 */
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   121
extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID( SDL_JoystickGUID guid );
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   122
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   123
/**
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   124
 *  Get a mapping string for an open GameController
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   125
 *
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   126
 *  \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
   127
 */
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   128
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
   129
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
 *  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
   132
 */
6871
bd681c870ccf Check bounds in SDL_IsGameController. Switch two functions to SDL_bool.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6795
diff changeset
   133
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
   134
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
 *  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
   138
 *  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
   139
 *  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
   140
 */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
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
   142
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
/**
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   144
 *  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
   145
 *  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
   146
 *  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
   147
 *  events.
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   148
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   149
 *  \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
   150
 */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
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
   152
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   153
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
 *  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
   155
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   156
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
   157
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   158
/**
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   159
 *  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
   160
 *  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
   161
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   162
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
   163
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   164
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   165
 *  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
   166
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   167
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
   168
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
 *  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
   171
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
 *  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
   173
 *  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
   174
 *  information.
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   175
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   176
 *  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
   177
 */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   178
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
   179
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   180
/**
6919
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   181
 *  Update the current state of the open game controllers.
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   182
 *  
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   183
 *  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
   184
 *  events are enabled.
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   185
 */
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   186
extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void);
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   187
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   188
c9c75d062fa8 Added SDL_GameControllerUpdate().
Ryan C. Gordon <icculus@icculus.org>
parents: 6917
diff changeset
   189
/**
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   190
 *  The list of axii 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
   191
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   192
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
   193
{
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   194
	SDL_CONTROLLER_AXIS_INVALID = -1,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   195
	SDL_CONTROLLER_AXIS_LEFTX,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   196
	SDL_CONTROLLER_AXIS_LEFTY,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   197
	SDL_CONTROLLER_AXIS_RIGHTX,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   198
	SDL_CONTROLLER_AXIS_RIGHTY,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   199
	SDL_CONTROLLER_AXIS_TRIGGERLEFT,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   200
	SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   201
	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
   202
} 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
   203
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   204
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   205
 *  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
   206
 */
6917
47dc155b774d Changed the game controller enum types to match SDL naming conventions.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   207
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
   208
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   209
/**
6964
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   210
 *  turn this axis enum into a string mapping
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   211
 */
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   212
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis);
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   213
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   214
/**
6932
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
   215
 *  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
   216
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   217
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
   218
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
   219
                                 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
   220
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   221
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   222
 *  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
   223
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   224
 *  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
   225
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   226
 *  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
   227
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   228
extern DECLSPEC Sint16 SDLCALL
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   229
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
   230
                          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
   231
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   232
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   233
 *  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
   234
 */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   235
typedef enum
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   236
{
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   237
	SDL_CONTROLLER_BUTTON_INVALID = -1,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   238
	SDL_CONTROLLER_BUTTON_A,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   239
	SDL_CONTROLLER_BUTTON_B,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   240
	SDL_CONTROLLER_BUTTON_X,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   241
	SDL_CONTROLLER_BUTTON_Y,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   242
	SDL_CONTROLLER_BUTTON_BACK,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   243
	SDL_CONTROLLER_BUTTON_GUIDE,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   244
	SDL_CONTROLLER_BUTTON_START,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   245
	SDL_CONTROLLER_BUTTON_LEFTSTICK,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   246
	SDL_CONTROLLER_BUTTON_RIGHTSTICK,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   247
	SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   248
	SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   249
	SDL_CONTROLLER_BUTTON_DPAD_UP,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   250
	SDL_CONTROLLER_BUTTON_DPAD_DOWN,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   251
	SDL_CONTROLLER_BUTTON_DPAD_LEFT,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   252
	SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   253
	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
   254
} 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
   255
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
 *  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
   258
 */
6917
47dc155b774d Changed the game controller enum types to match SDL naming conventions.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   259
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
   260
6964
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   261
/**
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   262
 *  turn this button enum into a string mapping
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   263
 */
c8aa24f05042 add new gamecontroller APIs
Edward Rudd <urkle@outoforder.cc>
parents: 6932
diff changeset
   264
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
   265
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   266
/**
6932
361bebe92c66 Fixed gcc pedantic warnings in public headers
Sam Lantinga <slouken@libsdl.org>
parents: 6919
diff changeset
   267
 *  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
   268
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   269
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
   270
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
   271
                                   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
   272
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   273
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   274
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   275
 *  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
   276
 *
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   277
 *  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
   278
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   279
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
   280
                                                          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
   281
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   282
/**
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   283
 *  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
   284
 */
6873
f042ae287155 New SDL_MSBIndex, updated VS projects, cleanup gamecontroller.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6871
diff changeset
   285
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
   286
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
/* 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
   289
#ifdef __cplusplus
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   290
/* *INDENT-OFF* */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   291
}
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   292
/* *INDENT-ON* */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   293
#endif
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   294
#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
   295
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   296
#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
   297
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   298
/* vi: set ts=4 sw=4 expandtab: */