Go to main content

man pages section 3: Library Interfaces and Headers

Exit Print View

Updated: Thursday, June 13, 2019
 
 

SDL_JoystickOpen (3)

Name

SDL_JoystickOpen - Opens a joystick for use.

Synopsis

#include "SDL.h"

SDL_Joystick *SDL_JoystickOpen(int index);

Description

SDL_JoystickOpen(3)            SDL API Reference           SDL_JoystickOpen(3)



NAME
       SDL_JoystickOpen - Opens a joystick for use.

SYNOPSIS
       #include "SDL.h"

       SDL_Joystick *SDL_JoystickOpen(int index);

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

RETURN VALUE
       Returns a SDL_Joystick structure on success. NULL on failure.

EXAMPLES
       SDL_Joystick *joy;
       // Check for joystick
       if(SDL_NumJoysticks()>0){
         // Open joystick
         joy=SDL_JoystickOpen(0);

         if(joy)
         {
           printf("Opened Joystick 0
       ");
           printf("Name: %s
       ", SDL_JoystickName(0));
           printf("Number of Axes: %d
       ", SDL_JoystickNumAxes(joy));
           printf("Number of Buttons: %d
       ", SDL_JoystickNumButtons(joy));
           printf("Number of Balls: %d
       ", SDL_JoystickNumBalls(joy));
         }
         else
           printf("Couldn't open Joystick 0
       ");

         // Close if opened
         if(SDL_JoystickOpened(0))
           SDL_JoystickClose(joy);
       }

ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:


       +---------------+------------------+
       |ATTRIBUTE TYPE | ATTRIBUTE VALUE  |
       +---------------+------------------+
       |Availability   | library/sdl      |
       +---------------+------------------+
       |Stability      | Volatile         |
       +---------------+------------------+
SEE ALSO
       SDL_JoystickClose



NOTES
       This    software    was    built    from    source     available     at
       https://github.com/oracle/solaris-userland.    The  original  community
       source       was        downloaded        from         https://www.lib-
       sdl.org/release/SDL-1.2.15.tar.gz

       Further information about this software can be found on the open source
       community website at https://www.libsdl.org/.



SDL                         Tue 11 Sep 2001, 23:00         SDL_JoystickOpen(3)