SDL_JoystickOpen

Name

SDL_JoystickOpen -- Opens a joystick for use.

Synopsis

uses
SDL;

function SDL_JoystickOpen( index : Integer ) : PSDL_Joystick;

Description

Opens a joystick for use within SDL. The index refers to the N'th joystick in the system. A joystick must be opened before it game be used.

Return Value

Returns a SDL_Joystick structure on success. nil on failure.

Examples

joy : PSDL_Joystick;
.
.
.
// Check for joystick
if ( SDL_NumJoysticks > 0 ) then
begin
// Open joystick
joy := SDL_JoystickOpen( 0 );

if ( joy <> nil ) then
begin
WriteLn( 'Opened Joystick 0' );
WriteLn( Format( 'Name: %s', [ SDL_JoystickName( 0 ) ] ) );
WriteLn( Format( 'Number of Axes: %s', [ SDL_JoystickNumAxes( joy ) ] ) );
WriteLn( Format( 'Number of Buttons: %s', [ SDL_JoystickNumButtons( joy ) ] ) );
WriteLn( Format( 'Number of Balls: %s', [ SDL_JoystickNumBalls( joy ) ] ) );
end
else
WriteLn( 'Couldn't open Joystick 0' );

// Close if opened
if ( SDL_JoystickOpened( 0 ) <> nil ) then
SDL_JoystickClose( joy );
end;

See Also

SDL_JoystickClose