including commercial applications, and to alter it and redistribute it

freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not

claim that you wrote the original software. If you use this software

in a product, an acknowledgment in the product documentation would be

appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be

misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.

*/

/**

* \file SDL_gamecontroller.h

*

* Include file for SDL game controller event handling

*/

#ifndef SDL_gamecontroller_h_

#define SDL_gamecontroller_h_

#include"SDL_stdinc.h"

#include"SDL_error.h"

#include"SDL_rwops.h"

#include"SDL_joystick.h"

#include"begin_code.h"

/* Set up for C function definitions, even when using C++ */

#ifdef __cplusplus

extern"C"{

#endif

/**

* \file SDL_gamecontroller.h

*

* In order to use these functions, SDL_Init() must have been called

* with the ::SDL_INIT_GAMECONTROLLER flag. This causes SDL to scan the system

* for game controllers, and load appropriate drivers.

*

* If you would like to receive controller updates while the application

* is in the background, you should set the following hint before calling

* SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS

*/

/**

* The gamecontroller structure used to identify an SDL game controller

*/

struct _SDL_GameController;

typedefstruct _SDL_GameController SDL_GameController;

typedefenum

{

SDL_CONTROLLER_BINDTYPE_NONE =0,

SDL_CONTROLLER_BINDTYPE_BUTTON,

SDL_CONTROLLER_BINDTYPE_AXIS,

SDL_CONTROLLER_BINDTYPE_HAT

} SDL_GameControllerBindType;

/**

* Get the SDL joystick layer binding for this controller button/axis mapping

*/

typedefstruct SDL_GameControllerButtonBind

{

SDL_GameControllerBindType bindType;

union

{

int button;

int axis;

struct{

int hat;

int hat_mask;

} hat;

} value;

} SDL_GameControllerButtonBind;

/**

* To count the number of game controllers in the system for the following:

* int nJoysticks = SDL_NumJoysticks();

* int nGameControllers = 0;

* for (int i = 0; i < nJoysticks; i++) {

* if (SDL_IsGameController(i)) {

* nGameControllers++;

* }

* }

*

* 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:

* guid,name,mappings

*

* 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.

* Under Windows there is a reserved GUID of "xinput" that covers any XInput devices.