include/SDL_joystick.h
author Ozkan Sezer <sezeroz@gmail.com>
Sun, 14 Oct 2018 15:25:04 +0300
branchSDL-1.2
changeset 12325 c4f2eeda176f
parent 6137 4720145f848b
permissions -rw-r--r--
remove symlink for libSDL-1.0.so.0 from the rpm spec file.

also fix a changelog date.
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@6137
     3
    Copyright (C) 1997-2012 Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@0
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@251
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@0
    22
slouken@4217
    23
/** @file SDL_joystick.h
slouken@4217
    24
 *  Include file for SDL joystick event handling
slouken@4217
    25
 */
slouken@0
    26
slouken@0
    27
#ifndef _SDL_joystick_h
slouken@0
    28
#define _SDL_joystick_h
slouken@0
    29
slouken@1356
    30
#include "SDL_stdinc.h"
slouken@1358
    31
#include "SDL_error.h"
slouken@0
    32
slouken@0
    33
#include "begin_code.h"
slouken@0
    34
/* Set up for C function definitions, even when using C++ */
slouken@0
    35
#ifdef __cplusplus
slouken@0
    36
extern "C" {
slouken@0
    37
#endif
slouken@0
    38
slouken@4217
    39
/** @file SDL_joystick.h
slouken@4217
    40
 *  @note In order to use these functions, SDL_Init() must have been called
slouken@4217
    41
 *        with the SDL_INIT_JOYSTICK flag.  This causes SDL to scan the system
slouken@4217
    42
 *        for joysticks, and load appropriate drivers.
slouken@4217
    43
 */
slouken@0
    44
slouken@4217
    45
/** The joystick structure used to identify an SDL joystick */
slouken@0
    46
struct _SDL_Joystick;
slouken@0
    47
typedef struct _SDL_Joystick SDL_Joystick;
slouken@0
    48
slouken@0
    49
/* Function prototypes */
slouken@4217
    50
/**
slouken@0
    51
 * Count the number of joysticks attached to the system
slouken@0
    52
 */
slouken@337
    53
extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
slouken@0
    54
slouken@4217
    55
/**
slouken@0
    56
 * Get the implementation dependent name of a joystick.
slouken@4217
    57
 *
slouken@0
    58
 * This can be called before any joysticks are opened.
slouken@0
    59
 * If no name can be found, this function returns NULL.
slouken@0
    60
 */
slouken@337
    61
extern DECLSPEC const char * SDLCALL SDL_JoystickName(int device_index);
slouken@0
    62
slouken@4217
    63
/**
slouken@4217
    64
 * Open a joystick for use.
slouken@4217
    65
 *
slouken@4217
    66
 * @param[in] device_index
slouken@4217
    67
 * The index passed as an argument refers to
slouken@0
    68
 * the N'th joystick on the system.  This index is the value which will
slouken@0
    69
 * identify this joystick in future joystick events.
slouken@0
    70
 *
slouken@4217
    71
 * @return This function returns a joystick identifier, or NULL if an error occurred.
slouken@0
    72
 */
slouken@905
    73
extern DECLSPEC SDL_Joystick * SDLCALL SDL_JoystickOpen(int device_index);
slouken@0
    74
slouken@4217
    75
/**
slouken@0
    76
 * Returns 1 if the joystick has been opened, or 0 if it has not.
slouken@0
    77
 */
slouken@337
    78
extern DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index);
slouken@0
    79
slouken@4217
    80
/**
slouken@0
    81
 * Get the device index of an opened joystick.
slouken@0
    82
 */
slouken@337
    83
extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick *joystick);
slouken@0
    84
slouken@4217
    85
/**
slouken@0
    86
 * Get the number of general axis controls on a joystick
slouken@0
    87
 */
slouken@337
    88
extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick);
slouken@0
    89
slouken@4217
    90
/**
slouken@0
    91
 * Get the number of trackballs on a joystick
slouken@4217
    92
 *
slouken@0
    93
 * Joystick trackballs have only relative motion events associated
slouken@0
    94
 * with them and their state cannot be polled.
slouken@0
    95
 */
slouken@337
    96
extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick);
slouken@0
    97
slouken@4217
    98
/**
slouken@0
    99
 * Get the number of POV hats on a joystick
slouken@0
   100
 */
slouken@337
   101
extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick);
slouken@0
   102
slouken@4217
   103
/**
slouken@0
   104
 * Get the number of buttons on a joystick
slouken@0
   105
 */
slouken@337
   106
extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick);
slouken@0
   107
slouken@4217
   108
/**
slouken@0
   109
 * Update the current state of the open joysticks.
slouken@4217
   110
 *
slouken@0
   111
 * This is called automatically by the event loop if any joystick
slouken@0
   112
 * events are enabled.
slouken@0
   113
 */
slouken@337
   114
extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
slouken@0
   115
slouken@4217
   116
/**
slouken@0
   117
 * Enable/disable joystick event polling.
slouken@4217
   118
 *
slouken@0
   119
 * If joystick events are disabled, you must call SDL_JoystickUpdate()
slouken@0
   120
 * yourself and check the state of the joystick when you want joystick
slouken@0
   121
 * information.
slouken@4217
   122
 *
slouken@4217
   123
 * @param[in] state The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
slouken@0
   124
 */
slouken@337
   125
extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
slouken@0
   126
slouken@4217
   127
/**
slouken@0
   128
 * Get the current state of an axis control on a joystick
slouken@4217
   129
 *
slouken@4217
   130
 * @param[in] axis The axis indices start at index 0.
slouken@4217
   131
 *
slouken@4217
   132
 * @return The state is a value ranging from -32768 to 32767.
slouken@0
   133
 */
slouken@337
   134
extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis);
slouken@0
   135
slouken@4217
   136
/**
slouken@4217
   137
 *  @name Hat Positions
slouken@4217
   138
 *  The return value of SDL_JoystickGetHat() is one of the following positions:
slouken@0
   139
 */
slouken@4217
   140
/*@{*/
slouken@0
   141
#define SDL_HAT_CENTERED	0x00
slouken@0
   142
#define SDL_HAT_UP		0x01
slouken@0
   143
#define SDL_HAT_RIGHT		0x02
slouken@0
   144
#define SDL_HAT_DOWN		0x04
slouken@0
   145
#define SDL_HAT_LEFT		0x08
slouken@0
   146
#define SDL_HAT_RIGHTUP		(SDL_HAT_RIGHT|SDL_HAT_UP)
slouken@0
   147
#define SDL_HAT_RIGHTDOWN	(SDL_HAT_RIGHT|SDL_HAT_DOWN)
slouken@0
   148
#define SDL_HAT_LEFTUP		(SDL_HAT_LEFT|SDL_HAT_UP)
slouken@0
   149
#define SDL_HAT_LEFTDOWN	(SDL_HAT_LEFT|SDL_HAT_DOWN)
slouken@4217
   150
/*@}*/
slouken@4217
   151
slouken@4217
   152
/** 
slouken@4217
   153
 *  Get the current state of a POV hat on a joystick
slouken@4217
   154
 *
slouken@4217
   155
 *  @param[in] hat The hat indices start at index 0.
slouken@0
   156
 */
slouken@337
   157
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick, int hat);
slouken@0
   158
slouken@4217
   159
/**
slouken@0
   160
 * Get the ball axis change since the last poll
slouken@4217
   161
 *
slouken@4217
   162
 * @param[in] ball The ball indices start at index 0.
slouken@4217
   163
 *
slouken@4217
   164
 * @return This returns 0, or -1 if you passed it invalid parameters.
slouken@0
   165
 */
slouken@337
   166
extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);
slouken@0
   167
slouken@4217
   168
/**
slouken@0
   169
 * Get the current state of a button on a joystick
slouken@4217
   170
 *
slouken@4217
   171
 * @param[in] button The button indices start at index 0.
slouken@0
   172
 */
slouken@337
   173
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick, int button);
slouken@0
   174
slouken@4217
   175
/**
slouken@0
   176
 * Close a joystick previously opened with SDL_JoystickOpen()
slouken@0
   177
 */
slouken@337
   178
extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick);
slouken@0
   179
slouken@0
   180
slouken@0
   181
/* Ends C function definitions when using C++ */
slouken@0
   182
#ifdef __cplusplus
slouken@0
   183
}
slouken@0
   184
#endif
slouken@0
   185
#include "close_code.h"
slouken@0
   186
slouken@0
   187
#endif /* _SDL_joystick_h */