docs/man3/SDL_JoystickOpen.3
author Sam Lantinga <slouken@libsdl.org>
Wed, 08 Mar 2006 18:30:12 +0000
changeset 1486 9d77fc9d0ace
parent 181 e5bc29de3f0a
child 2283 546f7c1eb755
permissions -rw-r--r--
Re-added C runtime support for Visual C++ 5,6
slouken@181
     1
.TH "SDL_JoystickOpen" "3" "Tue 11 Sep 2001, 23:00" "SDL" "SDL API Reference" 
slouken@0
     2
.SH "NAME"
slouken@0
     3
SDL_JoystickOpen\- Opens a joystick for use\&.
slouken@0
     4
.SH "SYNOPSIS"
slouken@0
     5
.PP
slouken@0
     6
\fB#include "SDL\&.h"
slouken@0
     7
.sp
slouken@0
     8
\fBSDL_Joystick *\fBSDL_JoystickOpen\fP\fR(\fBint index\fR);
slouken@0
     9
.SH "DESCRIPTION"
slouken@0
    10
.PP
slouken@0
    11
Opens a joystick for use within SDL\&. The \fBindex\fR refers to the N\&'th joystick in the system\&. A joystick must be opened before it game be used\&.
slouken@0
    12
.SH "RETURN VALUE"
slouken@0
    13
.PP
slouken@0
    14
Returns a \fBSDL_Joystick\fR structure on success\&. \fBNULL\fR on failure\&.
slouken@0
    15
.SH "EXAMPLES"
slouken@0
    16
.PP
slouken@0
    17
.PP
slouken@0
    18
.nf
slouken@0
    19
\f(CWSDL_Joystick *joy;
slouken@0
    20
// Check for joystick
slouken@0
    21
if(SDL_NumJoysticks()>0){
slouken@0
    22
  // Open joystick
slouken@0
    23
  joy=SDL_JoystickOpen(0);
slouken@0
    24
  
slouken@0
    25
  if(joy)
slouken@0
    26
  {
slouken@0
    27
    printf("Opened Joystick 0
slouken@0
    28
");
slouken@0
    29
    printf("Name: %s
slouken@0
    30
", SDL_JoystickName(0));
slouken@181
    31
    printf("Number of Axes: %d
slouken@0
    32
", SDL_JoystickNumAxes(joy));
slouken@181
    33
    printf("Number of Buttons: %d
slouken@0
    34
", SDL_JoystickNumButtons(joy));
slouken@181
    35
    printf("Number of Balls: %d
slouken@0
    36
", SDL_JoystickNumBalls(joy));
slouken@0
    37
  }
slouken@0
    38
  else
slouken@0
    39
    printf("Couldn\&'t open Joystick 0
slouken@0
    40
");
slouken@0
    41
  
slouken@0
    42
  // Close if opened
slouken@0
    43
  if(SDL_JoystickOpened(0))
slouken@0
    44
    SDL_JoystickClose(joy);
slouken@0
    45
}\fR
slouken@0
    46
.fi
slouken@0
    47
.PP
slouken@0
    48
.SH "SEE ALSO"
slouken@0
    49
.PP
slouken@0
    50
\fI\fBSDL_JoystickClose\fP\fR
slouken@181
    51
...\" created by instant / docbook-to-man, Tue 11 Sep 2001, 23:00