1 //from "sdl_joystick.h"
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.
13 {* The joystick structure used to identify an SDL joystick *}
14 PSDL_Joystick = Pointer; // todo!!
16 {* A structure that encodes the stable unique id for a joystick device *}
18 TSDL_JoystickGUID = record
19 data: array[0..15] of UInt8;
22 TSDL_JoystickID = SInt32;
24 {* Function prototypes *}
26 * Count the number of joysticks attached to the system right now
28 function SDL_NumJoysticks: SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_NumJoysticks' {$ENDIF} {$ENDIF};
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.
35 function SDL_JoystickNameForIndex(device_index: SInt32): PAnsiChar cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickNameForIndex' {$ENDIF} {$ENDIF};
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
43 * A joystick identifier, or NULL if an error occurred.
45 function SDL_JoystickOpen(device_index: SInt32): PSDL_Joystick cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickOpen' {$ENDIF} {$ENDIF};
48 * Return the name for this currently opened joystick.
49 * If no name can be found, this function returns NULL.
51 function SDL_JoystickName(joystick: PSDL_Joystick): PAnsiChar cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickName' {$ENDIF} {$ENDIF};
54 * Return the GUID for the joystick at this index
56 function SDL_JoystickGetDeviceGUID(device_index: SInt32): TSDL_JoystickGUID cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetDeviceGUID' {$ENDIF} {$ENDIF};
59 * Return the GUID for this opened joystick
61 function SDL_JoystickGetGUID(joystick: PSDL_Joystick): TSDL_JoystickGUID cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetGUID' {$ENDIF} {$ENDIF};
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).
67 procedure SDL_JoystickGetGUIDString(guid: TSDL_JoystickGUId; pszGUID: PAnsiChar; cbGUID: SInt32) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetGUIDString' {$ENDIF} {$ENDIF};
70 * convert a string into a joystick formatted guid
72 function SDL_JoystickGetGUIDFromString(const pchGUID: PAnsiChar): TSDL_JoystickGUID cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetGUIDFromString' {$ENDIF} {$ENDIF};
75 * Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not.
77 function SDL_JoystickGetAttached(joystick: PSDL_Joystick): TSDL_Bool cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetAttached' {$ENDIF} {$ENDIF};
80 * Get the instance ID of an opened joystick or -1 if the joystick is invalid.
82 function SDL_JoystickInstanceID(joystick: PSDL_Joystick): TSDL_JoystickID cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickInstanceID' {$ENDIF} {$ENDIF};
85 * Get the number of general axis controls on a joystick.
87 function SDL_JoystickNumAxes(joystick: PSDL_Joystick): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickNumAxes' {$ENDIF} {$ENDIF};
90 * Get the number of trackballs on a joystick.
92 * Joystick trackballs have only relative motion events associated
93 * with them and their state cannot be polled.
95 function SDL_JoystickNumBalls(joystick: PSDL_Joystick): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickNumBalls' {$ENDIF} {$ENDIF};
98 * Get the number of POV hats on a joystick.
100 function SDL_JoystickNumHats(joystick: PSDL_Joystick): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickNumHats' {$ENDIF} {$ENDIF};
103 * Get the number of buttons on a joystick.
105 function SDL_JoystickNumButtons(joystick: PSDL_Joystick): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickNumButtons' {$ENDIF} {$ENDIF};
108 * Update the current state of the open joysticks.
110 * This is called automatically by the event loop if any joystick
111 * events are enabled.
113 procedure SDL_JoystickUpdate cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickUpdate' {$ENDIF} {$ENDIF};
116 * Enable/disable joystick event polling.
118 * If joystick events are disabled, you must call SDL_JoystickUpdate()
119 * yourself and check the state of the joystick when you want joystick
122 * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE.
124 function SDL_JoystickEventState(state: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickEventState' {$ENDIF} {$ENDIF};
127 * Get the current state of an axis control on a joystick.
129 * The state is a value ranging from -32768 to 32767.
131 * The axis indices start at index 0.
133 function SDL_JoystickGetAxis(joystick: PSDL_Joystick; axis: SInt32): SInt16 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetAxis' {$ENDIF} {$ENDIF};
139 SDL_HAT_CENTERED = $00;
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;
150 * Get the current state of a POV hat on a joystick.
152 * The hat indices start at index 0.
154 * The return value is one of the following positions:
161 * - SDL_HAT_RIGHTDOWN
165 function SDL_JoystickGetHat(joystick: PSDL_Joystick; hat: SInt32): UInt8 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetHat' {$ENDIF} {$ENDIF};
168 * Get the ball axis change since the last poll.
170 * 0, or -1 if you passed it invalid parameters.
172 * The ball indices start at index 0.
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};
177 * Get the current state of a button on a joystick.
179 * The button indices start at index 0.
181 function SDL_JoystickGetButton(joystick: PSDL_Joystick; button: SInt32): UInt8 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetButton' {$ENDIF} {$ENDIF};
183 * Close a joystick previously opened with SDL_JoystickOpen().
185 procedure SDL_JoystickClose(joystick: PSDL_Joystick) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickClose' {$ENDIF} {$ENDIF};