1SDL_JoystickOpen(3)            SDL API Reference           SDL_JoystickOpen(3)
2
3
4

NAME

6       SDL_JoystickOpen - Opens a joystick for use.
7

SYNOPSIS

9       #include "SDL.h"
10
11       SDL_Joystick *SDL_JoystickOpen(int index);
12

DESCRIPTION

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

RETURN VALUE

18       Returns a SDL_Joystick structure on success. NULL on failure.
19

EXAMPLES

21       SDL_Joystick *joy;
22       // Check for joystick
23       if(SDL_NumJoysticks()>0){
24         // Open joystick
25         joy=SDL_JoystickOpen(0);
26
27         if(joy)
28         {
29           printf("Opened Joystick 0
30       ");
31           printf("Name: %s
32       ", SDL_JoystickName(0));
33           printf("Number of Axes: %d
34       ", SDL_JoystickNumAxes(joy));
35           printf("Number of Buttons: %d
36       ", SDL_JoystickNumButtons(joy));
37           printf("Number of Balls: %d
38       ", SDL_JoystickNumBalls(joy));
39         }
40         else
41           printf("Couldn't open Joystick 0
42       ");
43
44         // Close if opened
45         if(SDL_JoystickOpened(0))
46           SDL_JoystickClose(joy);
47       }
48

SEE ALSO

50       SDL_JoystickClose
51
52
53
54SDL                         Tue 11 Sep 2001, 23:00         SDL_JoystickOpen(3)
Impressum