actual version
[sdl-headers.git] / sdljoystick.inc
1 //from "sdl_joystick.h"
2
3   {**
4    *  SDL_joystick.h
5    *
6    *  In order to use these functions, SDL_Init() must have been called
7    *  with the ::SDL_INIT_JOYSTICK flag.  This causes SDL to scan the system
8    *  for joysticks, and load appropriate drivers.
9    *}
10
11 type
12
13   {* The joystick structure used to identify an SDL joystick *}
14   PSDL_Joystick = Pointer; // todo!!
15
16 {* A structure that encodes the stable unique id for a joystick device *}
17
18   TSDL_JoystickGUID = record
19     data: array[0..15] of UInt8;
20   end;
21
22   TSDL_JoystickID = SInt32;
23
24   {* Function prototypes *}
25   {**
26    *  Count the number of joysticks attached to the system right now
27    *}
28 function SDL_NumJoysticks: SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_NumJoysticks' {$ENDIF} {$ENDIF};
29
30   {**
31    *  Get the implementation dependent name of a joystick.
32    *  This can be called before any joysticks are opened.
33    *  If no name can be found, this function returns NULL.
34    *}
35 function SDL_JoystickNameForIndex(device_index: SInt32): PAnsiChar cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickNameForIndex' {$ENDIF} {$ENDIF};
36
37   {**
38    *  Open a joystick for use.
39    *  The index passed as an argument refers tothe N'th joystick on the system.
40    *  This index is the value which will identify this joystick in future joystick
41    *  events.
42    *
43    *  A joystick identifier, or NULL if an error occurred.
44    *}
45 function SDL_JoystickOpen(device_index: SInt32): PSDL_Joystick cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickOpen' {$ENDIF} {$ENDIF};
46
47   {**
48    *  Return the name for this currently opened joystick.
49    *  If no name can be found, this function returns NULL.
50    *}
51 function SDL_JoystickName(joystick: PSDL_Joystick): PAnsiChar cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickName' {$ENDIF} {$ENDIF};
52
53   {**
54    *  Return the GUID for the joystick at this index
55    *}
56 function SDL_JoystickGetDeviceGUID(device_index: SInt32): TSDL_JoystickGUID cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetDeviceGUID' {$ENDIF} {$ENDIF};
57
58   {**
59    *  Return the GUID for this opened joystick
60    *}
61 function SDL_JoystickGetGUID(joystick: PSDL_Joystick): TSDL_JoystickGUID cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetGUID' {$ENDIF} {$ENDIF};
62
63   {**
64    *  Return a string representation for this guid. pszGUID must point to at least 33 bytes
65    *  (32 for the string plus a NULL terminator).
66    *}
67 procedure SDL_JoystickGetGUIDString(guid: TSDL_JoystickGUId; pszGUID: PAnsiChar; cbGUID: SInt32) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetGUIDString' {$ENDIF} {$ENDIF};
68
69   {**
70    *  convert a string into a joystick formatted guid
71    *}
72 function SDL_JoystickGetGUIDFromString(const pchGUID: PAnsiChar): TSDL_JoystickGUID cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetGUIDFromString' {$ENDIF} {$ENDIF};
73
74   {**
75    *  Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not.
76    *}
77 function SDL_JoystickGetAttached(joystick: PSDL_Joystick): TSDL_Bool cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetAttached' {$ENDIF} {$ENDIF};
78
79   {**
80    *  Get the instance ID of an opened joystick or -1 if the joystick is invalid.
81    *}
82 function SDL_JoystickInstanceID(joystick: PSDL_Joystick): TSDL_JoystickID cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickInstanceID' {$ENDIF} {$ENDIF};
83
84   {**
85    *  Get the number of general axis controls on a joystick.
86    *}
87 function SDL_JoystickNumAxes(joystick: PSDL_Joystick): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickNumAxes' {$ENDIF} {$ENDIF};
88
89   {**
90    *  Get the number of trackballs on a joystick.
91    *
92    *  Joystick trackballs have only relative motion events associated
93    *  with them and their state cannot be polled.
94    *}
95 function SDL_JoystickNumBalls(joystick: PSDL_Joystick): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickNumBalls' {$ENDIF} {$ENDIF};
96
97   {**
98    *  Get the number of POV hats on a joystick.
99    *}
100 function SDL_JoystickNumHats(joystick: PSDL_Joystick): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickNumHats' {$ENDIF} {$ENDIF};
101
102   {**
103    *  Get the number of buttons on a joystick.
104    *}
105 function SDL_JoystickNumButtons(joystick: PSDL_Joystick): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickNumButtons' {$ENDIF} {$ENDIF};
106
107   {**
108    *  Update the current state of the open joysticks.
109    *
110    *  This is called automatically by the event loop if any joystick
111    *  events are enabled.
112    *}
113 procedure SDL_JoystickUpdate cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickUpdate' {$ENDIF} {$ENDIF};
114
115   {**
116    *  Enable/disable joystick event polling.
117    *
118    *  If joystick events are disabled, you must call SDL_JoystickUpdate()
119    *  yourself and check the state of the joystick when you want joystick
120    *  information.
121    *
122    *  The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE.
123    *}
124 function SDL_JoystickEventState(state: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickEventState' {$ENDIF} {$ENDIF};
125
126   {**
127    *  Get the current state of an axis control on a joystick.
128    *
129    *  The state is a value ranging from -32768 to 32767.
130    *
131    *  The axis indices start at index 0.
132    *}
133 function SDL_JoystickGetAxis(joystick: PSDL_Joystick; axis: SInt32): SInt16 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetAxis' {$ENDIF} {$ENDIF};
134
135   {**
136    *  Hat positions
137    *}
138 const
139   SDL_HAT_CENTERED  = $00;
140   SDL_HAT_UP        = $01;
141   SDL_HAT_RIGHT     = $02;
142   SDL_HAT_DOWN      = $04;
143   SDL_HAT_LEFT      = $08;
144   SDL_HAT_RIGHTUP   = SDL_HAT_RIGHT or SDL_HAT_UP;
145   SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT or SDL_HAT_DOWN;
146   SDL_HAT_LEFTUP    = SDL_HAT_LEFT or SDL_HAT_UP;
147   SDL_HAT_LEFTDOWN  = SDL_HAT_LEFT or SDL_HAT_DOWN;
148
149   {**
150    *  Get the current state of a POV hat on a joystick.
151    *
152    *  The hat indices start at index 0.
153    *
154    *  The return value is one of the following positions:
155    *   - SDL_HAT_CENTERED
156    *   - SDL_HAT_UP
157    *   - SDL_HAT_RIGHT
158    *   - SDL_HAT_DOWN
159    *   - SDL_HAT_LEFT
160    *   - SDL_HAT_RIGHTUP
161    *   - SDL_HAT_RIGHTDOWN
162    *   - SDL_HAT_LEFTUP
163    *   - SDL_HAT_LEFTDOWN
164    *}
165 function SDL_JoystickGetHat(joystick: PSDL_Joystick; hat: SInt32): UInt8 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetHat' {$ENDIF} {$ENDIF};
166
167   {**
168    *  Get the ball axis change since the last poll.
169    *
170    *  0, or -1 if you passed it invalid parameters.
171    *
172    *  The ball indices start at index 0.
173    *}
174 function SDL_JoystickGetBall(joystick: PSDL_Joystick; ball: SInt32; dx: PInt; dy: PInt): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetBall' {$ENDIF} {$ENDIF};
175
176   {**
177    *  Get the current state of a button on a joystick.
178    *
179    *  The button indices start at index 0.
180    *}
181 function SDL_JoystickGetButton(joystick: PSDL_Joystick; button: SInt32): UInt8 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetButton' {$ENDIF} {$ENDIF};
182   {**
183    *  Close a joystick previously opened with SDL_JoystickOpen().
184    *}
185 procedure SDL_JoystickClose(joystick: PSDL_Joystick) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickClose' {$ENDIF} {$ENDIF};